liquid_feedback_frontend
diff app/main/delegation/_info.lua @ 525:63d6549cc00b
Delegation chain preview improved, better visualisation of current context, code cleanup
author | bsw |
---|---|
date | Fri May 18 19:07:07 2012 +0200 (2012-05-18) |
parents | |
children | 18cd8595459b |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/app/main/delegation/_info.lua Fri May 18 19:07:07 2012 +0200 1.3 @@ -0,0 +1,188 @@ 1.4 +local unit = param.get("unit", "table") 1.5 +local area = param.get("area", "table") 1.6 +local issue = param.get("issue", "table") 1.7 + 1.8 +local unit_id = unit and unit.id or nil 1.9 +local area_id = area and area.id or nil 1.10 +local issue_id = issue and issue.id or nil 1.11 + 1.12 +local info 1.13 +local delegation_text 1.14 + 1.15 +if unit then 1.16 + unit:load_delegation_info_once_for_member_id(app.session.member_id) 1.17 + info = unit.delegation_info 1.18 + delegation_text = _"Delegate unit" 1.19 +end 1.20 + 1.21 +if area then 1.22 + area:load_delegation_info_once_for_member_id(app.session.member_id) 1.23 + info = area.delegation_info 1.24 + delegation_text = _"Delegate area" 1.25 +end 1.26 + 1.27 +if issue then 1.28 + issue:load_delegation_info_once_for_member_id(app.session.member_id) 1.29 + info = issue.delegation_info 1.30 + delegation_text = _"Delegate issue" 1.31 +end 1.32 + 1.33 +ui.link{ 1.34 + module = "delegation", view = "show", params = { 1.35 + unit_id = unit_id, 1.36 + area_id = area_id, 1.37 + issue_id = issue_id 1.38 + }, 1.39 + attr = { class = "delegation_info" }, content = function() 1.40 + 1.41 + 1.42 + local participant_occured = false 1.43 + 1.44 + if info.own_participation or info.first_trustee_id then 1.45 + 1.46 + local class = "micro_avatar" 1.47 + if info.own_participation then 1.48 + participant_occured = true 1.49 + class = class .. " highlighted" 1.50 + end 1.51 + 1.52 + execute.view{ module = "member_image", view = "_show", params = { 1.53 + member = app.session.member, class = class, popup_text = app.session.member.name, 1.54 + image_type = "avatar", show_dummy = true, 1.55 + } } 1.56 + 1.57 + end 1.58 + 1.59 + if not info.first_trustee_id and (not issue or not issue.closed) then 1.60 + slot.put(" ") 1.61 + ui.tag{ attr = { class = "link" }, content = delegation_text } 1.62 + end 1.63 + 1.64 + if not (issue and issue.state == "voting" and info.own_participation) then 1.65 + 1.66 + if info.first_trustee_id then 1.67 + 1.68 + local text = _"delegates to" 1.69 + ui.image{ 1.70 + attr = { class = "delegation_arrow", alt = text, title = text }, 1.71 + static = "delegation_arrow_24_horizontal.png" 1.72 + } 1.73 + 1.74 + local class = "micro_avatar" 1.75 + if not participant_occured and info.first_trustee_participation then 1.76 + participant_occured = true 1.77 + class = class .. " highlighted" 1.78 + end 1.79 + 1.80 + execute.view{ module = "member_image", view = "_show", params = { 1.81 + member_id = info.first_trustee_id, class = class, popup_text = info.first_trustee_name, 1.82 + image_type = "avatar", show_dummy = true, 1.83 + } } 1.84 + 1.85 + end 1.86 + 1.87 + if info.first_trustee_ellipsis then 1.88 + 1.89 + local text = _"delegates to" 1.90 + ui.image{ 1.91 + attr = { class = "delegation_arrow", alt = text, title = text }, 1.92 + static = "delegation_arrow_24_horizontal.png" 1.93 + } 1.94 + 1.95 + slot.put("...") 1.96 + 1.97 + end 1.98 + 1.99 + if info.other_trustee_id then 1.100 + 1.101 + local text = _"delegates to" 1.102 + ui.image{ 1.103 + attr = { class = "delegation_arrow", alt = text, title = text }, 1.104 + static = "delegation_arrow_24_horizontal.png" 1.105 + } 1.106 + 1.107 + local class = "micro_avatar" 1.108 + if not participant_occured and info.other_trustee_participation then 1.109 + participant_occured = true 1.110 + class = class .. " highlighted" 1.111 + end 1.112 + 1.113 + execute.view{ module = "member_image", view = "_show", params = { 1.114 + member_id = info.other_trustee_id, class = class, popup_text = info.other_trustee_name, 1.115 + image_type = "avatar", show_dummy = true, 1.116 + } } 1.117 + 1.118 + end 1.119 + 1.120 + if info.other_trustee_ellipsis then 1.121 + 1.122 + local text = _"delegates to" 1.123 + ui.image{ 1.124 + attr = { class = "delegation_arrow", alt = text, title = text }, 1.125 + static = "delegation_arrow_24_horizontal.png" 1.126 + } 1.127 + 1.128 + slot.put("...") 1.129 + 1.130 + end 1.131 + 1.132 + local trailing_ellipsis = info.other_trustee_ellipsis or 1.133 + (info.first_trustee_ellipsis and not info.other_trustee_id) 1.134 + 1.135 + if info.delegation_loop == "own" then 1.136 + 1.137 + local text = _"delegates to" 1.138 + ui.image{ 1.139 + attr = { class = "delegation_arrow", alt = text, title = text }, 1.140 + static = "delegation_arrow_24_horizontal.png" 1.141 + } 1.142 + 1.143 + execute.view{ module = "member_image", view = "_show", params = { 1.144 + member = app.session.member, class = "micro_avatar", popup_text = app.session.member.name, 1.145 + image_type = "avatar", show_dummy = true, 1.146 + } } 1.147 + 1.148 + elseif info.delegation_loop == "first" then 1.149 + if info.first_trustee_ellipsis then 1.150 + if not trailing_ellipsis then 1.151 + 1.152 + local text = _"delegates to" 1.153 + ui.image{ 1.154 + attr = { class = "delegation_arrow", alt = text, title = text }, 1.155 + static = "delegation_arrow_24_horizontal.png" 1.156 + } 1.157 + 1.158 + slot.put("...") 1.159 + end 1.160 + 1.161 + else 1.162 + 1.163 + local text = _"delegates to" 1.164 + ui.image{ 1.165 + attr = { class = "delegation_arrow", alt = text, title = text }, 1.166 + static = "delegation_arrow_24_horizontal.png" 1.167 + } 1.168 + 1.169 + execute.view{ module = "member_image", view = "_show", params = { 1.170 + member_id = info.first_trustee_id, class = "micro_avatar", popup_text = info.first_trustee_name, 1.171 + image_type = "avatar", show_dummy = true, 1.172 + } } 1.173 + end 1.174 + 1.175 + 1.176 + elseif info.delegation_loop and not trailing_ellipsis then 1.177 + local text = _"delegates to" 1.178 + ui.image{ 1.179 + attr = { class = "delegation_arrow", alt = text, title = text }, 1.180 + static = "delegation_arrow_24_horizontal.png" 1.181 + } 1.182 + 1.183 + slot.put("...") 1.184 + end 1.185 + 1.186 + end 1.187 + 1.188 + end 1.189 + 1.190 +} 1.191 +