liquid_feedback_frontend

view app/main/issue/_sidebar_whatcanido.lua @ 1598:6b203b43bef3

Reworked unit and area head and delegation buttons
author bsw
date Sun Jan 31 22:04:30 2021 +0100 (2021-01-31)
parents a59dd2ae9cd8
children dcbe505ddf24
line source
1 local issue = param.get("issue", "table")
2 local initiative = param.get("initiative", "table")
3 local member = param.get("member", "table") or app.session.member
5 if initiative then
6 issue = initiative.issue
7 end
9 local privileged_to_vote = app.session.member and app.session.member:has_voting_right_for_unit_id(issue.area.unit_id)
11 local active_trustee_id
12 if member then
13 if not issue.member_info.own_participation then
14 if issue.member_info.first_trustee_participation then
15 active_trustee_id = issue.member_info.first_trustee_id
16 elseif issue.member_info.other_trustee_participation then
17 active_trustee_id = issue.member_info.other_trustee_id
18 end
19 end
20 end
22 local supporter
24 if initiative and app.session.member_id then
25 supporter = app.session.member:get_reference_selector("supporters")
26 :add_where{ "initiative_id = ?", initiative.id }
27 :optional_object_mode()
28 :exec()
29 end
31 local view_module
32 local view_id
34 if initiative then
35 issue = issue
36 view_module = "initiative"
37 view_id = initiative.id
38 else
39 view_module = "issue"
40 view_id = issue.id
41 end
43 local initiator
44 if initiative and app.session.member_id then
45 initiator = Initiator:by_pk(initiative.id, app.session.member.id)
46 end
48 local initiators
50 if initiative then
51 local initiators_members_selector = initiative:get_reference_selector("initiating_members")
52 :add_field("initiator.accepted", "accepted")
53 :add_order_by("member.name")
54 if initiator and initiator.accepted then
55 initiators_members_selector:add_where("initiator.accepted ISNULL OR initiator.accepted")
56 else
57 initiators_members_selector:add_where("initiator.accepted")
58 end
60 initiators = initiators_members_selector:exec()
61 end
63 ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function()
64 ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
65 ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = _"What can I do here?" }
66 end }
67 ui.container{ attr = { class = "what-can-i-do-here" }, content = function()
69 if initiator and
70 initiator.accepted and
71 not issue.fully_frozen and
72 not issue.closed and
73 not initiative.revoked
74 then
76 ui.container { attr = { class = "mdl-card__content mdl-card--border" }, content = function ()
77 ui.tag { content = _"You are initiator of this initiative" }
78 ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
79 if issue.half_frozen then
80 ui.tag { tag = "li", content = _"this issue is in verification phase, therefore the initiative text cannot be updated anymore" }
81 else
82 ui.tag { tag = "li", content = function ()
83 ui.link{
84 module = "draft", view = "new",
85 params = { initiative_id = initiative.id },
86 content = _"edit proposal and/or reasons"
87 }
88 end }
89 ui.tag { tag = "li", content = function ()
90 ui.link{
91 attr = { class = "action" },
92 module = "initiative", view = "add_initiator",
93 params = { initiative_id = initiative.id },
94 content = _"invite another initiator"
95 }
96 end }
97 if #initiative.initiators > 1 then
98 ui.tag { tag = "li", content = function ()
99 ui.link{
100 module = "initiative", view = "remove_initiator",
101 params = { initiative_id = initiative.id },
102 content = _"remove an initiator"
103 }
104 end }
105 end
106 ui.tag { tag = "li", content = function ()
107 ui.link{
108 module = "initiative", view = "revoke", id = initiative.id,
109 content = _"revoke initiative"
110 }
111 end }
112 end
113 end }
114 end }
115 end
117 -- invited as initiator
118 if initiator and initiator.accepted == nil and not initiative.issue.half_frozen and not initiative.issue.closed then
119 ui.container { attr = { class = "mdl-card__content mdl-card--border" }, content = function ()
120 ui.tag { content = _"You are invited to become initiator of this initiative" }
121 ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
122 ui.tag{ tag = "li", content = function ()
123 ui.link{
124 content = _"accept invitation",
125 module = "initiative",
126 action = "accept_invitation",
127 id = initiative.id,
128 routing = {
129 default = {
130 mode = "redirect",
131 module = request.get_module(),
132 view = request.get_view(),
133 id = request.get_id_string(),
134 params = request.get_param_strings()
135 }
136 }
137 }
138 end }
140 ui.tag{ tag = "li", content = function ()
141 ui.link{
142 content = _"refuse invitation",
143 module = "initiative",
144 action = "reject_initiator_invitation",
145 params = {
146 initiative_id = initiative.id,
147 member_id = app.session.member.id
148 },
149 routing = {
150 default = {
151 mode = "redirect",
152 module = request.get_module(),
153 view = request.get_view(),
154 id = request.get_id_string(),
155 params = request.get_param_strings()
156 }
157 }
158 }
159 end }
160 end }
161 end }
162 end
165 if privileged_to_vote and issue.member_info.first_trustee_id then
166 local member = Member:by_id(issue.member_info.first_trustee_id)
167 ui.container { attr = { class = "mdl-card__content mdl-card--border" }, content = function ()
168 --[[
169 ui.container { attr = { class = "right" }, content = function()
170 execute.view{
171 module = "member_image",
172 view = "_show",
173 params = {
174 member = member,
175 image_type = "avatar",
176 show_dummy = true
177 }
178 }
179 end }
180 --]]
181 if issue.member_info.own_delegation_scope == "unit" then
182 ui.tag{ content = _"You delegated this organizational unit" }
183 elseif issue.member_info.own_delegation_scope == "area" then
184 ui.tag{ content = _"You delegated this subject area" }
185 elseif issue.member_info.own_delegation_scope == "issue" then
186 ui.tag{ content = _"You delegated this issue" }
187 end
189 ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
190 if issue.member_info.own_delegation_scope == "area" or
191 issue.member_info.own_delegation_scope == "unit" then
192 ui.tag { tag = "li", content = function ()
193 ui.link {
194 module = "delegation", view = "show", params = {
195 issue_id = issue.id,
196 initiative_id = initiative and initiative.id or nil
197 },
198 content = _"change/revoke delegation only for this issue"
199 }
200 end }
201 end
202 if issue.member_info.own_delegation_scope == "unit" then
203 ui.tag { tag = "li", content = function ()
204 ui.link {
205 module = "delegation", view = "show", params = {
206 unit_id = issue.area.unit_id,
207 },
208 content = _("change/revoke delegation of organizational unit", {
209 unit_name = issue.area.unit.name
210 })
211 }
212 end }
213 elseif issue.member_info.own_delegation_scope == "area" then
214 ui.tag { tag = "li", content = function ()
215 ui.link {
216 module = "delegation", view = "show", params = {
217 area_id = issue.area_id,
218 },
219 content = _"change/revoke delegation of subject area"
220 }
221 end }
222 end
223 if issue.member_info.own_delegation_scope == nil then
224 ui.tag { tag = "li", content = function ()
225 ui.link {
226 module = "delegation", view = "show", params = {
227 issue_id = issue.id,
228 initiative_id = initiative and initiative.id or nil
229 },
230 content = _"choose issue delegatee"
231 }
232 end }
233 elseif issue.member_info.own_delegation_scope == "issue" then
234 ui.tag { tag = "li", content = function ()
235 ui.link {
236 module = "delegation", view = "show", params = {
237 issue_id = issue.id,
238 initiative_id = initiative and initiative.id or nil
239 },
240 content = _"change/revoke issue delegation"
241 }
242 end }
243 end
244 if issue.member_info.first_trustee_id and issue.member_info.own_participation then
245 local text = _"As long as you are interested in this issue yourself, the delegation is suspended for this issue, but it will be applied again in the voting phase unless you vote yourself."
246 if issue.state == "voting" then
247 text = _"This delegation is suspended, because you voted yourself."
248 end
249 ui.tag { tag = "li", content = function ()
250 ui.container { content = text }
251 end }
252 end
254 end }
256 end }
257 end
259 if privileged_to_vote and not issue.closed and not issue.fully_frozen then
260 if issue.member_info.own_participation then
261 ui.container { attr = { class = "mdl-card__content mdl-card--border" }, content = function ()
262 --[[
263 ui.container{ attr = { class = "right" }, content = function()
264 ui.image{ attr = { class = "right" }, static = "icons/48/eye.png" }
265 if issue.member_info.weight and issue.member_info.weight > 1 then
266 slot.put("<br />")
267 ui.tag{
268 attr = { class = "right" },
269 content = "+" .. issue.member_info.weight - 1
270 }
271 end
272 end }
273 --]]
274 ui.tag{ content = _("You are interested in this issue", { id = issue.id }) }
275 ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
276 if issue.member_info.weight and issue.member_info.weight > 1 then
277 ui.tag { tag = "li", content = function ()
278 ui.link {
279 module = "delegation", view = "show_incoming",
280 params = { issue_id = issue.id, member_id = app.session.member_id },
281 content = _("you have #{count} incoming delegations", {
282 count = issue.member_info.weight - 1
283 })
284 }
285 end }
286 end
287 ui.tag { tag = "li", content = function ()
288 ui.link {
289 module = "interest", action = "update",
290 routing = { default = {
291 mode = "redirect", module = view_module, view = "show", id = view_id
292 } },
293 params = { issue_id = issue.id, delete = true },
294 text = _"remove my interest"
295 }
296 end }
297 end }
298 end }
299 else
300 ui.container { attr = { class = "mdl-card__content mdl-card--border" }, content = function ()
301 ui.tag{ content = _("I want to participate in this issue", { id = issue.id }) }
302 ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
303 ui.tag { tag = "li", content = function ()
304 ui.link {
305 module = "interest", action = "update",
306 params = { issue_id = issue.id },
307 routing = { default = {
308 mode = "redirect", module = view_module, view = "show", id = view_id
309 } },
310 text = _"add my interest"
311 }
312 end }
313 ui.tag { tag = "li", content = _"browse through the competing initiatives" }
314 end }
315 end }
316 end
318 if initiative then
320 if not initiative.member_info.supported or active_trustee_id then
321 ui.container { attr = { class = "mdl-card__content mdl-card--border" }, content = function ()
322 ui.tag { content = _"I like this initiative and I want to support it" }
323 ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
324 ui.tag { tag = "li", content = function ()
325 ui.link {
326 module = "initiative", action = "add_support",
327 routing = { default = {
328 mode = "redirect", module = "initiative", view = "show", id = initiative.id
329 } },
330 id = initiative.id,
331 text = _"add my support"
332 }
333 end }
334 end }
335 end }
337 else -- if not supported
338 ui.container { attr = { class = "mdl-card__content mdl-card--border" }, content = function ()
339 --[[
340 if initiative.member_info.satisfied then
341 ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "thumb_up" }
342 else
343 ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "thumb_up" }
344 ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "warning" }
345 end
346 --]]
347 ui.tag{ content = _"You are supporting this initiative" }
348 ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
349 if not initiative.member_info.satisfied then
350 ui.tag { tag = "li", content = function ()
351 ui.tag { content = function ()
352 ui.link {
353 external = "#suggestions",
354 content = _"you restricted your support by rating suggestions as must or must not"
355 }
356 end }
357 end }
358 end
359 ui.tag { tag = "li", content = function ()
360 ui.tag { content = function ()
361 ui.link {
362 xattr = { class = "btn btn-remove" },
363 module = "initiative", action = "remove_support",
364 routing = { default = {
365 mode = "redirect", module = "initiative", view = "show", id = initiative.id
366 } },
367 id = initiative.id,
368 text = _"remove my support"
369 }
370 end }
371 end }
372 end }
373 end }
375 end -- not supported
377 ui.container { attr = { class = "mdl-card__content mdl-card--border" }, content = function ()
378 ui.tag{ content = _"I want to improve this initiative" }
379 ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
380 if issue.state == "verification" then
381 ui.tag { tag = "li", content = _"this issue is in verification phase, therefore the initiative text cannot be updated anymore" }
382 elseif issue.state == "voting" then
383 ui.tag { tag = "li", content = _"this issue is in voting phase, therefore the initiative text cannot be updated anymore" }
384 else
386 if initiative.member_info.initiated then
387 ui.tag { tag = "li", content =_"take a look at the suggestions of your supporters" }
388 ui.tag { tag = "li", content =_"if you like to implement a suggestion in your proposal and/or reasons, update your initiative draft" }
389 ui.tag { tag = "li", content =_"to argue about suggestions, just add your arguments to your reasons in the initiative draft, so your supporters can learn about your opinion" }
390 end
392 if not initiative.member_info.supported or active_trustee_id then
393 ui.tag { tag = "li", content =_"add your support (see above) and rate or write new suggestions (and thereby restrict your support to certain conditions if necessary)" }
394 else
395 ui.tag { tag = "li", content = _"take a look at the suggestions (see right) and rate them" }
396 ui.tag { tag = "li", content = function ()
397 ui.link {
398 module = "suggestion", view = "new", params = {
399 initiative_id = initiative.id
400 },
401 content = _"write a new suggestion"
402 }
403 end }
404 end
405 end
406 end }
407 end }
409 end
411 if
412 (issue.state == "admission" or
413 issue.state == "discussion" or
414 issue.state == "verification")
415 then
416 ui.container { attr = { class = "mdl-card__content mdl-card--border" }, content = function ()
417 if initiative then
418 ui.tag{ content = _"I don't like this initiative and I want to add my opinion or counter proposal" }
419 else
420 ui.tag{ content = _"I don't like any of the initiative in this issue and I want to add my opinion or counter proposal" }
421 end
422 ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
423 ui.tag { tag = "li", content = function ()
424 ui.link {
425 module = "issue", view = "show", id = issue.id,
426 content = _"take a look at the competing initiatives"
427 }
428 end }
429 ui.tag { tag = "li", content = function ()
430 ui.link {
431 module = "draft", view = "new",
432 params = { issue_id = issue.id },
433 content = _"start a new competing initiative"
434 }
435 end }
436 end }
437 end }
438 end
440 end
442 if not config.disable_delegations and privileged_to_vote and not issue.closed then
444 if not issue.member_info.first_trustee_id then
445 ui.container { attr = { class = "mdl-card__content mdl-card--border" }, content = function ()
446 ui.tag{ content = _"I want to delegate this issue" }
448 ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
449 ui.tag { tag = "li", content = function ()
450 ui.link {
451 module = "delegation", view = "show", params = {
452 issue_id = issue.id,
453 initiative_id = initiative and initiative.id or nil
454 },
455 content = _"choose issue delegatee"
456 }
457 end }
458 end }
459 end }
460 end
462 end
464 if initiator and initiator.accepted == false then
465 ui.container { attr = { class = "mdl-card__content mdl-card--border" }, content = function ()
466 ui.tag { content = _"You refused to become initiator of this initiative" }
467 ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
468 ui.tag{ tag = "li", content = function ()
469 ui.link{
470 text = _"allow invitation again",
471 module = "initiative",
472 action = "remove_initiator",
473 params = {
474 initiative_id = initiative.id,
475 member_id = app.session.member.id
476 },
477 routing = {
478 ok = {
479 mode = "redirect",
480 module = "initiative",
481 view = "show",
482 id = initiative.id
483 }
484 }
485 }
486 end }
487 end }
488 end }
489 end
493 if privileged_to_vote then
495 if initiative and
496 (issue.state == "admission" or
497 issue.state == "discussion" or
498 issue.state == "verification")
499 then
501 elseif issue.state == "verification" then
503 elseif issue.state == "voting" then
504 if not issue.member_info.direct_voted then
505 if not issue.member_info.non_voter then
506 ui.container { attr = { class = "mdl-card__content mdl-card--border" }, content = function ()
507 ui.tag{ content = _"I like to vote on this issue:" }
508 ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
509 ui.tag { tag = "li", content = function ()
510 ui.tag { content = function ()
511 if not issue.closed then
512 ui.link {
513 xattr = { class = "btn btn-vote" },
514 module = "vote", view = "list",
515 params = { issue_id = issue.id },
516 text = _"vote now"
517 }
518 end
519 end }
520 end }
521 end }
522 end }
523 end
524 ui.container { attr = { class = "mdl-card__content mdl-card--border" }, content = function ()
525 if not issue.member_info.non_voter then
526 ui.tag{ content = _"I don't like to vote this issue (myself):" }
527 ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
528 ui.tag { tag = "li", content = function ()
529 ui.link{
530 content = _"do not notify me about this voting anymore",
531 module = "vote",
532 action = "non_voter",
533 params = { issue_id = issue.id },
534 routing = {
535 default = {
536 mode = "redirect",
537 module = request.get_module(),
538 view = request.get_view(),
539 id = request.get_id_string(),
540 params = request.get_param_strings()
541 }
542 }
543 }
544 end }
545 end }
546 else
547 ui.tag{ content = _"You do not like to vote this issue (yourself)" }
548 ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
549 ui.tag { tag = "li", content = function ()
550 ui.link{
551 in_brackets = true,
552 content = _"discard",
553 module = "vote",
554 action = "non_voter",
555 params = { issue_id = issue.id, delete = true },
556 routing = {
557 default = {
558 mode = "redirect",
559 module = request.get_module(),
560 view = request.get_view(),
561 id = request.get_id_string(),
562 params = request.get_param_strings()
563 }
564 }
565 }
566 end }
567 end }
568 end
569 end }
570 else
571 ui.container { attr = { class = "mdl-card__content mdl-card--border" }, content = function ()
572 ui.tag{ content = _"I like to change/revoke my vote:" }
573 ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
574 ui.tag { tag = "li", content = function ()
575 ui.tag { content = function ()
576 if not issue.closed then
577 ui.link {
578 xattr = { class = "btn btn-vote" },
579 module = "vote", view = "list",
580 params = { issue_id = issue.id },
581 text = _"change my vote"
582 }
583 end
584 end }
585 end }
586 ui.tag { tag = "li", content = function ()
587 ui.tag { content = function ()
588 if not issue.closed then
589 ui.link {
590 module = "vote", action = "update",
591 params = {
592 issue_id = issue.id,
593 discard = true
594 },
595 routing = {
596 default = {
597 mode = "redirect",
598 module = "issue",
599 view = "show",
600 id = issue.id
601 }
602 },
603 text = _"discard my vote"
604 }
605 end
606 end }
607 end }
608 end }
610 end }
612 end
613 end
614 end
616 if not app.session.member or not privileged_to_vote then
617 ui.container { attr = { class = "mdl-card__content mdl-card--border" }, content = function ()
618 ui.tag{ content = _"You are not entitled to vote in this unit" }
619 ui.tag{ tag = "ul", content = function()
620 ui.tag{ tag = "li", content = function()
621 ui.link{ module = "index", view = "login", content = _"Login" }
622 end }
623 end }
624 end }
625 end
627 if issue.closed then
628 ui.container { attr = { class = "mdl-card__content mdl-card--border" }, content = function ()
629 ui.tag { content = _"This issue is closed" }
630 end }
631 end
633 if initiative and config.tell_others and config.tell_others.initiative then
634 ui.container { attr = { class = "mdl-card__content mdl-card--border" }, content = function ()
636 ui.heading { level = 3, content = _"Tell others about this initiative:" }
637 ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
639 for i, link in ipairs (config.tell_others.initiative(initiative)) do
640 ui.tag { tag = "li", content = function ()
641 ui.link ( link )
642 end }
643 end
645 end }
646 end }
647 end
648 end }
650 end }

Impressum / About Us