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