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@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@774: area:load_delegation_info_once_for_member_id(member.id) 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@780: local function print_delegation_info() bsw@780: local participant_occured = false bsw@780: bsw@780: if info.own_participation or info.first_trustee_id then bsw@780: bsw@780: local class = "micro_avatar" bsw@780: if info.own_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 = member, class = class, popup_text = member.name, bsw@780: image_type = "avatar", show_dummy = true, bsw@780: } } bsw@525: bsw@780: end bsw@525: 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@780: execute.view{ module = "member_image", view = "_show", params = { bsw@780: member_id = info.first_trustee_id, class = "micro_avatar", popup_text = info.first_trustee_name, bsw@780: image_type = "avatar", show_dummy = true, bsw@780: } } 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@529: bsw@780: if info.own_participation or info.first_trustee_id then bsw@780: if app.session.member_id == member.id then bsw@780: ui.link{ bsw@780: module = "delegation", view = "show", params = { bsw@780: unit_id = unit_id, bsw@780: area_id = area_id, bsw@780: issue_id = issue_id bsw@780: }, bsw@780: attr = { class = "delegation_info" }, content = function() bsw@780: print_delegation_info() bsw@525: end bsw@780: } bsw@780: else bsw@780: ui.container{ bsw@780: attr = { class = "delegation_info" }, content = function() bsw@780: print_delegation_info() bsw@780: end bsw@780: } bsw@780: end bsw@551: end