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