rev |
line source |
bsw/jbe@1309
|
1 local for_member = param.get("for_member", "table")
|
bsw/jbe@0
|
2
|
bsw@1045
|
3 local initiatives = param.get("initiatives", "table")
|
bsw/jbe@1309
|
4 local ommit_initiative_id = param.get ( "ommit_initiative_id", "number" )
|
bsw/jbe@1309
|
5
|
bsw@285
|
6
|
bsw@1045
|
7 local for_initiative = param.get("initiative", "table")
|
bsw/jbe@19
|
8
|
bsw@1045
|
9 local for_event = param.get("for_event", atom.boolean)
|
bsw/jbe@19
|
10
|
bsw@1045
|
11 if for_initiative then
|
bsw@1045
|
12 initiatives = { for_initiative }
|
bsw@345
|
13 end
|
bsw@345
|
14
|
bsw@1045
|
15 ui.tag {
|
bsw@1045
|
16 tag = "ul",
|
bsw/jbe@1309
|
17 attr = { class = "initiatives mdl-list" },
|
bsw@1045
|
18 content = function ()
|
bsw@1045
|
19 local last_group
|
bsw@1045
|
20 for i, initiative in ipairs(initiatives) do
|
bsw@1045
|
21 local group
|
bsw@1045
|
22 if initiative.issue.closed then
|
bsw@1045
|
23 if initiative.rank == 1 then
|
bsw@1045
|
24 group = "1st_rank"
|
bsw@1045
|
25 elseif initiative.admitted then
|
bsw@1045
|
26 group = "admitted"
|
bsw@1045
|
27 elseif initiative.revoked_by_member_id then
|
bsw@1045
|
28 group = "revoked"
|
bsw@1045
|
29 else
|
bsw@1045
|
30 group = "not_admitted"
|
bsw@1045
|
31 end
|
bsw@1045
|
32 end
|
bsw/jbe@1309
|
33 if not for_initiative and group ~= last_group and not for_event and not for_member then
|
bsw/jbe@19
|
34
|
bsw@1045
|
35 local text
|
bsw@1045
|
36 if group == "admitted" then
|
bsw@1045
|
37 if initiative.issue.state == "finished_with_winner" then
|
bsw@1045
|
38 text = _"Competing initiatives in pairwise comparison to winner:"
|
bsw/jbe@1309
|
39 elseif initiative.issue.voter_count and initiative.issue.voter_count > 0 then
|
bsw@1045
|
40 text = _"Competing initiatives in pairwise comparison to best initiative:"
|
bsw@1045
|
41 end
|
bsw@1045
|
42 end
|
bsw/jbe@1309
|
43 if group == "not_admitted" and initiative.issue.state ~= "canceled_no_initiative_admitted" then
|
bsw@1045
|
44 text = _("Competing initiatives failed the 2nd quorum (#{num}/#{den}):", {
|
bsw@1045
|
45 num = initiative.issue.policy.initiative_quorum_num,
|
bsw@1045
|
46 den = initiative.issue.policy.initiative_quorum_den
|
bsw@1045
|
47 } )
|
bsw@1045
|
48 end
|
bsw@1045
|
49 if text then
|
bsw/jbe@1309
|
50 ui.tag{ tag = "li", attr = { class = "mdl-list__item" }, content = function()
|
bsw/jbe@1309
|
51 ui.container{ attr = { class = "mdl-list__item-primary-content" }, content = text }
|
bsw/jbe@1309
|
52 end }
|
bsw@1045
|
53 end
|
bsw@1045
|
54 last_group = group
|
bsw@1045
|
55 end
|
bsw@1045
|
56
|
bsw/jbe@1309
|
57 if ommit_initiative_id ~= initiative.id then
|
bsw/jbe@1309
|
58 local class = "mdl-list__item mdl-list__item--three-line"
|
bsw/jbe@1309
|
59 if app.session.member then
|
bsw/jbe@1309
|
60 if initiative.member_info.supported then
|
bsw/jbe@1309
|
61 class = class .. " supported"
|
bsw/jbe@1309
|
62 end
|
bsw/jbe@1309
|
63 if initiative.member_info.satisfied then
|
bsw/jbe@1309
|
64 class = class .. " satisfied"
|
bsw/jbe@1309
|
65 end
|
bsw@1045
|
66 end
|
bsw/jbe@1309
|
67 ui.tag {
|
bsw/jbe@1309
|
68 tag = "li", attr = { class = class },
|
bsw/jbe@1309
|
69 content = function ()
|
bsw/jbe@1309
|
70 if i == 1 and not ommit_initiative_id and not for_member and (
|
bsw/jbe@1309
|
71 initiative.issue.state == "finished_with_winner"
|
bsw/jbe@1309
|
72 or initiative.issue.state == "finished_without_winner"
|
bsw/jbe@1309
|
73 ) then
|
bsw/jbe@1309
|
74 util.initiative_pie(initiative)
|
bsw/jbe@1309
|
75 end
|
bsw/jbe@1309
|
76 execute.view {
|
bsw/jbe@1309
|
77 module = "initiative", view = "_list_element", params = {
|
bsw/jbe@1309
|
78 initiative = initiative, for_event = for_event, for_member = for_member
|
bsw/jbe@1309
|
79 }
|
bsw/jbe@1309
|
80 }
|
bsw/jbe@1309
|
81 end
|
bsw/jbe@1309
|
82 }
|
bsw@1045
|
83 end
|
bsw@551
|
84 end
|
bsw@1045
|
85 end
|
bsw/jbe@1309
|
86 }
|