liquid_feedback_frontend

view app/main/initiative/_list_element.lua @ 159:5d797c6706d5

implement quorum display

show the initiative quorum as a small 1px line in bargraph
allow to update your support on the diff page
better linked title in diff page
show absolute quorum numbers in detail pages of issue and initiative
author Daniel Poelzleithner <poelzi@poelzi.org>
date Sat Oct 09 03:42:48 2010 +0200 (2010-10-09)
parents df5392f114e2
children 86988175dc89
line source
1 local initiative = param.get("initiative", "table")
2 local expanded = param.get("expanded", atom.boolean)
3 local expandable = param.get("expandable", atom.boolean)
5 local head_name = "initiative_head_" .. tostring(initiative.id)
6 local link_name = "initiative_link_" .. tostring(initiative.id)
7 local name = "initiative_content_" .. tostring(initiative.id)
8 local icon_name = "initiative_icon_" .. tostring(initiative.id)
10 ui.container{
11 attr = { class = "ui_tabs" .. (initiative.id == for_initiative_id and " active" or "") },
12 content = function()
13 local web20 = config.user_tab_mode == "accordeon"
14 or config.user_tab_mode == "accordeon_first_expanded"
15 or config.user_tab_mode == "accordeon_all_expanded"
16 local onclick
17 if web20 then
18 if expandable then
19 onclick =
20 'if (lf_initiative_expanded["' .. name .. '"]) {' ..
21 'lf_initiative_expanded["' .. name .. '"]=false;' ..
22 'document.getElementById("' .. name .. '_content").innerHTML="&nbsp;";' ..
23 'document.getElementById("' .. name .. '").style.display="none";' ..
24 '} else {' ..
25 'lf_initiative_expanded["' .. name .. '"] = true;' ..
26 'document.getElementById("' .. name .. '").style.display="block"; ' ..
27 'var hourglass_el = document.getElementById("' .. icon_name .. '");' ..
28 'var hourglass_src = hourglass_el.src;' ..
29 'hourglass_el.src = "' .. encode.url{ static = "icons/16/connect.png" } .. '";' ..
30 'partialMultiLoad(' ..
31 '{ trace: "trace", system_error: "system_error", ' .. name .. '_content: "default" },' ..
32 '{},' ..
33 '"error",' ..
34 '"' .. request.get_relative_baseurl() .. 'initiative/show_partial/' .. tostring(initiative.id) .. '.html?&_webmcp_json_slots[]=default&_webmcp_json_slots[]=support&_webmcp_json_slots[]=trace&_webmcp_json_slots[]=system_error",' ..
35 '{},' ..
36 '{},' ..
37 'function() {' ..
38 'hourglass_el.src = hourglass_src;' ..
39 '},' ..
40 'function() {' ..
41 'hourglass_el.src = hourglass_src;' ..
42 '}' ..
43 '); ' ..
44 '}' ..
45 'return(false);'
46 else
47 onclick = "document.location.href = document.getElementById('" .. link_name .. "').href;"
48 end
49 end
50 local module = "initiative"
51 local view = "show"
52 local id = initiative.id
53 local params = {}
54 ui.container{
55 attr = {
56 name = name,
57 class = "ui_tabs_accordeon_head",
58 id = head_name,
59 onclick = onclick,
60 },
61 content = function()
63 ui.list{
64 attr = { class = "nohover" },
65 records = { { a = 1} },
66 columns = {
67 {
68 field_attr = { style = "width: 4em; padding: 0;"},
69 content = function()
70 if initiative.issue.accepted and initiative.issue.closed and initiative.issue.ranks_available or initiative.admitted == false then
71 ui.field.rank{ image_attr = { id = icon_name }, attr = { class = "rank" }, value = initiative.rank }
72 elseif web20 then
73 ui.image{
74 attr = {
75 width = 16,
76 height = 16,
77 id = icon_name,
78 style = "float: left;"
79 },
80 static = "icons/16/script.png"
81 }
82 else
83 slot.put("&nbsp;")
84 end
85 end
86 },
88 {
89 field_attr = { style = "width: 110px; padding: 0;"},
90 content = function()
91 if initiative.issue.fully_frozen and initiative.issue.closed then
92 if initiative.issue.ranks_available then
93 if initiative.negative_votes and initiative.positive_votes then
94 local max_value = initiative.issue.voter_count
95 ui.bargraph{
96 max_value = max_value,
97 width = 100,
98 bars = {
99 { color = "#0a0", value = initiative.positive_votes },
100 { color = "#aaa", value = max_value - initiative.negative_votes - initiative.positive_votes },
101 { color = "#a00", value = initiative.negative_votes },
102 }
103 }
104 else
105 slot.put("&nbsp;")
106 end
107 else
108 slot.put(_"Counting of votes")
109 end
110 elseif initiative.issue.population then
111 local max_value = initiative.issue.population
112 ui.bargraph{
113 max_value = max_value,
114 width = 100,
115 quorum = max_value * (initiative.issue.policy.initiative_quorum_num / initiative.issue.policy.initiative_quorum_den),
116 quorum_color = "#00F",
117 bars = {
118 { color = "#0a0", value = (initiative.satisfied_supporter_count or 0) },
119 { color = "#bbb", value = (initiative.supporter_count or 0) - (initiative.satisfied_supporter_count or 0) },
120 { color = "#eee", value = max_value - (initiative.supporter_count or 0) },
121 }
122 }
123 else
124 slot.put("&nbsp;")
125 end
126 end
127 },
129 {
130 field_attr = { style = "padding: 0;"},
131 content = function()
132 local link_class
133 if initiative.revoked then
134 link_class = "revoked"
135 end
136 ui.link{
137 attr = { id = link_name, class = link_class },
138 content = function()
139 local name
140 if initiative.name_highlighted then
141 name = encode.highlight(initiative.name_highlighted)
142 else
143 name = encode.html(initiative.shortened_name)
144 end
145 slot.put(name)
146 end,
147 module = module,
148 view = view,
149 id = id,
150 params = params,
151 }
153 if initiative.issue.state == "new" then
154 ui.image{
155 static = "icons/16/new.png"
156 }
157 end
158 if initiative.is_supporter then
159 slot.put("&nbsp;")
160 local label = _"You are supporting this initiative"
161 ui.image{
162 attr = { alt = label, title = label },
163 static = "icons/16/thumb_up_green.png"
164 }
165 end
166 if initiative.is_potential_supporter then
167 slot.put("&nbsp;")
168 local label = _"You are potential supporter of this initiative"
169 ui.image{
170 attr = { alt = label, title = label },
171 static = "icons/16/thumb_up.png"
172 }
173 end
174 if initiative.is_initiator then
175 slot.put("&nbsp;")
176 local label = _"You are iniator of this initiative"
177 ui.image{
178 attr = { alt = label, title = label },
179 static = "icons/16/user_edit.png"
180 }
181 end
183 end
184 }
185 }
186 }
187 end
188 }
189 end
190 }
192 if ui.is_partial_loading_enabled() then
193 ui.container{
194 attr = {
195 id = name,
196 class = "ui_tabs_accordeon_content",
197 style = not expanded and "display: none;" or nil
198 },
199 content = function()
200 ui.container{
201 attr = { id = name .. "_content", style = "clear: left;" },
202 content = function()
203 execute.view{
204 module = "initiative",
205 view = "show_partial",
206 params = {
207 initiative = initiative,
208 expanded = expanded
209 }
210 }
211 end
212 }
213 end
214 }
215 end

Impressum / About Us