rev |
line source |
bsw/jbe@19
|
1 local initiative = param.get("initiative", "table")
|
bsw@274
|
2 local selected = param.get("selected", atom.boolean)
|
bsw/jbe@19
|
3
|
bsw@715
|
4 local class = "initiative"
|
bsw/jbe@19
|
5
|
bsw@715
|
6 if selected then
|
bsw@715
|
7 class = class .. " selected"
|
bsw@715
|
8 end
|
bsw@715
|
9
|
bsw@715
|
10 ui.container{ attr = { class = class }, content = function()
|
bsw/jbe@19
|
11
|
bsw@373
|
12 ui.container{ attr = { class = "rank" }, content = function()
|
bsw@373
|
13 if initiative.issue.accepted and initiative.issue.closed
|
bsw@373
|
14 and initiative.issue.ranks_available or initiative.admitted == false
|
bsw@373
|
15 then
|
bsw@373
|
16 ui.field.rank{ attr = { class = "rank" }, value = initiative.rank, eligible = initiative.eligible }
|
bsw@414
|
17 elseif not initiative.issue.closed then
|
bsw@414
|
18 ui.image{ static = "icons/16/script.png" }
|
bsw@373
|
19 else
|
bsw@414
|
20 ui.image{ static = "icons/16/cross.png" }
|
bsw@373
|
21 end
|
bsw@373
|
22 end }
|
bsw@373
|
23
|
bsw@373
|
24 ui.container{ attr = { class = "bar" }, content = function()
|
bsw@373
|
25 if initiative.issue.fully_frozen and initiative.issue.closed then
|
bsw@373
|
26 if initiative.issue.ranks_available then
|
bsw@373
|
27 if initiative.negative_votes and initiative.positive_votes then
|
bsw@373
|
28 local max_value = initiative.issue.voter_count
|
bsw@345
|
29 ui.bargraph{
|
bsw@345
|
30 max_value = max_value,
|
bsw@345
|
31 width = 100,
|
bsw@345
|
32 bars = {
|
bsw@674
|
33 { color = "#0a5", value = initiative.positive_votes },
|
bsw@373
|
34 { color = "#aaa", value = max_value - initiative.negative_votes - initiative.positive_votes },
|
bsw@373
|
35 { color = "#a00", value = initiative.negative_votes },
|
bsw/jbe@19
|
36 }
|
bsw/jbe@19
|
37 }
|
bsw@373
|
38 else
|
bsw@345
|
39 slot.put(" ")
|
bsw@345
|
40 end
|
bsw@373
|
41 else
|
bsw@373
|
42 slot.put(_"Counting of votes")
|
bsw/jbe@19
|
43 end
|
bsw@373
|
44 else
|
bsw@373
|
45 local max_value = initiative.issue.population or 0
|
bsw@534
|
46 local quorum
|
bsw@534
|
47 if initiative.issue.accepted then
|
bsw@534
|
48 quorum = initiative.issue.policy.initiative_quorum_num / initiative.issue.policy.initiative_quorum_den
|
bsw@534
|
49 else
|
bsw@534
|
50 quorum = initiative.issue.policy.issue_quorum_num / initiative.issue.policy.issue_quorum_den
|
bsw@534
|
51 end
|
bsw@373
|
52 ui.bargraph{
|
bsw@373
|
53 max_value = max_value,
|
bsw@373
|
54 width = 100,
|
bsw@534
|
55 quorum = max_value * quorum,
|
bsw@373
|
56 quorum_color = "#00F",
|
bsw@373
|
57 bars = {
|
bsw@642
|
58 { color = "#0a5", value = (initiative.satisfied_supporter_count or 0) },
|
bsw@642
|
59 { color = "#aaa", value = (initiative.supporter_count or 0) - (initiative.satisfied_supporter_count or 0) },
|
bsw@642
|
60 { color = "#fff", value = max_value - (initiative.supporter_count or 0) },
|
bsw@373
|
61 }
|
bsw/jbe@19
|
62 }
|
bsw/jbe@19
|
63 end
|
bsw@373
|
64 end }
|
bsw@373
|
65
|
bsw@556
|
66 if app.session.member_id then
|
bsw@556
|
67 ui.container{ attr = { class = "interest" }, content = function()
|
bsw@556
|
68 if initiative.member_info.initiated then
|
bsw@556
|
69 local label = _"You are initiator of this initiative"
|
bsw@551
|
70 ui.image{
|
bsw@551
|
71 attr = { alt = label, title = label },
|
bsw@556
|
72 static = "icons/16/user_edit.png"
|
bsw@551
|
73 }
|
bsw@556
|
74 elseif initiative.member_info.directly_supported then
|
bsw@556
|
75 if initiative.member_info.satisfied then
|
bsw@556
|
76 local label = _"You are supporter of this initiative"
|
bsw@556
|
77 ui.image{
|
bsw@556
|
78 attr = { alt = label, title = label },
|
bsw@556
|
79 static = "icons/16/thumb_up_green.png"
|
bsw@556
|
80 }
|
bsw@556
|
81 else
|
bsw@556
|
82 local label = _"You are potential supporter of this initiative"
|
bsw@556
|
83 ui.image{
|
bsw@556
|
84 attr = { alt = label, title = label },
|
bsw@556
|
85 static = "icons/16/thumb_up.png"
|
bsw@556
|
86 }
|
bsw@556
|
87 end
|
bsw@556
|
88 elseif initiative.member_info.supported then
|
bsw@556
|
89 if initiative.member_info.satisfied then
|
bsw@556
|
90 local label = _"You are supporter of this initiative via delegation"
|
bsw@556
|
91 ui.image{
|
bsw@556
|
92 attr = { alt = label, title = label },
|
bsw@556
|
93 static = "icons/16/thumb_up_green_arrow.png"
|
bsw@556
|
94 }
|
bsw@556
|
95 else
|
bsw@556
|
96 local label = _"You are potential supporter of this initiative via delegation"
|
bsw@556
|
97 ui.image{
|
bsw@556
|
98 attr = { alt = label, title = label },
|
bsw@556
|
99 static = "icons/16/thumb_up_arrow.png"
|
bsw@556
|
100 }
|
bsw@556
|
101 end
|
bsw@551
|
102 end
|
bsw@556
|
103 end }
|
bsw@556
|
104 end
|
bsw@556
|
105
|
bsw@373
|
106 ui.container{ attr = { class = "name" }, content = function()
|
bsw@373
|
107 local link_class = "initiative_link"
|
bsw@373
|
108 if initiative.revoked then
|
bsw@373
|
109 link_class = "revoked"
|
bsw@373
|
110 end
|
bsw@373
|
111 ui.link{
|
bsw@373
|
112 attr = { class = link_class },
|
bsw@345
|
113 content = function()
|
bsw@373
|
114 local name
|
bsw@373
|
115 if initiative.name_highlighted then
|
bsw@373
|
116 name = encode.highlight(initiative.name_highlighted)
|
bsw@373
|
117 else
|
bsw@373
|
118 name = encode.html(initiative.shortened_name)
|
bsw@345
|
119 end
|
bsw@373
|
120 ui.tag{ content = "i" .. initiative.id .. ": " }
|
bsw@373
|
121 slot.put(name)
|
bsw@373
|
122 end,
|
bsw@373
|
123 module = "initiative",
|
bsw@373
|
124 view = "show",
|
bsw@373
|
125 id = initiative.id
|
bsw@345
|
126 }
|
bsw@373
|
127
|
bsw@373
|
128 end }
|
bsw@373
|
129
|
bsw@534
|
130 end }
|