liquid_feedback_frontend

view app/main/initiative/_list_element.lua @ 898:ae9ab3edff89

Added polling support
author bsw
date Mon Aug 20 03:54:20 2012 +0200 (2012-08-20)
parents a1ff5d08f0f4
children c7215c18168b
line source
1 local initiative = param.get("initiative", "table")
2 local selected = param.get("selected", atom.boolean)
3 local for_member = param.get("for_member", "table") or app.session.member
5 local class = "initiative"
7 if selected then
8 class = class .. " selected"
9 end
11 if initiative.polling then
12 class = class .. " polling"
13 end
15 ui.container{ attr = { class = class }, content = function()
17 ui.container{ attr = { class = "rank" }, content = function()
18 if initiative.issue.accepted and initiative.issue.closed
19 and initiative.issue.ranks_available or initiative.admitted == false
20 then
21 ui.field.rank{ attr = { class = "rank" }, value = initiative.rank, eligible = initiative.eligible }
22 elseif not initiative.issue.closed then
23 ui.image{ static = "icons/16/script.png" }
24 else
25 ui.image{ static = "icons/16/cross.png" }
26 end
27 end }
29 ui.container{ attr = { class = "bar" }, content = function()
30 if initiative.issue.fully_frozen and initiative.issue.closed then
31 if initiative.issue.ranks_available then
32 if initiative.negative_votes and initiative.positive_votes then
33 local max_value = initiative.issue.voter_count
34 ui.bargraph{
35 max_value = max_value,
36 width = 100,
37 bars = {
38 { color = "#0a5", value = initiative.positive_votes },
39 { color = "#aaa", value = max_value - initiative.negative_votes - initiative.positive_votes },
40 { color = "#a00", value = initiative.negative_votes },
41 }
42 }
43 else
44 slot.put(" ")
45 end
46 else
47 slot.put(_"Counting of votes")
48 end
49 else
50 local max_value = initiative.issue.population or 0
51 local quorum
52 if initiative.issue.accepted then
53 quorum = initiative.issue.policy.initiative_quorum_num / initiative.issue.policy.initiative_quorum_den
54 else
55 quorum = initiative.issue.policy.issue_quorum_num / initiative.issue.policy.issue_quorum_den
56 end
57 ui.bargraph{
58 max_value = max_value,
59 width = 100,
60 quorum = max_value * quorum,
61 quorum_color = "#00F",
62 bars = {
63 { color = "#0a5", value = (initiative.satisfied_supporter_count or 0) },
64 { color = "#aaa", value = (initiative.supporter_count or 0) - (initiative.satisfied_supporter_count or 0) },
65 { color = "#fff", value = max_value - (initiative.supporter_count or 0) },
66 }
67 }
68 end
69 end }
71 if app.session.member_id then
72 ui.container{ attr = { class = "interest" }, content = function()
73 if initiative.member_info.initiated then
74 local label
75 if for_member and for_member.id ~= app.session.member_id then
76 label = _"This member is initiator of this initiative"
77 else
78 label = _"You are initiator of this initiative"
79 end
80 ui.image{
81 attr = { alt = label, title = label },
82 static = "icons/16/user_edit.png"
83 }
84 elseif initiative.member_info.directly_supported then
85 if initiative.member_info.satisfied then
86 if for_member and for_member.id ~= app.session.member_id then
87 label = _"This member is supporter of this initiative"
88 else
89 local label = _"You are supporter of this initiative"
90 end
91 ui.image{
92 attr = { alt = label, title = label },
93 static = "icons/16/thumb_up_green.png"
94 }
95 else
96 if for_member and for_member.id ~= app.session.member_id then
97 label = _"This member is potential supporter of this initiative"
98 else
99 local label = _"You are potential supporter of this initiative"
100 end
101 ui.image{
102 attr = { alt = label, title = label },
103 static = "icons/16/thumb_up.png"
104 }
105 end
106 elseif initiative.member_info.supported then
107 if initiative.member_info.satisfied then
108 if for_member and for_member.id ~= app.session.member_id then
109 label = _"This member is supporter of this initiative via delegation"
110 else
111 local label = _"You are supporter of this initiative via delegation"
112 end
113 ui.image{
114 attr = { alt = label, title = label },
115 static = "icons/16/thumb_up_green_arrow.png"
116 }
117 else
118 if for_member and for_member.id ~= app.session.member_id then
119 label = _"This member is potential supporter of this initiative via delegation"
120 else
121 local label = _"You are potential supporter of this initiative via delegation"
122 end
123 ui.image{
124 attr = { alt = label, title = label },
125 static = "icons/16/thumb_up_arrow.png"
126 }
127 end
128 end
129 end }
130 end
132 ui.container{ attr = { class = "name" }, content = function()
133 local link_class = "initiative_link"
134 if initiative.revoked then
135 link_class = "revoked"
136 end
137 ui.link{
138 attr = { class = link_class },
139 content = function()
140 local name
141 if initiative.name_highlighted then
142 name = encode.highlight(initiative.name_highlighted)
143 else
144 name = encode.html(initiative.shortened_name)
145 end
146 ui.tag{ content = "i" .. initiative.id .. ": " }
147 slot.put(name)
148 end,
149 module = "initiative",
150 view = "show",
151 id = initiative.id
152 }
154 end }
156 end }

Impressum / About Us