bsw@10: local initiator = param.get("initiator", "table") bsw@2: local member = param.get("member", "table") bsw@2: bsw@3: local issue = param.get("issue", "table") bsw@3: local initiative = param.get("initiative", "table") bsw@3: local trustee = param.get("trustee", "table") bsw@3: bsw@1045: local class = param.get("class") bsw@1045: bsw@606: local name_html bsw@2: if member.name_highlighted then bsw@606: name_html = encode.highlight(member.name_highlighted) bsw@2: else bsw@606: name_html = encode.html(member.name) bsw@2: end bsw@2: bsw/jbe@1309: local container_class = "mdl-chip mdl-chip--contact clickable mdl-badge mdl-badge--overlap" bsw@10: if initiator and member.accepted ~= true then bsw@10: container_class = container_class .. " not_accepted" bsw@10: end bsw@10: bsw/jbe@19: if member.is_informed == false then bsw/jbe@19: container_class = container_class .. " not_informed" bsw/jbe@19: end bsw/jbe@19: bsw@1045: if class then bsw@1045: container_class = container_class .. " " .. class bsw@1045: end bsw@1045: bsw@1045: local in_delegation_chain = member.in_delegation_chain bsw@1045: --[[if member.delegate_member_ids then bsw@177: for member_id in member.delegate_member_ids:gmatch("(%w+)") do bsw@177: if tonumber(member_id) == member.id then bsw@177: in_delegation_chain = true bsw@177: end bsw@177: end bsw@177: end bsw@1045: --]] bsw@179: if in_delegation_chain or ((issue or initiative) and member.id == app.session.member_id) then bsw@177: container_class = container_class .. " in_delegation_chain" bsw@177: end bsw@177: bsw/jbe@1309: local el_id = multirand.string(32, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz") bsw/jbe@1309: local weight = 0 bsw@1503: local ownweight = member.ownweight bsw/jbe@1309: if member.weight then bsw/jbe@1309: weight = member.weight bsw/jbe@1309: end bsw/jbe@1309: if member.voter_weight then bsw/jbe@1309: weight = member.voter_weight bsw/jbe@1309: end bsw@1503: local delegated_weight = weight - (ownweight or 0) bsw@1503: bsw@1503: local weight_text = "" bsw@1503: bsw@1503: if ownweight and ownweight > 1 then bsw@1503: weight_text = weight_text .. ownweight bsw@1503: end bsw@1503: bsw@1503: if delegated_weight > 0 then bsw@1503: weight_text = weight_text .. "+" .. delegated_weight bsw@1503: end bsw@1503: bsw@1503: if weight_text == "" then bsw@1503: weight_text = nil bsw@1503: end bsw/jbe@1309: bsw@3: ui.container{ bsw@1503: attr = { id = el_id, class = container_class }, bsw@2: content = function() bsw@1045: bsw/jbe@1309: execute.view{ bsw/jbe@1309: module = "member_image", bsw/jbe@1309: view = "_show", bsw/jbe@1309: params = { bsw/jbe@1309: member = member, bsw/jbe@1309: image_type = "avatar", bsw/jbe@1309: show_dummy = true bsw@1045: } bsw/jbe@1309: } bsw/jbe@1309: ui.tag{ bsw/jbe@1309: attr = { class = "mdl-chip__text" }, bsw@1503: content = function() bsw@1503: slot.put(name_html) bsw@1503: if weight_text then bsw@1503: slot.put(" ") bsw@1503: ui.tag{ attr = { class = "member_weight" }, content = weight_text } bsw@1503: end bsw@1503: end bsw/jbe@1309: } bsw@1045: bsw@1045: if member.grade then bsw@1045: slot.put ( " " ) bsw/jbe@1309: if member.grade > 0 then bsw/jbe@1309: ui.tag{ tag = "i", attr = { class = "material-icons icon-green" }, content = "thumb_up" } bsw/jbe@1309: elseif member.grade < 0 then bsw/jbe@1309: ui.tag{ tag = "i", attr = { class = "material-icons icon-red" }, content = "thumb_down" } bsw/jbe@1309: else bsw/jbe@1309: ui.tag{ tag = "i", attr = { class = "material-icons icon-yellow" }, content = "brightness_1" } bsw/jbe@1309: end bsw/jbe@1309: end bsw/jbe@1309: bsw/jbe@1309: if (member.voter_comment) then bsw@1606: local text = _"Voting comment available", bsw@1606: ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "comment" } bsw@1045: end bsw@1045: bsw/jbe@19: bsw/jbe@1309: if (issue or initiative) and weight > 0 then bsw@1045: end bsw@1045: bsw@1045: if member.supporter then bsw/jbe@1309: ui.tag { attr = { class = "mdl-chip__action" }, content = function() bsw/jbe@1309: if member.supporter_satisfied then bsw/jbe@1309: local text = _"supporter" bsw/jbe@1309: ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "thumb_up" } bsw/jbe@1309: else bsw/jbe@1309: local text = _"supporter with restricting suggestions" bsw/jbe@1309: ui.tag{ tag = "i", attr = { class = "material-icons mdl-color-text--orange-900" }, content = "thumb_up" } bsw/jbe@1309: end bsw/jbe@1309: end } bsw@1045: end bsw/jbe@4: bsw@1045: if not member.active then bsw@1045: local text = _"member inactive" bsw@1606: ui.tag{ tag = "i", attr = { class = "material-icons icon-red" }, content = "disabled_by_default" } bsw@1045: end bsw@1045: bsw@1045: if initiator and initiator.accepted then bsw@1045: if member.accepted == nil then bsw@1045: slot.put(_"Invited") bsw@1045: elseif member.accepted == false then bsw@1045: slot.put(_"Rejected") bsw@3: end bsw@1045: end bsw@1045: bsw@1045: if member.is_informed == false then bsw@1045: local text = _"Member has not approved latest draft" bsw@1606: ui.tag{ tag = "i", attr = { class = "material-icons icon-yellow" }, content = "help" } bsw@1045: end bsw@1045: bsw@2: end bsw@3: } bsw/jbe@1309: bsw/jbe@1309: if member.grade or (issue and weight > 1) or app.session.member_id or app.session:has_access("everything") then bsw/jbe@1309: ui.tag { tag = "ul", attr = { class = "mdl-menu mdl-menu--bottom-left mdl-js-menu mdl-js-ripple-effect", ["for"] = el_id }, content = function() bsw/jbe@1309: if (member.grade) then bsw/jbe@1309: ui.tag{ tag = "li", attr = { class = "mdl-menu__item" }, content = function() bsw/jbe@1309: ui.link{ bsw/jbe@1309: attr = { class = "mdl-menu__link" }, bsw/jbe@1309: module = "vote", bsw/jbe@1309: view = "list", bsw/jbe@1309: params = { bsw/jbe@1309: issue_id = issue.id, bsw/jbe@1309: member_id = member.id, bsw/jbe@1309: }, bsw/jbe@1309: content = _"show ballot" bsw/jbe@1309: } bsw/jbe@1309: end } bsw/jbe@1309: end bsw/jbe@1309: if issue and weight > 1 then bsw/jbe@1309: ui.tag{ tag = "li", attr = { class = "mdl-menu__item" }, content = function() bsw/jbe@1309: local module = "interest" bsw/jbe@1309: if member.voter_weight then bsw/jbe@1309: module = "vote" bsw/jbe@1309: end bsw/jbe@1309: ui.link{ attr = { class = "mdl-menu__link" }, content = _"show incoming delegations", module = module, view = "show_incoming", params = { bsw/jbe@1309: member_id = member.id, bsw/jbe@1309: initiative_id = initiative and initiative.id or nil, bsw/jbe@1309: issue_id = issue and issue.id or nil bsw/jbe@1309: } } bsw/jbe@1309: end } bsw/jbe@1309: end bsw/jbe@1309: if app.session:has_access("everything") then bsw/jbe@1309: ui.tag{ tag = "li", attr = { class = "mdl-menu__item" }, content = function() bsw/jbe@1309: ui.link{ attr = { class = "mdl-menu__link" }, content = _"show profile", module = "member", view = "show", id = member.id } bsw/jbe@1309: end } bsw/jbe@1309: end bsw/jbe@1309: if app.session.member_id then bsw/jbe@1309: ui.tag{ tag = "li", attr = { class = "mdl-menu__item" }, content = function() bsw/jbe@1309: ui.link{ bsw/jbe@1309: attr = { class = "mdl-menu__link" }, bsw/jbe@1309: text = _"add to my list of private contacts", bsw/jbe@1309: module = "contact", bsw/jbe@1309: action = "add_member", bsw/jbe@1309: id = member.id, bsw/jbe@1309: routing = { bsw/jbe@1309: default = { bsw/jbe@1309: mode = "redirect", bsw/jbe@1309: module = request.get_module(), bsw/jbe@1309: view = request.get_view(), bsw/jbe@1309: id = request.get_id_string(), bsw/jbe@1309: params = request.get_param_strings() bsw/jbe@1309: } bsw/jbe@1309: } bsw/jbe@1309: } bsw/jbe@1309: end } bsw/jbe@1309: end bsw/jbe@1309: end } bsw/jbe@1309: end