liquid_feedback_frontend

view 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 source
1 local unit = param.get("unit", "table")
2 local area = param.get("area", "table")
3 local issue = param.get("issue", "table")
5 local unit_id = unit and unit.id or nil
6 local area_id = area and area.id or nil
7 local issue_id = issue and issue.id or nil
9 local info
10 local delegation_text
12 if unit then
13 unit:load_delegation_info_once_for_member_id(app.session.member_id)
14 info = unit.delegation_info
15 delegation_text = _"Delegate unit"
16 end
18 if area then
19 area:load_delegation_info_once_for_member_id(app.session.member_id)
20 info = area.delegation_info
21 delegation_text = _"Delegate area"
22 end
24 if issue then
25 issue:load_delegation_info_once_for_member_id(app.session.member_id)
26 info = issue.delegation_info
27 delegation_text = _"Delegate issue"
28 end
30 ui.link{
31 module = "delegation", view = "show", params = {
32 unit_id = unit_id,
33 area_id = area_id,
34 issue_id = issue_id
35 },
36 attr = { class = "delegation_info" }, content = function()
39 local participant_occured = false
41 if info.own_participation or info.first_trustee_id then
43 local class = "micro_avatar"
44 if info.own_participation then
45 participant_occured = true
46 class = class .. " highlighted"
47 end
49 execute.view{ module = "member_image", view = "_show", params = {
50 member = app.session.member, class = class, popup_text = app.session.member.name,
51 image_type = "avatar", show_dummy = true,
52 } }
54 end
56 if not info.first_trustee_id and (not issue or not issue.closed) then
57 slot.put(" ")
58 ui.tag{ attr = { class = "link" }, content = delegation_text }
59 end
61 if not (issue and issue.state == "voting" and info.own_participation) then
63 if info.first_trustee_id then
65 local text = _"delegates to"
66 ui.image{
67 attr = { class = "delegation_arrow", alt = text, title = text },
68 static = "delegation_arrow_24_horizontal.png"
69 }
71 local class = "micro_avatar"
72 if not participant_occured and info.first_trustee_participation then
73 participant_occured = true
74 class = class .. " highlighted"
75 end
77 execute.view{ module = "member_image", view = "_show", params = {
78 member_id = info.first_trustee_id, class = class, popup_text = info.first_trustee_name,
79 image_type = "avatar", show_dummy = true,
80 } }
82 end
84 if info.first_trustee_ellipsis then
86 local text = _"delegates to"
87 ui.image{
88 attr = { class = "delegation_arrow", alt = text, title = text },
89 static = "delegation_arrow_24_horizontal.png"
90 }
92 slot.put("...")
94 end
96 if info.other_trustee_id then
98 local text = _"delegates to"
99 ui.image{
100 attr = { class = "delegation_arrow", alt = text, title = text },
101 static = "delegation_arrow_24_horizontal.png"
102 }
104 local class = "micro_avatar"
105 if not participant_occured and info.other_trustee_participation then
106 participant_occured = true
107 class = class .. " highlighted"
108 end
110 execute.view{ module = "member_image", view = "_show", params = {
111 member_id = info.other_trustee_id, class = class, popup_text = info.other_trustee_name,
112 image_type = "avatar", show_dummy = true,
113 } }
115 end
117 if info.other_trustee_ellipsis then
119 local text = _"delegates to"
120 ui.image{
121 attr = { class = "delegation_arrow", alt = text, title = text },
122 static = "delegation_arrow_24_horizontal.png"
123 }
125 slot.put("...")
127 end
129 local trailing_ellipsis = info.other_trustee_ellipsis or
130 (info.first_trustee_ellipsis and not info.other_trustee_id)
132 if info.delegation_loop == "own" then
134 local text = _"delegates to"
135 ui.image{
136 attr = { class = "delegation_arrow", alt = text, title = text },
137 static = "delegation_arrow_24_horizontal.png"
138 }
140 execute.view{ module = "member_image", view = "_show", params = {
141 member = app.session.member, class = "micro_avatar", popup_text = app.session.member.name,
142 image_type = "avatar", show_dummy = true,
143 } }
145 elseif info.delegation_loop == "first" then
146 if info.first_trustee_ellipsis then
147 if not trailing_ellipsis then
149 local text = _"delegates to"
150 ui.image{
151 attr = { class = "delegation_arrow", alt = text, title = text },
152 static = "delegation_arrow_24_horizontal.png"
153 }
155 slot.put("...")
156 end
158 else
160 local text = _"delegates to"
161 ui.image{
162 attr = { class = "delegation_arrow", alt = text, title = text },
163 static = "delegation_arrow_24_horizontal.png"
164 }
166 execute.view{ module = "member_image", view = "_show", params = {
167 member_id = info.first_trustee_id, class = "micro_avatar", popup_text = info.first_trustee_name,
168 image_type = "avatar", show_dummy = true,
169 } }
170 end
173 elseif info.delegation_loop and not trailing_ellipsis then
174 local text = _"delegates to"
175 ui.image{
176 attr = { class = "delegation_arrow", alt = text, title = text },
177 static = "delegation_arrow_24_horizontal.png"
178 }
180 slot.put("...")
181 end
183 end
185 end
187 }

Impressum / About Us