liquid_feedback_frontend

view app/main/initiative/_list_element.lua @ 118:93f4e465b50d

add initiator support in delegation

if a delegation is issued from the initiative view, the initiators
from that one are added to the delegation target list. this makes it easier to delegate to the author without the need to add him to the contact list.
author Daniel Poelzleithner <poelzi@poelzi.org>
date Mon Sep 20 20:32:04 2010 +0200 (2010-09-20)
parents df5392f114e2
children 5d797c6706d5
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 bars = {
116 { color = "#0a0", value = (initiative.satisfied_supporter_count or 0) },
117 { color = "#bbb", value = (initiative.supporter_count or 0) - (initiative.satisfied_supporter_count or 0) },
118 { color = "#eee", value = max_value - (initiative.supporter_count or 0) },
119 }
120 }
121 else
122 slot.put("&nbsp;")
123 end
124 end
125 },
127 {
128 field_attr = { style = "padding: 0;"},
129 content = function()
130 local link_class
131 if initiative.revoked then
132 link_class = "revoked"
133 end
134 ui.link{
135 attr = { id = link_name, class = link_class },
136 content = function()
137 local name
138 if initiative.name_highlighted then
139 name = encode.highlight(initiative.name_highlighted)
140 else
141 name = encode.html(initiative.shortened_name)
142 end
143 slot.put(name)
144 end,
145 module = module,
146 view = view,
147 id = id,
148 params = params,
149 }
151 if initiative.issue.state == "new" then
152 ui.image{
153 static = "icons/16/new.png"
154 }
155 end
156 if initiative.is_supporter then
157 slot.put("&nbsp;")
158 local label = _"You are supporting this initiative"
159 ui.image{
160 attr = { alt = label, title = label },
161 static = "icons/16/thumb_up_green.png"
162 }
163 end
164 if initiative.is_potential_supporter then
165 slot.put("&nbsp;")
166 local label = _"You are potential supporter of this initiative"
167 ui.image{
168 attr = { alt = label, title = label },
169 static = "icons/16/thumb_up.png"
170 }
171 end
172 if initiative.is_initiator then
173 slot.put("&nbsp;")
174 local label = _"You are iniator of this initiative"
175 ui.image{
176 attr = { alt = label, title = label },
177 static = "icons/16/user_edit.png"
178 }
179 end
181 end
182 }
183 }
184 }
185 end
186 }
187 end
188 }
190 if ui.is_partial_loading_enabled() then
191 ui.container{
192 attr = {
193 id = name,
194 class = "ui_tabs_accordeon_content",
195 style = not expanded and "display: none;" or nil
196 },
197 content = function()
198 ui.container{
199 attr = { id = name .. "_content", style = "clear: left;" },
200 content = function()
201 execute.view{
202 module = "initiative",
203 view = "show_partial",
204 params = {
205 initiative = initiative,
206 expanded = expanded
207 }
208 }
209 end
210 }
211 end
212 }
213 end

Impressum / About Us