liquid_feedback_frontend

view app/main/initiative/_list_element.lua @ 256:d28594eb0d42

Mark issue quorum instead of initiative quorum at initiative bargraphs unless issue is accepted
author bsw
date Mon Jan 16 21:40:25 2012 +0100 (2012-01-16)
parents 86988175dc89
children 3e4f6534bb15
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=" ";' ..
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(" ")
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(" ")
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 local quorum
113 if initiative.issue.accepted then
114 quorum = initiative.issue.policy.initiative_quorum_num / initiative.issue.policy.initiative_quorum_den
115 else
116 quorum = initiative.issue.policy.issue_quorum_num / initiative.issue.policy.issue_quorum_den
117 end
118 ui.bargraph{
119 max_value = max_value,
120 width = 100,
121 quorum = max_value * quorum,
122 quorum_color = "#00F",
123 bars = {
124 { color = "#0a0", value = (initiative.satisfied_supporter_count or 0) },
125 { color = "#bbb", value = (initiative.supporter_count or 0) - (initiative.satisfied_supporter_count or 0) },
126 { color = "#eee", value = max_value - (initiative.supporter_count or 0) },
127 }
128 }
129 else
130 slot.put(" ")
131 end
132 end
133 },
135 {
136 field_attr = { style = "padding: 0;"},
137 content = function()
138 local link_class
139 if initiative.revoked then
140 link_class = "revoked"
141 end
142 ui.link{
143 attr = { id = link_name, class = link_class },
144 content = function()
145 local name
146 if initiative.name_highlighted then
147 name = encode.highlight(initiative.name_highlighted)
148 else
149 name = encode.html(initiative.shortened_name)
150 end
151 slot.put(name)
152 end,
153 module = module,
154 view = view,
155 id = id,
156 params = params,
157 }
159 if initiative.issue.state == "new" then
160 ui.image{
161 static = "icons/16/new.png"
162 }
163 end
164 if initiative.is_supporter then
165 slot.put(" ")
166 local label = _"You are supporting this initiative"
167 ui.image{
168 attr = { alt = label, title = label },
169 static = "icons/16/thumb_up_green.png"
170 }
171 end
172 if initiative.is_potential_supporter then
173 slot.put(" ")
174 local label = _"You are potential supporter of this initiative"
175 ui.image{
176 attr = { alt = label, title = label },
177 static = "icons/16/thumb_up.png"
178 }
179 end
180 if initiative.is_initiator then
181 slot.put(" ")
182 local label = _"You are initiator of this initiative"
183 ui.image{
184 attr = { alt = label, title = label },
185 static = "icons/16/user_edit.png"
186 }
187 end
189 end
190 }
191 }
192 }
193 end
194 }
195 end
196 }
198 if ui.is_partial_loading_enabled() then
199 ui.container{
200 attr = {
201 id = name,
202 class = "ui_tabs_accordeon_content",
203 style = not expanded and "display: none;" or nil
204 },
205 content = function()
206 ui.container{
207 attr = { id = name .. "_content", style = "clear: left;" },
208 content = function()
209 execute.view{
210 module = "initiative",
211 view = "show_partial",
212 params = {
213 initiative = initiative,
214 expanded = expanded
215 }
216 }
217 end
218 }
219 end
220 }
221 end

Impressum / About Us