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@1659
|
186 elseif not issue.half_frozen and not issue.closed and not info.own_participation then
|
bsw@1603
|
187 ui.link{
|
bsw@1618
|
188 attr = {
|
bsw@1619
|
189 id = "issue_" .. issue.id .. "_interest_link",
|
bsw@1619
|
190 class = "float-right mdl-button mdl-js-button mdl-button--icon mdl-button--feature-off",
|
bsw@1618
|
191 },
|
bsw@1618
|
192 form_attr = {
|
bsw@1618
|
193 onsubmit = "toggleInterest(" .. issue.id .. ", 'issue_" .. issue.id .. "_interest_icon'); return false;"
|
bsw@1618
|
194 },
|
bsw@1618
|
195 module = "interest", action = "update", params = { issue_id = issue.id, interested = true },
|
bsw@1603
|
196 routing = { default = {
|
bsw@1603
|
197 mode = "redirect", module = "index", view = "index", params = {
|
bsw@1603
|
198 unit = redirect_unit, area = redirect_area
|
bsw@1045
|
199 },
|
bsw@1603
|
200 anchor = "issue_" .. issue.id
|
bsw@1603
|
201 } },
|
bsw@1603
|
202 content = function()
|
bsw@1618
|
203 ui.tag{ tag = "i", attr = { id = "issue_" .. issue.id .. "_interest_icon", class = "material-icons" }, content = "star_outline" }
|
bsw@1603
|
204 end
|
bsw@1603
|
205 }
|
bsw@1659
|
206 elseif not issue.half_frozen and not issue.closed and info.own_participation then
|
bsw@1603
|
207 ui.link{
|
bsw@1618
|
208 attr = {
|
bsw@1619
|
209 id = "issue_" .. issue.id .. "_interest_link",
|
bsw@1618
|
210 class = "float-right mdl-button mdl-js-button mdl-button--icon mdl-button--accent"
|
bsw@1618
|
211 },
|
bsw@1618
|
212 form_attr = {
|
bsw@1618
|
213 onsubmit = "toggleInterest(" .. issue.id .. ", 'issue_" .. issue.id .. "_interest_icon'); return false;"
|
bsw@1618
|
214 },
|
bsw@1618
|
215 module = "interest", action = "update", params = { issue_id = issue.id, interested = false },
|
bsw@1603
|
216 routing = { default = {
|
bsw@1603
|
217 mode = "redirect", module = "index", view = "index", params = {
|
bsw@1603
|
218 unit = redirect_unit, area = redirect_area
|
bsw@1603
|
219 },
|
bsw@1603
|
220 anchor = "issue_" .. issue.id
|
bsw@1603
|
221 } },
|
bsw@1603
|
222 content = function()
|
bsw@1618
|
223 ui.tag{ tag = "i", attr = { id = "issue_" .. issue.id .. "_interest_icon", class = "material-icons" }, content = "star" }
|
bsw@1045
|
224 end
|
bsw@1603
|
225 }
|
bsw@1853
|
226
|
bsw@1853
|
227 local privilege = Privilege:new_selector()
|
bsw@1853
|
228 :add_where{ "member_id = ?", member.id }
|
bsw@1853
|
229 :add_where{ "unit_id = ?", issue.area.unit_id }
|
bsw@1853
|
230 :optional_object_mode()
|
bsw@1853
|
231 :exec()
|
bsw@1853
|
232
|
bsw@1853
|
233 local own_weight = privilege and privilege.weight or 0
|
bsw@1853
|
234
|
bsw@1853
|
235 if not issue.closed and info.own_participation and info.weight and info.weight > own_weight then
|
bsw@1854
|
236 local weight = info.weight - own_weight
|
bsw@1854
|
237 if config.token and config.token.unit_id == issue.area.unit_id then
|
bsw@1854
|
238 weight = weight / 100 .. " " .. config.token.token_name
|
bsw@1854
|
239 end
|
bsw/jbe@1309
|
240 slot.put(" ")
|
bsw@1603
|
241 ui.link {
|
bsw@1854
|
242 attr = { class = "right" }, content = "+" .. weight,
|
bsw@1603
|
243 module = "interest", view = "show_incoming", params = {
|
bsw@1603
|
244 issue_id = issue.id, member_id = member.id
|
bsw@1603
|
245 }
|
bsw@1603
|
246 }
|
bsw@1045
|
247 end
|
bsw@1603
|
248 slot.put(" ")
|
bsw@1045
|
249 end
|
bsw@1045
|
250 end
|
bsw@1045
|
251
|
bsw@529
|
252
|
bsw@780
|
253 if info.own_participation or info.first_trustee_id then
|
bsw@1045
|
254 local class = "delegation_info"
|
bsw@1045
|
255 if info.own_participation then
|
bsw@1045
|
256 class = class .. " suspended"
|
bsw@1045
|
257 end
|
bsw@1045
|
258
|
bsw@1045
|
259 local voting_member_id
|
bsw@1045
|
260 local voting_member_name
|
bsw@1045
|
261 if issue and issue.fully_frozen and issue.closed then
|
bsw@1045
|
262 if issue.member_info.first_trustee_participation then
|
bsw@1045
|
263 voting_member_id = issue.member_info.first_trustee_id
|
bsw@1045
|
264 voting_member_name = issue.member_info.first_trustee_name
|
bsw@1045
|
265 elseif issue.member_info.other_trustee_participation then
|
bsw@1045
|
266 voting_member_id = issue.member_info.other_trustee_id
|
bsw@1045
|
267 voting_member_name = issue.member_info.other_trustee_name
|
bsw@1045
|
268 end
|
bsw@1045
|
269 end
|
bsw@1045
|
270
|
bsw@780
|
271 if app.session.member_id == member.id then
|
bsw@1045
|
272
|
bsw@1045
|
273 if voting_member_id then
|
bsw@1045
|
274 ui.link{
|
bsw@1045
|
275 module = "vote", view = "list", params = {
|
bsw@1045
|
276 issue_id = issue.id,
|
bsw@1045
|
277 member_id = voting_member_id
|
bsw@1045
|
278 },
|
bsw@1045
|
279 attr = { class = class }, content = function()
|
bsw@1045
|
280 print_delegation_info()
|
bsw@1045
|
281 end
|
bsw@1045
|
282 }
|
bsw@1045
|
283
|
bsw@1045
|
284 else
|
bsw@1045
|
285 ui.link{
|
bsw@1045
|
286 module = "delegation", view = "show", params = {
|
bsw@1045
|
287 unit_id = unit_id,
|
bsw@1045
|
288 area_id = area_id,
|
bsw@1045
|
289 issue_id = issue_id
|
bsw@1045
|
290 },
|
bsw@1045
|
291 attr = { class = class }, content = function()
|
bsw@1045
|
292 print_delegation_info()
|
bsw@1045
|
293 end
|
bsw@1045
|
294 }
|
bsw@1045
|
295 end
|
bsw@780
|
296 else
|
bsw@780
|
297 ui.container{
|
bsw@1045
|
298 attr = { class = class }, content = function()
|
bsw@780
|
299 print_delegation_info()
|
bsw@780
|
300 end
|
bsw@780
|
301 }
|
bsw@780
|
302 end
|
bsw@551
|
303 end
|
bsw@1045
|
304
|
bsw/jbe@1309
|
305 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
|
306 ui.link{
|
bsw/jbe@1309
|
307 attr = { class = "mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--underlined" },
|
bsw/jbe@1309
|
308 module = "vote", view = "list", params = {
|
bsw/jbe@1309
|
309 issue_id = issue.id
|
bsw/jbe@1309
|
310 },
|
bsw/jbe@1309
|
311 content = function ()
|
bsw/jbe@1309
|
312 ui.tag { content = _"vote now" }
|
bsw/jbe@1309
|
313 end
|
bsw/jbe@1309
|
314 }
|
bsw/jbe@1309
|
315 else
|
bsw/jbe@1309
|
316 end
|