bsw@526: if not app.session.member_id then bsw@526: return bsw@526: end bsw@526: bsw@774: local member = param.get("member", "table") or app.session.member bsw@774: bsw@525: local unit = param.get("unit", "table") bsw@525: local area = param.get("area", "table") bsw@525: local issue = param.get("issue", "table") bsw@525: bsw@1045: local for_title = param.get("for_title", "boolean") bsw@1045: bsw@525: local unit_id = unit and unit.id or nil bsw@525: local area_id = area and area.id or nil bsw@525: local issue_id = issue and issue.id or nil bsw@525: bsw@525: local info bsw@525: local delegation_text bsw@525: bsw@525: if unit then bsw@525: info = unit.delegation_info bsw@525: delegation_text = _"Delegate unit" bsw@525: end bsw@525: bsw@525: if area then bsw@525: info = area.delegation_info bsw@525: delegation_text = _"Delegate area" bsw@525: end bsw@525: bsw@525: if issue then bsw@774: info = issue.member_info bsw@525: delegation_text = _"Delegate issue" bsw@525: end bsw@525: bsw@1045: if not info then bsw@1045: --return bsw@1045: end bsw@1045: bsw@780: local function print_delegation_info() bsw@1045: local participant_occured = info.own_participation bsw@780: bsw@780: if not (issue and issue.state == "voting" and info.own_participation) then bsw@780: bsw@780: if info.first_trustee_id then bsw@780: bsw@780: local text = _"delegates to" bsw@780: ui.image{ bsw@780: attr = { class = "delegation_arrow", alt = text, title = text }, bsw@780: static = "delegation_arrow_24_horizontal.png" bsw@780: } bsw@780: bsw@780: local class = "micro_avatar" bsw@780: if not participant_occured and info.first_trustee_participation then bsw@780: participant_occured = true bsw@780: class = class .. " highlighted" bsw@780: end bsw@525: bsw@780: execute.view{ module = "member_image", view = "_show", params = { bsw@780: member_id = info.first_trustee_id, class = class, popup_text = info.first_trustee_name, bsw@780: image_type = "avatar", show_dummy = true, bsw@780: } } bsw@780: bsw@780: end bsw@780: bsw@780: if info.first_trustee_ellipsis then bsw@780: bsw@780: local text = _"delegates to" bsw@780: ui.image{ bsw@780: attr = { class = "delegation_arrow", alt = text, title = text }, bsw@780: static = "delegation_arrow_24_horizontal.png" bsw@780: } bsw@525: bsw@780: slot.put("...") bsw@780: bsw@780: end bsw@780: bsw@780: if info.other_trustee_id then bsw@780: bsw@780: local text = _"delegates to" bsw@780: ui.image{ bsw@780: attr = { class = "delegation_arrow", alt = text, title = text }, bsw@780: static = "delegation_arrow_24_horizontal.png" bsw@780: } bsw@525: bsw@780: local class = "micro_avatar" bsw@780: if not participant_occured and info.other_trustee_participation then bsw@780: participant_occured = true bsw@780: class = class .. " highlighted" bsw@780: end bsw@780: bsw@780: execute.view{ module = "member_image", view = "_show", params = { bsw@780: member_id = info.other_trustee_id, class = class, popup_text = info.other_trustee_name, bsw@780: image_type = "avatar", show_dummy = true, bsw@780: } } bsw@780: bsw@780: end bsw@780: bsw@780: if info.other_trustee_ellipsis then bsw@525: bsw@780: local text = _"delegates to" bsw@780: ui.image{ bsw@780: attr = { class = "delegation_arrow", alt = text, title = text }, bsw@780: static = "delegation_arrow_24_horizontal.png" bsw@780: } bsw@529: bsw@780: slot.put("...") bsw@780: bsw@780: end bsw@780: bsw@780: local trailing_ellipsis = info.other_trustee_ellipsis or bsw@780: (info.first_trustee_ellipsis and not info.other_trustee_id) bsw@780: bsw@780: if info.delegation_loop == "own" then bsw@780: bsw@780: local text = _"delegates to" bsw@780: ui.image{ bsw@780: attr = { class = "delegation_arrow", alt = text, title = text }, bsw@780: static = "delegation_arrow_24_horizontal.png" bsw@780: } bsw@780: bsw@780: execute.view{ module = "member_image", view = "_show", params = { bsw@780: member = member, class = "micro_avatar", popup_text = member.name, bsw@780: image_type = "avatar", show_dummy = true, bsw@780: } } bsw@780: bsw@780: elseif info.delegation_loop == "first" then bsw@780: if info.first_trustee_ellipsis then bsw@780: if not trailing_ellipsis then bsw@529: bsw@529: local text = _"delegates to" bsw@529: ui.image{ bsw@529: attr = { class = "delegation_arrow", alt = text, title = text }, bsw@529: static = "delegation_arrow_24_horizontal.png" bsw@529: } bsw@529: bsw@529: slot.put("...") bsw@780: end bsw@529: bsw@780: else bsw@529: bsw@780: local text = _"delegates to" bsw@780: ui.image{ bsw@780: attr = { class = "delegation_arrow", alt = text, title = text }, bsw@780: static = "delegation_arrow_24_horizontal.png" bsw@780: } bsw@525: bsw@1045: execute.view{ bsw@1045: module = "member_image", view = "_show", params = { bsw@1045: member_id = info.first_trustee_id, bsw@1045: class = "micro_avatar", bsw@1045: popup_text = info.first_trustee_name, bsw@1045: image_type = "avatar", bsw@1045: show_dummy = true, bsw@1045: } bsw@1045: } bsw@780: end bsw@780: bsw@529: bsw@780: elseif info.delegation_loop and not trailing_ellipsis then bsw@780: local text = _"delegates to" bsw@780: ui.image{ bsw@780: attr = { class = "delegation_arrow", alt = text, title = text }, bsw@780: static = "delegation_arrow_24_horizontal.png" bsw@780: } bsw@525: bsw@780: slot.put("...") bsw@780: end bsw@529: bsw@780: end bsw@780: end bsw@529: bsw@1045: if not param.get("no_star", "boolean") then bsw@1045: bsw@1045: if info.own_participation then bsw@1045: if issue and issue.fully_frozen then bsw@1045: ui.link{ bsw/jbe@1309: attr = { class = "mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--underlined" }, bsw@1045: module = "vote", view = "list", params = { bsw@1045: issue_id = issue.id bsw@1045: }, bsw@1045: content = function () bsw@1045: ui.tag { content = _"you voted" } bsw@1045: end bsw@1045: } bsw@1045: else bsw@1045: if issue then bsw/jbe@1309: ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "star" } bsw/jbe@1309: slot.put(" ") bsw/jbe@1309: ui.tag{ content = _"you are interested" } bsw@1045: if not issue.closed and info.own_participation and info.weight and info.weight > 1 then bsw@1489: slot.put(" ") bsw@1045: ui.link { bsw@1045: attr = { class = "right" }, content = "+" .. (info.weight - 1), bsw@1489: module = "interest", view = "show_incoming", params = { bsw@1045: issue_id = issue.id, member_id = member.id bsw@1045: } bsw@1045: } bsw@1045: end bsw@1045: else bsw@1045: local text = _"you are subscribed" bsw@1045: ui.image { attr = { class = "icon24 star", title = text, alt = text }, static = "icons/48/star.png" } bsw@1045: end bsw/jbe@1309: slot.put(" ") bsw@1045: end bsw@1045: end bsw@1045: end bsw@1045: bsw@529: bsw@780: if info.own_participation or info.first_trustee_id then bsw@1045: local class = "delegation_info" bsw@1045: if info.own_participation then bsw@1045: class = class .. " suspended" bsw@1045: end bsw@1045: bsw@1045: local voting_member_id bsw@1045: local voting_member_name bsw@1045: if issue and issue.fully_frozen and issue.closed then bsw@1045: if issue.member_info.first_trustee_participation then bsw@1045: voting_member_id = issue.member_info.first_trustee_id bsw@1045: voting_member_name = issue.member_info.first_trustee_name bsw@1045: elseif issue.member_info.other_trustee_participation then bsw@1045: voting_member_id = issue.member_info.other_trustee_id bsw@1045: voting_member_name = issue.member_info.other_trustee_name bsw@1045: end bsw@1045: end bsw@1045: bsw@780: if app.session.member_id == member.id then bsw@1045: bsw@1045: if voting_member_id then bsw@1045: ui.link{ bsw@1045: module = "vote", view = "list", params = { bsw@1045: issue_id = issue.id, bsw@1045: member_id = voting_member_id bsw@1045: }, bsw@1045: attr = { class = class }, content = function() bsw@1045: print_delegation_info() bsw@1045: end bsw@1045: } bsw@1045: bsw@1045: else bsw@1045: ui.link{ bsw@1045: module = "delegation", view = "show", params = { bsw@1045: unit_id = unit_id, bsw@1045: area_id = area_id, bsw@1045: issue_id = issue_id bsw@1045: }, bsw@1045: attr = { class = class }, content = function() bsw@1045: print_delegation_info() bsw@1045: end bsw@1045: } bsw@1045: end bsw@780: else bsw@780: ui.container{ bsw@1045: attr = { class = class }, content = function() bsw@780: print_delegation_info() bsw@780: end bsw@780: } bsw@780: end bsw@551: end bsw@1045: bsw/jbe@1309: if issue and app.session.member and issue.fully_frozen and not issue.closed and not issue.member_info.direct_voted and app.session.member:has_voting_right_for_unit_id(issue.area.unit_id) then bsw/jbe@1309: ui.link{ bsw/jbe@1309: attr = { class = "mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--underlined" }, bsw/jbe@1309: module = "vote", view = "list", params = { bsw/jbe@1309: issue_id = issue.id bsw/jbe@1309: }, bsw/jbe@1309: content = function () bsw/jbe@1309: ui.tag { content = _"vote now" } bsw/jbe@1309: end bsw/jbe@1309: } bsw/jbe@1309: else bsw/jbe@1309: end