| rev |
line source |
|
bsw@526
|
1 if not app.session.member_id then
|
|
bsw@526
|
2 return
|
|
bsw@526
|
3 end
|
|
bsw@526
|
4
|
|
bsw@774
|
5 local member = param.get("member", "table") or app.session.member
|
|
bsw@774
|
6
|
|
bsw@525
|
7 local unit = param.get("unit", "table")
|
|
bsw@525
|
8 local area = param.get("area", "table")
|
|
bsw@525
|
9 local issue = param.get("issue", "table")
|
|
bsw@525
|
10
|
|
bsw@1045
|
11 local for_title = param.get("for_title", "boolean")
|
|
bsw@1045
|
12
|
|
bsw@525
|
13 local unit_id = unit and unit.id or nil
|
|
bsw@525
|
14 local area_id = area and area.id or nil
|
|
bsw@525
|
15 local issue_id = issue and issue.id or nil
|
|
bsw@525
|
16
|
|
bsw@525
|
17 local info
|
|
bsw@525
|
18 local delegation_text
|
|
bsw@525
|
19
|
|
bsw@525
|
20 if unit then
|
|
bsw@525
|
21 info = unit.delegation_info
|
|
bsw@525
|
22 delegation_text = _"Delegate unit"
|
|
bsw@525
|
23 end
|
|
bsw@525
|
24
|
|
bsw@525
|
25 if area then
|
|
bsw@525
|
26 info = area.delegation_info
|
|
bsw@525
|
27 delegation_text = _"Delegate area"
|
|
bsw@525
|
28 end
|
|
bsw@525
|
29
|
|
bsw@525
|
30 if issue then
|
|
bsw@774
|
31 info = issue.member_info
|
|
bsw@525
|
32 delegation_text = _"Delegate issue"
|
|
bsw@525
|
33 end
|
|
bsw@525
|
34
|
|
bsw@1045
|
35 if not info then
|
|
bsw@1045
|
36 --return
|
|
bsw@1045
|
37 end
|
|
bsw@1045
|
38
|
|
bsw@780
|
39 local function print_delegation_info()
|
|
bsw@1045
|
40 local participant_occured = info.own_participation
|
|
bsw@780
|
41
|
|
bsw@780
|
42 if not (issue and issue.state == "voting" and info.own_participation) then
|
|
bsw@780
|
43
|
|
bsw@780
|
44 if info.first_trustee_id then
|
|
bsw@780
|
45
|
|
bsw@780
|
46 local text = _"delegates to"
|
|
bsw@780
|
47 ui.image{
|
|
bsw@780
|
48 attr = { class = "delegation_arrow", alt = text, title = text },
|
|
bsw@780
|
49 static = "delegation_arrow_24_horizontal.png"
|
|
bsw@780
|
50 }
|
|
bsw@780
|
51
|
|
bsw@780
|
52 local class = "micro_avatar"
|
|
bsw@780
|
53 if not participant_occured and info.first_trustee_participation then
|
|
bsw@780
|
54 participant_occured = true
|
|
bsw@780
|
55 class = class .. " highlighted"
|
|
bsw@780
|
56 end
|
|
bsw@525
|
57
|
|
bsw@780
|
58 execute.view{ module = "member_image", view = "_show", params = {
|
|
bsw@780
|
59 member_id = info.first_trustee_id, class = class, popup_text = info.first_trustee_name,
|
|
bsw@780
|
60 image_type = "avatar", show_dummy = true,
|
|
bsw@780
|
61 } }
|
|
bsw@780
|
62
|
|
bsw@780
|
63 end
|
|
bsw@780
|
64
|
|
bsw@780
|
65 if info.first_trustee_ellipsis then
|
|
bsw@780
|
66
|
|
bsw@780
|
67 local text = _"delegates to"
|
|
bsw@780
|
68 ui.image{
|
|
bsw@780
|
69 attr = { class = "delegation_arrow", alt = text, title = text },
|
|
bsw@780
|
70 static = "delegation_arrow_24_horizontal.png"
|
|
bsw@780
|
71 }
|
|
bsw@525
|
72
|
|
bsw@780
|
73 slot.put("...")
|
|
bsw@780
|
74
|
|
bsw@780
|
75 end
|
|
bsw@780
|
76
|
|
bsw@780
|
77 if info.other_trustee_id then
|
|
bsw@780
|
78
|
|
bsw@780
|
79 local text = _"delegates to"
|
|
bsw@780
|
80 ui.image{
|
|
bsw@780
|
81 attr = { class = "delegation_arrow", alt = text, title = text },
|
|
bsw@780
|
82 static = "delegation_arrow_24_horizontal.png"
|
|
bsw@780
|
83 }
|
|
bsw@525
|
84
|
|
bsw@780
|
85 local class = "micro_avatar"
|
|
bsw@780
|
86 if not participant_occured and info.other_trustee_participation then
|
|
bsw@780
|
87 participant_occured = true
|
|
bsw@780
|
88 class = class .. " highlighted"
|
|
bsw@780
|
89 end
|
|
bsw@780
|
90
|
|
bsw@780
|
91 execute.view{ module = "member_image", view = "_show", params = {
|
|
bsw@780
|
92 member_id = info.other_trustee_id, class = class, popup_text = info.other_trustee_name,
|
|
bsw@780
|
93 image_type = "avatar", show_dummy = true,
|
|
bsw@780
|
94 } }
|
|
bsw@780
|
95
|
|
bsw@780
|
96 end
|
|
bsw@780
|
97
|
|
bsw@780
|
98 if info.other_trustee_ellipsis then
|
|
bsw@525
|
99
|
|
bsw@780
|
100 local text = _"delegates to"
|
|
bsw@780
|
101 ui.image{
|
|
bsw@780
|
102 attr = { class = "delegation_arrow", alt = text, title = text },
|
|
bsw@780
|
103 static = "delegation_arrow_24_horizontal.png"
|
|
bsw@780
|
104 }
|
|
bsw@529
|
105
|
|
bsw@780
|
106 slot.put("...")
|
|
bsw@780
|
107
|
|
bsw@780
|
108 end
|
|
bsw@780
|
109
|
|
bsw@780
|
110 local trailing_ellipsis = info.other_trustee_ellipsis or
|
|
bsw@780
|
111 (info.first_trustee_ellipsis and not info.other_trustee_id)
|
|
bsw@780
|
112
|
|
bsw@780
|
113 if info.delegation_loop == "own" then
|
|
bsw@780
|
114
|
|
bsw@780
|
115 local text = _"delegates to"
|
|
bsw@780
|
116 ui.image{
|
|
bsw@780
|
117 attr = { class = "delegation_arrow", alt = text, title = text },
|
|
bsw@780
|
118 static = "delegation_arrow_24_horizontal.png"
|
|
bsw@780
|
119 }
|
|
bsw@780
|
120
|
|
bsw@780
|
121 execute.view{ module = "member_image", view = "_show", params = {
|
|
bsw@780
|
122 member = member, class = "micro_avatar", popup_text = member.name,
|
|
bsw@780
|
123 image_type = "avatar", show_dummy = true,
|
|
bsw@780
|
124 } }
|
|
bsw@780
|
125
|
|
bsw@780
|
126 elseif info.delegation_loop == "first" then
|
|
bsw@780
|
127 if info.first_trustee_ellipsis then
|
|
bsw@780
|
128 if not trailing_ellipsis then
|
|
bsw@529
|
129
|
|
bsw@529
|
130 local text = _"delegates to"
|
|
bsw@529
|
131 ui.image{
|
|
bsw@529
|
132 attr = { class = "delegation_arrow", alt = text, title = text },
|
|
bsw@529
|
133 static = "delegation_arrow_24_horizontal.png"
|
|
bsw@529
|
134 }
|
|
bsw@529
|
135
|
|
bsw@529
|
136 slot.put("...")
|
|
bsw@780
|
137 end
|
|
bsw@529
|
138
|
|
bsw@780
|
139 else
|
|
bsw@529
|
140
|
|
bsw@780
|
141 local text = _"delegates to"
|
|
bsw@780
|
142 ui.image{
|
|
bsw@780
|
143 attr = { class = "delegation_arrow", alt = text, title = text },
|
|
bsw@780
|
144 static = "delegation_arrow_24_horizontal.png"
|
|
bsw@780
|
145 }
|
|
bsw@525
|
146
|
|
bsw@1045
|
147 execute.view{
|
|
bsw@1045
|
148 module = "member_image", view = "_show", params = {
|
|
bsw@1045
|
149 member_id = info.first_trustee_id,
|
|
bsw@1045
|
150 class = "micro_avatar",
|
|
bsw@1045
|
151 popup_text = info.first_trustee_name,
|
|
bsw@1045
|
152 image_type = "avatar",
|
|
bsw@1045
|
153 show_dummy = true,
|
|
bsw@1045
|
154 }
|
|
bsw@1045
|
155 }
|
|
bsw@780
|
156 end
|
|
bsw@780
|
157
|
|
bsw@529
|
158
|
|
bsw@780
|
159 elseif info.delegation_loop and not trailing_ellipsis then
|
|
bsw@780
|
160 local text = _"delegates to"
|
|
bsw@780
|
161 ui.image{
|
|
bsw@780
|
162 attr = { class = "delegation_arrow", alt = text, title = text },
|
|
bsw@780
|
163 static = "delegation_arrow_24_horizontal.png"
|
|
bsw@780
|
164 }
|
|
bsw@525
|
165
|
|
bsw@780
|
166 slot.put("...")
|
|
bsw@780
|
167 end
|
|
bsw@529
|
168
|
|
bsw@780
|
169 end
|
|
bsw@780
|
170 end
|
|
bsw@529
|
171
|
|
bsw@1603
|
172 if not param.get("no_star", "boolean") and issue then
|
|
bsw@1603
|
173 local redirect_unit = request.get_param{ name = "unit" }
|
|
bsw@1603
|
174 local redirect_area = request.get_param{ name = "area" }
|
|
bsw@1603
|
175
|
|
bsw@1603
|
176 if issue.fully_frozen and info.own_participation then
|
|
bsw@1603
|
177 ui.link{
|
|
bsw@1603
|
178 attr = { class = "mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--underlined" },
|
|
bsw@1603
|
179 module = "vote", view = "list", params = {
|
|
bsw@1603
|
180 issue_id = issue.id
|
|
bsw@1603
|
181 },
|
|
bsw@1603
|
182 content = function ()
|
|
bsw@1603
|
183 ui.tag { content = _"you voted" }
|
|
bsw@1603
|
184 end
|
|
bsw@1603
|
185 }
|
|
bsw@1603
|
186 elseif not issue.half_frozen and not info.own_participation then
|
|
bsw@1603
|
187 ui.link{
|
|
bsw@1618
|
188 attr = {
|
|
bsw@1618
|
189 class = "float-right mdl-button mdl-js-button mdl-button--icon mdl-button--accent",
|
|
bsw@1618
|
190 },
|
|
bsw@1618
|
191 form_attr = {
|
|
bsw@1618
|
192 onsubmit = "toggleInterest(" .. issue.id .. ", 'issue_" .. issue.id .. "_interest_icon'); return false;"
|
|
bsw@1618
|
193 },
|
|
bsw@1618
|
194 module = "interest", action = "update", params = { issue_id = issue.id, interested = true },
|
|
bsw@1603
|
195 routing = { default = {
|
|
bsw@1603
|
196 mode = "redirect", module = "index", view = "index", params = {
|
|
bsw@1603
|
197 unit = redirect_unit, area = redirect_area
|
|
bsw@1045
|
198 },
|
|
bsw@1603
|
199 anchor = "issue_" .. issue.id
|
|
bsw@1603
|
200 } },
|
|
bsw@1603
|
201 content = function()
|
|
bsw@1618
|
202 ui.tag{ tag = "i", attr = { id = "issue_" .. issue.id .. "_interest_icon", class = "material-icons" }, content = "star_outline" }
|
|
bsw@1603
|
203 end
|
|
bsw@1603
|
204 }
|
|
bsw@1603
|
205 elseif not issue.half_frozen and info.own_participation then
|
|
bsw@1603
|
206 ui.link{
|
|
bsw@1618
|
207 attr = {
|
|
bsw@1618
|
208 class = "float-right mdl-button mdl-js-button mdl-button--icon mdl-button--accent"
|
|
bsw@1618
|
209 },
|
|
bsw@1618
|
210 form_attr = {
|
|
bsw@1618
|
211 onsubmit = "toggleInterest(" .. issue.id .. ", 'issue_" .. issue.id .. "_interest_icon'); return false;"
|
|
bsw@1618
|
212 },
|
|
bsw@1618
|
213 module = "interest", action = "update", params = { issue_id = issue.id, interested = false },
|
|
bsw@1603
|
214 routing = { default = {
|
|
bsw@1603
|
215 mode = "redirect", module = "index", view = "index", params = {
|
|
bsw@1603
|
216 unit = redirect_unit, area = redirect_area
|
|
bsw@1603
|
217 },
|
|
bsw@1603
|
218 anchor = "issue_" .. issue.id
|
|
bsw@1603
|
219 } },
|
|
bsw@1603
|
220 content = function()
|
|
bsw@1618
|
221 ui.tag{ tag = "i", attr = { id = "issue_" .. issue.id .. "_interest_icon", class = "material-icons" }, content = "star" }
|
|
bsw@1045
|
222 end
|
|
bsw@1603
|
223 }
|
|
bsw@1603
|
224 if not issue.closed and info.own_participation and info.weight and info.weight > 1 then
|
|
bsw/jbe@1309
|
225 slot.put(" ")
|
|
bsw@1603
|
226 ui.link {
|
|
bsw@1603
|
227 attr = { class = "right" }, content = "+" .. (info.weight - 1),
|
|
bsw@1603
|
228 module = "interest", view = "show_incoming", params = {
|
|
bsw@1603
|
229 issue_id = issue.id, member_id = member.id
|
|
bsw@1603
|
230 }
|
|
bsw@1603
|
231 }
|
|
bsw@1045
|
232 end
|
|
bsw@1603
|
233 slot.put(" ")
|
|
bsw@1045
|
234 end
|
|
bsw@1045
|
235 end
|
|
bsw@1045
|
236
|
|
bsw@529
|
237
|
|
bsw@780
|
238 if info.own_participation or info.first_trustee_id then
|
|
bsw@1045
|
239 local class = "delegation_info"
|
|
bsw@1045
|
240 if info.own_participation then
|
|
bsw@1045
|
241 class = class .. " suspended"
|
|
bsw@1045
|
242 end
|
|
bsw@1045
|
243
|
|
bsw@1045
|
244 local voting_member_id
|
|
bsw@1045
|
245 local voting_member_name
|
|
bsw@1045
|
246 if issue and issue.fully_frozen and issue.closed then
|
|
bsw@1045
|
247 if issue.member_info.first_trustee_participation then
|
|
bsw@1045
|
248 voting_member_id = issue.member_info.first_trustee_id
|
|
bsw@1045
|
249 voting_member_name = issue.member_info.first_trustee_name
|
|
bsw@1045
|
250 elseif issue.member_info.other_trustee_participation then
|
|
bsw@1045
|
251 voting_member_id = issue.member_info.other_trustee_id
|
|
bsw@1045
|
252 voting_member_name = issue.member_info.other_trustee_name
|
|
bsw@1045
|
253 end
|
|
bsw@1045
|
254 end
|
|
bsw@1045
|
255
|
|
bsw@780
|
256 if app.session.member_id == member.id then
|
|
bsw@1045
|
257
|
|
bsw@1045
|
258 if voting_member_id then
|
|
bsw@1045
|
259 ui.link{
|
|
bsw@1045
|
260 module = "vote", view = "list", params = {
|
|
bsw@1045
|
261 issue_id = issue.id,
|
|
bsw@1045
|
262 member_id = voting_member_id
|
|
bsw@1045
|
263 },
|
|
bsw@1045
|
264 attr = { class = class }, content = function()
|
|
bsw@1045
|
265 print_delegation_info()
|
|
bsw@1045
|
266 end
|
|
bsw@1045
|
267 }
|
|
bsw@1045
|
268
|
|
bsw@1045
|
269 else
|
|
bsw@1045
|
270 ui.link{
|
|
bsw@1045
|
271 module = "delegation", view = "show", params = {
|
|
bsw@1045
|
272 unit_id = unit_id,
|
|
bsw@1045
|
273 area_id = area_id,
|
|
bsw@1045
|
274 issue_id = issue_id
|
|
bsw@1045
|
275 },
|
|
bsw@1045
|
276 attr = { class = class }, content = function()
|
|
bsw@1045
|
277 print_delegation_info()
|
|
bsw@1045
|
278 end
|
|
bsw@1045
|
279 }
|
|
bsw@1045
|
280 end
|
|
bsw@780
|
281 else
|
|
bsw@780
|
282 ui.container{
|
|
bsw@1045
|
283 attr = { class = class }, content = function()
|
|
bsw@780
|
284 print_delegation_info()
|
|
bsw@780
|
285 end
|
|
bsw@780
|
286 }
|
|
bsw@780
|
287 end
|
|
bsw@551
|
288 end
|
|
bsw@1045
|
289
|
|
bsw/jbe@1309
|
290 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
|
291 ui.link{
|
|
bsw/jbe@1309
|
292 attr = { class = "mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--underlined" },
|
|
bsw/jbe@1309
|
293 module = "vote", view = "list", params = {
|
|
bsw/jbe@1309
|
294 issue_id = issue.id
|
|
bsw/jbe@1309
|
295 },
|
|
bsw/jbe@1309
|
296 content = function ()
|
|
bsw/jbe@1309
|
297 ui.tag { content = _"vote now" }
|
|
bsw/jbe@1309
|
298 end
|
|
bsw/jbe@1309
|
299 }
|
|
bsw/jbe@1309
|
300 else
|
|
bsw/jbe@1309
|
301 end
|