rev |
line source |
bsw@211
|
1 local initiatives = param.get("initiatives", "table")
|
bsw@215
|
2 local current_initiative_id = param.get("current_initiative_id", atom.integer)
|
bsw@211
|
3
|
bsw@211
|
4 for i, initiative in ipairs(initiatives) do
|
bsw@211
|
5
|
bsw@215
|
6 local class = "initiative"
|
bsw@215
|
7 if i == 1 then class = class .. " first" end
|
bsw@215
|
8 if initiative.id == current_initiative_id then class = class .. " active" end
|
bsw@211
|
9
|
bsw@215
|
10 ui.box_row{ class = class, content = function() ui.box_col { content = function()
|
bsw@211
|
11
|
bsw@211
|
12 ui.link{
|
bsw@211
|
13 module = "lf2", view = "initiative", id = initiative.id,
|
bsw@215
|
14 attr = { class = "name" },
|
bsw@211
|
15 text = initiative.name
|
bsw@211
|
16 }
|
bsw@211
|
17
|
bsw@211
|
18 ui.container{ attr = { class = "bar" }, content = function()
|
bsw@211
|
19 if initiative.issue.fully_frozen and initiative.issue.closed then
|
bsw@211
|
20 if initiative.issue.ranks_available then
|
bsw@211
|
21 if initiative.negative_votes and initiative.positive_votes then
|
bsw@211
|
22 local max_value = initiative.issue.voter_count
|
bsw@211
|
23 ui.bargraph{
|
bsw@211
|
24 max_value = max_value,
|
bsw@211
|
25 width = 100,
|
bsw@211
|
26 bars = {
|
bsw@211
|
27 { color = "#0a0", value = initiative.positive_votes },
|
bsw@211
|
28 { color = "#aaa", value = max_value - initiative.negative_votes - initiative.positive_votes },
|
bsw@211
|
29 { color = "#a00", value = initiative.negative_votes },
|
bsw@211
|
30 }
|
bsw@211
|
31 }
|
bsw@211
|
32 else
|
bsw@211
|
33 slot.put(" ")
|
bsw@211
|
34 end
|
bsw@211
|
35 else
|
bsw@211
|
36 slot.put(_"Counting of votes")
|
bsw@211
|
37 end
|
bsw@211
|
38 elseif initiative.issue.population then
|
bsw@211
|
39 local max_value = initiative.issue.population
|
bsw@211
|
40 ui.bargraph{
|
bsw@211
|
41 max_value = max_value,
|
bsw@211
|
42 width = 100,
|
bsw@211
|
43 quorum = max_value * (initiative.issue.policy.initiative_quorum_num / initiative.issue.policy.initiative_quorum_den),
|
bsw@211
|
44 quorum_color = "#00F",
|
bsw@211
|
45 bars = {
|
bsw@211
|
46 { color = "#0a0", value = (initiative.satisfied_supporter_count or 0) },
|
bsw@211
|
47 { color = "#bbb", value = (initiative.supporter_count or 0) - (initiative.satisfied_supporter_count or 0) },
|
bsw@211
|
48 { color = "#eee", value = max_value - (initiative.supporter_count or 0) },
|
bsw@211
|
49 }
|
bsw@211
|
50 }
|
bsw@211
|
51 else
|
bsw@211
|
52 slot.put(" ")
|
bsw@211
|
53 end
|
bsw@211
|
54 end }
|
bsw@211
|
55
|
bsw@211
|
56 ui.container{ attr = { class = "authors" }, content = function()
|
bsw@211
|
57 local members = initiative.initiating_members
|
bsw@211
|
58 slot.put(_"by", " ")
|
bsw@211
|
59 for i, member in ipairs(members) do
|
bsw@211
|
60 if i > 1 and i < #members then
|
bsw@211
|
61 slot.put(", ")
|
bsw@211
|
62 elseif i > 1 then
|
bsw@211
|
63 slot.put(" ", _"and", " ")
|
bsw@211
|
64 end
|
bsw@211
|
65 ui.link{
|
bsw@211
|
66 module = "lf2", view = "initiative", id = initiative.id,
|
bsw@211
|
67 params = { member_id = member.id }, text = member.name
|
bsw@211
|
68 }
|
bsw@211
|
69 end
|
bsw@211
|
70 end }
|
bsw@211
|
71
|
bsw@211
|
72 end } end }
|
bsw@211
|
73
|
bsw@211
|
74 end |