liquid_feedback_frontend

view app/main/issue/_sidebar_whatcanido.lua @ 1135:abee3e49cd44

Initiatives cannot be updated during verification phase
author bsw
date Tue Jan 27 12:07:58 2015 +0100 (2015-01-27)
parents 701a5cf6b067
children e4df22c3a69f
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 ui.sidebar ( "tab-whatcanido", function ()
24 ui.sidebarHeadWhatCanIDo()
26 local supporter
28 if initiative and app.session.member_id then
29 supporter = app.session.member:get_reference_selector("supporters")
30 :add_where{ "initiative_id = ?", initiative.id }
31 :optional_object_mode()
32 :exec()
33 end
35 local view_module
36 local view_id
38 if initiative then
39 issue = issue
40 view_module = "initiative"
41 view_id = initiative.id
42 else
43 view_module = "issue"
44 view_id = issue.id
45 end
47 local initiator
48 if initiative and app.session.member_id then
49 initiator = Initiator:by_pk(initiative.id, app.session.member.id)
50 end
52 local initiators
54 if initiative then
55 local initiators_members_selector = initiative:get_reference_selector("initiating_members")
56 :add_field("initiator.accepted", "accepted")
57 :add_order_by("member.name")
58 if initiator and initiator.accepted then
59 initiators_members_selector:add_where("initiator.accepted ISNULL OR initiator.accepted")
60 else
61 initiators_members_selector:add_where("initiator.accepted")
62 end
64 initiators = initiators_members_selector:exec()
65 end
67 if initiator and
68 initiator.accepted and
69 not issue.fully_frozen and
70 not issue.closed and
71 not initiative.revoked
72 then
74 ui.container { attr = { class = "sidebarRow" }, content = function ()
75 ui.heading { level = 3, content = function()
76 ui.tag { content = _"You are initiator of this initiative" }
77 end }
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 = "sidebarRow highlighted" }, content = function ()
120 ui.heading { level = 3, content = function()
121 ui.tag { content = _"You are invited to become initiator of this initiative" }
122 end }
123 ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
124 ui.tag{ tag = "li", content = function ()
125 ui.link{
126 content = _"accept invitation",
127 module = "initiative",
128 action = "accept_invitation",
129 id = initiative.id,
130 routing = {
131 default = {
132 mode = "redirect",
133 module = request.get_module(),
134 view = request.get_view(),
135 id = param.get_id_cgi(),
136 params = param.get_all_cgi()
137 }
138 }
139 }
140 end }
142 ui.tag{ tag = "li", content = function ()
143 ui.link{
144 content = _"refuse invitation",
145 module = "initiative",
146 action = "reject_initiator_invitation",
147 params = {
148 initiative_id = initiative.id,
149 member_id = app.session.member.id
150 },
151 routing = {
152 default = {
153 mode = "redirect",
154 module = request.get_module(),
155 view = request.get_view(),
156 id = param.get_id_cgi(),
157 params = param.get_all_cgi()
158 }
159 }
160 }
161 end }
162 end }
163 end }
164 end
167 if privileged_to_vote and issue.member_info.first_trustee_id then
168 local member = Member:by_id(issue.member_info.first_trustee_id)
169 ui.sidebarSection( function ()
170 ui.container { attr = { class = "right" }, content = function()
171 execute.view{
172 module = "member_image",
173 view = "_show",
174 params = {
175 member = member,
176 image_type = "avatar",
177 show_dummy = true
178 }
179 }
180 end }
181 if issue.member_info.own_delegation_scope == "unit" then
182 ui.heading{ level = 3, content = _"You delegated this organizational unit" }
183 elseif issue.member_info.own_delegation_scope == "area" then
184 ui.heading{ level = 3, content = _"You delegated this subject area" }
185 elseif issue.member_info.own_delegation_scope == "issue" then
186 ui.heading{ level = 3, 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 end }
246 if issue.member_info.first_trustee_id and issue.member_info.own_participation then
247 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."
248 if issue.state == "voting" then
249 text = _"This delegation is suspended, because you voted yourself."
250 end
251 ui.container { content = text }
252 end
253 end )
254 end
256 if privileged_to_vote and not issue.closed and not issue.fully_frozen then
257 if issue.member_info.own_participation then
258 ui.sidebarSection( function ()
259 ui.container{ attr = { class = "right" }, content = function()
260 ui.image{ attr = { class = "right" }, static = "icons/48/eye.png" }
261 if issue.member_info.weight and issue.member_info.weight > 1 then
262 slot.put("<br />")
263 ui.tag{
264 attr = { class = "right" },
265 content = "+" .. issue.member_info.weight - 1
266 }
267 end
268 end }
269 ui.heading{ level = 3, content = _("You are interested in this issue", { id = issue.id }) }
270 ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
271 if issue.member_info.weight and issue.member_info.weight > 1 then
272 ui.tag { tag = "li", content = function ()
273 ui.link {
274 module = "delegation", view = "show_incoming",
275 params = { issue_id = issue.id, member_id = app.session.member_id },
276 content = _("you have #{count} incoming delegations", {
277 count = issue.member_info.weight - 1
278 })
279 }
280 end }
281 end
282 ui.tag { tag = "li", content = function ()
283 ui.link {
284 module = "interest", action = "update",
285 routing = { default = {
286 mode = "redirect", module = view_module, view = "show", id = view_id
287 } },
288 params = { issue_id = issue.id, delete = true },
289 text = _"remove my interest"
290 }
291 end }
292 end }
293 end )
294 else
295 ui.sidebarSection( function ()
296 ui.heading{ level = 3, content = _("I want to participate in this issue", { id = issue.id }) }
297 ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
298 ui.tag { tag = "li", content = function ()
299 ui.link {
300 module = "interest", action = "update",
301 params = { issue_id = issue.id },
302 routing = { default = {
303 mode = "redirect", module = view_module, view = "show", id = view_id
304 } },
305 text = _"add my interest"
306 }
307 end }
308 ui.tag { tag = "li", content = _"browse through the competing initiatives" }
309 end }
310 end )
311 end
313 if initiative then
315 if not initiative.member_info.supported or active_trustee_id then
316 ui.container { attr = { class = "sidebarRow" }, content = function ()
317 ui.heading { level = 3, content = function()
318 ui.tag { content = _"I like this initiative and I want to support it" }
319 end }
320 ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
321 ui.tag { tag = "li", content = function ()
322 ui.link {
323 module = "initiative", action = "add_support",
324 routing = { default = {
325 mode = "redirect", module = "initiative", view = "show", id = initiative.id
326 } },
327 id = initiative.id,
328 text = _"add my support"
329 }
330 end }
331 end }
332 end }
334 else -- if not supported
335 ui.container { attr = { class = "sidebarRow" }, content = function ()
336 if initiative.member_info.satisfied then
337 ui.image{ attr = { class = "right icon48" }, static = "icons/32/support_satisfied.png" }
338 else
339 ui.image{ attr = { class = "right icon48" }, static = "icons/32/support_unsatisfied.png" }
340 end
341 ui.heading { level = 3, content = _"You are supporting this initiative" }
342 ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
343 if not initiative.member_info.satisfied then
344 ui.tag { tag = "li", content = function ()
345 ui.tag { content = function ()
346 ui.link {
347 external = "#suggestions",
348 content = _"you restricted your support by rating suggestions as must or must not"
349 }
350 end }
351 end }
352 end
353 ui.tag { tag = "li", content = function ()
354 ui.tag { content = function ()
355 ui.link {
356 xattr = { class = "btn btn-remove" },
357 module = "initiative", action = "remove_support",
358 routing = { default = {
359 mode = "redirect", module = "initiative", view = "show", id = initiative.id
360 } },
361 id = initiative.id,
362 text = _"remove my support"
363 }
364 end }
365 end }
366 end }
367 end }
369 end -- not supported
371 ui.container { attr = { class = "sidebarRow" }, content = function ()
372 ui.heading { level = 3, content = _"I want to improve this initiative" }
373 ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
374 if issue.state == "verification" then
375 ui.tag { tag = "li", content = _"this issue is in verification phase, therefore the initiative text cannot be updated anymore" }
376 elseif issue.state == "voting" then
377 ui.tag { tag = "li", content = _"this issue is in voting phase, therefore the initiative text cannot be updated anymore" }
378 else
380 if initiative.member_info.initiated then
381 ui.tag { tag = "li", content =_"take a look at the suggestions of your supporters" }
382 ui.tag { tag = "li", content =_"if you like to implement a suggestion in your proposal and/or reasons, update your initiative draft" }
383 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" }
384 end
386 if not initiative.member_info.supported or active_trustee_id then
387 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)" }
388 else
389 ui.tag { tag = "li", content = _"take a look at the suggestions (see left) and rate them" }
390 ui.tag { tag = "li", content = function ()
391 ui.link {
392 module = "suggestion", view = "new", params = {
393 initiative_id = initiative.id
394 },
395 content = _"write a new suggestion"
396 }
397 end }
398 end
399 end
400 end }
401 end }
403 end
405 if
406 (issue.state == "admission" or
407 issue.state == "discussion" or
408 issue.state == "verification")
409 then
410 ui.sidebarSection( function ()
411 if initiative then
412 ui.heading{ level = 3, content = _"I don't like this initiative and I want to add my opinion or counter proposal" }
413 else
414 ui.heading{ level = 3, content = _"I don't like any of the initiative in this issue and I want to add my opinion or counter proposal" }
415 end
416 ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
417 ui.tag { tag = "li", content = function ()
418 ui.link {
419 module = "issue", view = "show", id = issue.id,
420 content = _"take a look at the competing initiatives"
421 }
422 end }
423 ui.tag { tag = "li", content = function ()
424 ui.link {
425 module = "initiative", view = "new",
426 params = { issue_id = issue.id },
427 content = _"start a new competing initiative"
428 }
429 end }
430 end }
431 end )
432 end
434 if not issue.member_info.first_trustee_id then
435 ui.sidebarSection( function ()
436 ui.heading{ level = 3, content = _"I want to delegate this issue" }
438 ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
439 ui.tag { tag = "li", content = function ()
440 ui.link {
441 module = "delegation", view = "show", params = {
442 issue_id = issue.id,
443 initiative_id = initiative and initiative.id or nil
444 },
445 content = _"choose issue delegatee"
446 }
447 end }
448 end }
449 end )
450 end
452 end
454 if initiator and initiator.accepted == false then
455 ui.container { attr = { class = "sidebarRow" }, content = function ()
456 ui.heading { level = 3, content = function()
457 ui.tag { content = _"You refused to become initiator of this initiative" }
458 end }
459 ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
460 ui.tag{ tag = "li", content = function ()
461 ui.link{
462 text = _"allow invitation again",
463 module = "initiative",
464 action = "remove_initiator",
465 params = {
466 initiative_id = initiative.id,
467 member_id = app.session.member.id
468 },
469 routing = {
470 ok = {
471 mode = "redirect",
472 module = "initiative",
473 view = "show",
474 id = initiative.id
475 }
476 }
477 }
478 end }
479 end }
480 end }
481 end
485 if privileged_to_vote then
487 if initiative and
488 (issue.state == "admission" or
489 issue.state == "discussion" or
490 issue.state == "verification")
491 then
493 elseif issue.state == "verification" then
495 elseif issue.state == "voting" then
496 if not issue.member_info.direct_voted then
497 if not issue.member_info.non_voter then
498 ui.container { attr = { class = "sidebarRow" }, content = function ()
499 ui.heading { level = 3, content = _"I like to vote on this issue:" }
500 ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
501 ui.tag { tag = "li", content = function ()
502 ui.tag { content = function ()
503 if not issue.closed then
504 ui.link {
505 xattr = { class = "btn btn-vote" },
506 module = "vote", view = "list",
507 params = { issue_id = issue.id },
508 text = _"vote now"
509 }
510 end
511 end }
512 end }
513 end }
514 end }
515 end
516 ui.container { attr = { class = "sidebarRow" }, content = function ()
517 if not issue.member_info.non_voter then
518 ui.heading { level = 3, content = _"I don't like to vote this issue (myself):" }
519 ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
520 ui.tag { tag = "li", content = function ()
521 ui.link{
522 content = _"do not notify me about this voting anymore",
523 module = "vote",
524 action = "non_voter",
525 params = { issue_id = issue.id },
526 routing = {
527 default = {
528 mode = "redirect",
529 module = request.get_module(),
530 view = request.get_view(),
531 id = param.get_id_cgi(),
532 params = param.get_all_cgi()
533 }
534 }
535 }
536 end }
537 end }
538 else
539 ui.heading { level = 3, content = _"You do not like to vote this issue (yourself)" }
540 ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
541 ui.tag { tag = "li", content = function ()
542 ui.link{
543 in_brackets = true,
544 content = _"discard",
545 module = "vote",
546 action = "non_voter",
547 params = { issue_id = issue.id, delete = true },
548 routing = {
549 default = {
550 mode = "redirect",
551 module = request.get_module(),
552 view = request.get_view(),
553 id = param.get_id_cgi(),
554 params = param.get_all_cgi()
555 }
556 }
557 }
558 end }
559 end }
560 end
561 end }
562 else
563 ui.container { attr = { class = "sidebarRow" }, content = function ()
564 ui.heading { level = 3, content = _"I like to change/revoke my vote:" }
565 ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
566 ui.tag { tag = "li", content = function ()
567 ui.tag { content = function ()
568 if not issue.closed then
569 ui.link {
570 xattr = { class = "btn btn-vote" },
571 module = "vote", view = "list",
572 params = { issue_id = issue.id },
573 text = _"change my vote"
574 }
575 end
576 end }
577 end }
578 ui.tag { tag = "li", content = function ()
579 ui.tag { content = function ()
580 if not issue.closed then
581 ui.link {
582 module = "vote", action = "update",
583 params = {
584 issue_id = issue.id,
585 discard = true
586 },
587 routing = {
588 default = {
589 mode = "redirect",
590 module = "issue",
591 view = "show",
592 id = issue.id
593 }
594 },
595 text = _"discard my vote"
596 }
597 end
598 end }
599 end }
600 end }
602 end }
604 end
605 end
606 end
608 if app.session.member and not privileged_to_vote then
609 ui.sidebarSection( _"You are not entitled to vote in this unit" )
610 end
612 if issue.closed then
613 ui.container { attr = { class = "sidebarRow" }, content = function ()
614 ui.heading { level = 3, content = _"This issue is closed" }
615 end }
616 end
618 if initiative and config.tell_others and config.tell_others.initiative then
619 ui.container { attr = { class = "sidebarRow" }, content = function ()
621 ui.heading { level = 3, content = _"Tell others about this initiative:" }
622 ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
624 for i, link in ipairs (config.tell_others.initiative(initiative)) do
625 ui.tag { tag = "li", content = function ()
626 ui.link ( link )
627 end }
628 end
630 end }
631 end }
632 end
635 end )

Impressum / About Us