liquid_feedback_frontend

view app/main/issue/_sidebar_whatcanido.lua @ 1858:3d1f0464a3ea

Handle missing ldap.member.allowed function
author bsw
date Tue Sep 20 17:35:29 2022 +0200 (20 months ago)
parents b27b327be05e
children
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 ui.tag{ content = _("You are interested in this issue", { id = issue.id }) }
263 ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
264 if issue.member_info.weight and issue.member_info.weight > 1 then
265 ui.tag { tag = "li", content = function ()
266 ui.link {
267 module = "interest", view = "show_incoming",
268 params = { issue_id = issue.id, member_id = app.session.member_id },
269 content = _("you have #{count} incoming delegations", {
270 count = issue.member_info.weight - 1
271 })
272 }
273 end }
274 end
275 ui.tag { tag = "li", content = function ()
276 ui.link {
277 module = "interest", action = "update",
278 routing = { default = {
279 mode = "redirect", module = view_module, view = "show", id = view_id
280 } },
281 params = { issue_id = issue.id, interested = false },
282 text = _"remove my interest"
283 }
284 end }
285 end }
286 end }
287 else
288 ui.container { attr = { class = "mdl-card__content mdl-card--border" }, content = function ()
289 ui.tag{ content = _("I want to participate in this issue", { id = issue.id }) }
290 ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
291 ui.tag { tag = "li", content = function ()
292 ui.link {
293 module = "interest", action = "update",
294 params = { issue_id = issue.id, interested = true },
295 routing = { default = {
296 mode = "redirect", module = view_module, view = "show", id = view_id
297 } },
298 text = _"add my interest"
299 }
300 end }
301 ui.tag { tag = "li", content = _"browse through the competing initiatives" }
302 end }
303 end }
304 end
306 if initiative then
308 if not initiative.member_info.supported or active_trustee_id then
309 ui.container { attr = { class = "mdl-card__content mdl-card--border" }, content = function ()
310 ui.tag { content = _"I like this initiative and I want to support it" }
311 ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
312 ui.tag { tag = "li", content = function ()
313 ui.link {
314 module = "initiative", action = "add_support",
315 routing = { default = {
316 mode = "redirect", module = "initiative", view = "show", id = initiative.id
317 } },
318 id = initiative.id,
319 text = _"add my support"
320 }
321 end }
322 end }
323 end }
325 else -- if not supported
326 ui.container { attr = { class = "mdl-card__content mdl-card--border" }, content = function ()
327 --[[
328 if initiative.member_info.satisfied then
329 ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "thumb_up" }
330 else
331 ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "thumb_up" }
332 ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "warning" }
333 end
334 --]]
335 ui.tag{ content = _"You are supporting this initiative" }
336 ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
337 if not initiative.member_info.satisfied then
338 ui.tag { tag = "li", content = function ()
339 ui.tag { content = function ()
340 ui.link {
341 external = "#suggestions",
342 content = _"you restricted your support by rating suggestions as must or must not"
343 }
344 end }
345 end }
346 end
347 ui.tag { tag = "li", content = function ()
348 ui.tag { content = function ()
349 ui.link {
350 xattr = { class = "btn btn-remove" },
351 module = "initiative", action = "remove_support",
352 routing = { default = {
353 mode = "redirect", module = "initiative", view = "show", id = initiative.id
354 } },
355 id = initiative.id,
356 text = _"remove my support"
357 }
358 end }
359 end }
360 end }
361 end }
363 end -- not supported
365 ui.container { attr = { class = "mdl-card__content mdl-card--border" }, content = function ()
366 ui.tag{ content = _"I want to improve this initiative" }
367 ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
368 if issue.state == "verification" then
369 ui.tag { tag = "li", content = _"this issue is in verification phase, therefore the initiative text cannot be updated anymore" }
370 elseif issue.state == "voting" then
371 ui.tag { tag = "li", content = _"this issue is in voting phase, therefore the initiative text cannot be updated anymore" }
372 else
374 if initiative.member_info.initiated then
375 ui.tag { tag = "li", content =_"take a look at the suggestions of your supporters" }
376 ui.tag { tag = "li", content =_"if you like to implement a suggestion in your proposal and/or reasons, update your initiative draft" }
377 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" }
378 end
380 if not initiative.member_info.supported or active_trustee_id then
381 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)" }
382 else
383 ui.tag { tag = "li", content = _"take a look at the suggestions (see right) and rate them" }
384 ui.tag { tag = "li", content = function ()
385 ui.link {
386 module = "suggestion", view = "new", params = {
387 initiative_id = initiative.id
388 },
389 content = _"write a new suggestion"
390 }
391 end }
392 end
393 end
394 end }
395 end }
397 end
399 if
400 (issue.state == "admission" or
401 issue.state == "discussion" or
402 issue.state == "verification")
403 then
404 ui.container { attr = { class = "mdl-card__content mdl-card--border" }, content = function ()
405 if initiative then
406 ui.tag{ content = _"I don't like this initiative and I want to add my opinion or counter proposal" }
407 else
408 ui.tag{ content = _"I don't like any of the initiative in this issue and I want to add my opinion or counter proposal" }
409 end
410 ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
411 ui.tag { tag = "li", content = function ()
412 ui.link {
413 module = "issue", view = "show", id = issue.id,
414 content = _"take a look at the competing initiatives"
415 }
416 end }
417 ui.tag { tag = "li", content = function ()
418 ui.link {
419 module = "draft", view = "new",
420 params = { issue_id = issue.id },
421 content = _"start a new competing initiative"
422 }
423 end }
424 end }
425 end }
426 end
428 end
430 if not config.disable_delegations and privileged_to_vote and not issue.closed then
432 if not issue.member_info.first_trustee_id then
433 ui.container { attr = { class = "mdl-card__content mdl-card--border" }, content = function ()
434 ui.tag{ content = _"I want to delegate this issue" }
436 ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
437 ui.tag { tag = "li", content = function ()
438 ui.link {
439 module = "delegation", view = "show", params = {
440 issue_id = issue.id,
441 initiative_id = initiative and initiative.id or nil
442 },
443 content = _"choose issue delegatee"
444 }
445 end }
446 end }
447 end }
448 end
450 end
452 if initiator and initiator.accepted == false then
453 ui.container { attr = { class = "mdl-card__content mdl-card--border" }, content = function ()
454 ui.tag { content = _"You refused to become initiator of this initiative" }
455 ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
456 ui.tag{ tag = "li", content = function ()
457 ui.link{
458 text = _"allow invitation again",
459 module = "initiative",
460 action = "remove_initiator",
461 params = {
462 initiative_id = initiative.id,
463 member_id = app.session.member.id
464 },
465 routing = {
466 ok = {
467 mode = "redirect",
468 module = "initiative",
469 view = "show",
470 id = initiative.id
471 }
472 }
473 }
474 end }
475 end }
476 end }
477 end
481 if privileged_to_vote then
483 if initiative and
484 (issue.state == "admission" or
485 issue.state == "discussion" or
486 issue.state == "verification")
487 then
489 elseif issue.state == "verification" then
491 elseif issue.state == "voting" then
492 if not issue.member_info.direct_voted then
493 if not issue.member_info.non_voter then
494 ui.container { attr = { class = "mdl-card__content mdl-card--border" }, content = function ()
495 ui.tag{ content = _"I like to vote on this issue:" }
496 ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
497 ui.tag { tag = "li", content = function ()
498 ui.tag { content = function ()
499 if not issue.closed then
500 ui.link {
501 xattr = { class = "btn btn-vote" },
502 module = "vote", view = "list",
503 params = { issue_id = issue.id },
504 text = _"vote now"
505 }
506 end
507 end }
508 end }
509 end }
510 end }
511 end
512 ui.container { attr = { class = "mdl-card__content mdl-card--border" }, content = function ()
513 if not issue.member_info.non_voter then
514 ui.tag{ content = _"I don't like to vote this issue (myself):" }
515 ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
516 ui.tag { tag = "li", content = function ()
517 ui.link{
518 content = _"do not notify me about this voting anymore",
519 module = "vote",
520 action = "non_voter",
521 params = { issue_id = issue.id },
522 routing = {
523 default = {
524 mode = "redirect",
525 module = request.get_module(),
526 view = request.get_view(),
527 id = request.get_id_string(),
528 params = request.get_param_strings()
529 }
530 }
531 }
532 end }
533 end }
534 else
535 ui.tag{ content = _"You do not like to vote this issue (yourself)" }
536 ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
537 ui.tag { tag = "li", content = function ()
538 ui.link{
539 in_brackets = true,
540 content = _"discard",
541 module = "vote",
542 action = "non_voter",
543 params = { issue_id = issue.id, delete = true },
544 routing = {
545 default = {
546 mode = "redirect",
547 module = request.get_module(),
548 view = request.get_view(),
549 id = request.get_id_string(),
550 params = request.get_param_strings()
551 }
552 }
553 }
554 end }
555 end }
556 end
557 end }
558 else
559 ui.container { attr = { class = "mdl-card__content mdl-card--border" }, content = function ()
560 ui.tag{ content = _"I like to change/revoke my vote:" }
561 ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
562 ui.tag { tag = "li", content = function ()
563 ui.tag { content = function ()
564 if not issue.closed then
565 ui.link {
566 xattr = { class = "btn btn-vote" },
567 module = "vote", view = "list",
568 params = { issue_id = issue.id },
569 text = _"change my vote"
570 }
571 end
572 end }
573 end }
574 ui.tag { tag = "li", content = function ()
575 ui.tag { content = function ()
576 if not issue.closed then
577 ui.link {
578 module = "vote", action = "update",
579 params = {
580 issue_id = issue.id,
581 discard = true
582 },
583 routing = {
584 default = {
585 mode = "redirect",
586 module = "issue",
587 view = "show",
588 id = issue.id
589 }
590 },
591 text = _"discard my vote"
592 }
593 end
594 end }
595 end }
596 end }
598 end }
600 end
601 end
602 end
604 if not app.session.member or not privileged_to_vote then
605 ui.container { attr = { class = "mdl-card__content mdl-card--border" }, content = function ()
606 if not app.session.member_id then
607 ui.tag{ content = _"Login to participate" }
608 ui.tag{ tag = "ul", content = function()
609 ui.tag{ tag = "li", content = function()
610 ui.link{ module = "index", view = "login", content = _"Login [button]" }
611 end }
612 end }
613 else
614 ui.tag{ content = _"You are not entitled to vote in this unit" }
615 end
616 end }
617 end
619 if issue.closed then
620 ui.container { attr = { class = "mdl-card__content mdl-card--border" }, content = function ()
621 ui.tag { content = _"This issue is closed" }
622 end }
623 end
625 if initiative and config.tell_others and config.tell_others.initiative then
626 ui.container { attr = { class = "mdl-card__content mdl-card--border" }, content = function ()
628 ui.heading { level = 3, content = _"Tell others about this initiative:" }
629 ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
631 for i, link in ipairs (config.tell_others.initiative(initiative)) do
632 ui.tag { tag = "li", content = function ()
633 ui.link ( link )
634 end }
635 end
637 end }
638 end }
639 end
640 end }
642 end }

Impressum / About Us