liquid_feedback_frontend
view app/main/suggestion/_list.lua @ 38:2c7cc99c4e8e
translated all missing entries
author | Dinu Gherman |
---|---|
date | Fri Mar 05 15:45:55 2010 +0100 (2010-03-05) |
parents | 00d1004545f1 |
children | 0849be391140 |
line source
2 local initiative = param.get("initiative", "table")
3 local suggestions_selector = param.get("suggestions_selector", "table")
4 local tab_id = param.get("tab_id")
5 local show_name = param.get("show_name", atom.boolean)
6 if show_name == nil then
7 show_name = true
8 end
9 local show_filter = param.get("show_filter", atom.boolean)
10 if show_filter == nil then
11 show_filter = true
12 end
14 local partial = {
15 routing = {
16 default = {
17 mode = "redirect",
18 module = "initiative",
19 view = "show_tab",
20 params = {
21 initiative_id = initiative.id,
22 tab = "suggestions",
23 tab_id = tab_id
24 },
25 }
26 }
27 }
29 local ui_filters = ui.filters
30 if not show_filter then
31 ui_filters = function(args) args.content() end
32 end
34 ui_filters{
35 label = _"Show filter",
36 selector = suggestions_selector,
37 {
38 label = _"Order by",
39 {
40 name = "plus_unfulfilled",
41 label = _"requested",
42 selector_modifier = function(selector) selector:add_order_by("plus2_unfulfilled_count + plus1_unfulfilled_count DESC, id") end
43 },
44 {
45 name = "plus2",
46 label = _"must",
47 selector_modifier = function(selector) selector:add_order_by("plus2_unfulfilled_count + plus2_fulfilled_count DESC, id") end
48 },
49 {
50 name = "plus",
51 label = _"must/should",
52 selector_modifier = function(selector) selector:add_order_by("plus2_unfulfilled_count + plus1_unfulfilled_count + plus2_fulfilled_count + plus1_fulfilled_count DESC, id") end
53 },
54 {
55 name = "minus",
56 label = _"must/should not",
57 selector_modifier = function(selector) selector:add_order_by("minus2_unfulfilled_count + minus1_unfulfilled_count + minus2_fulfilled_count + minus1_fulfilled_count DESC, id") end
58 },
59 {
60 name = "minus2",
61 label = _"must not",
62 selector_modifier = function(selector) selector:add_order_by("minus2_unfulfilled_count + minus2_fulfilled_count DESC, id") end
63 }
64 },
65 content = function()
66 ui.paginate{
67 selector = suggestions_selector,
68 content = function()
69 ui.list{
70 attr = { style = "table-layout: fixed;" },
71 records = suggestions_selector:exec(),
72 columns = {
73 {
74 label = show_name and _"Suggestion" or nil,
75 content = function(record)
76 if show_name then
77 ui.link{
78 text = record.name,
79 module = "suggestion",
80 view = "show",
81 id = record.id
82 }
83 end
84 end
85 },
86 {
87 label = _"Collective opinion",
88 label_attr = { style = "width: 101px;" },
89 content = function(record)
90 if record.minus2_unfulfilled_count then
91 local max_value = record.initiative.issue.population
92 ui.bargraph{
93 max_value = max_value,
94 width = 50,
95 bars = {
96 { color = "#ddd", value = max_value - record.minus2_unfulfilled_count - record.minus1_unfulfilled_count - record.minus2_fulfilled_count - record.minus1_fulfilled_count },
97 { color = "#f88", value = record.minus1_unfulfilled_count + record.minus1_fulfilled_count },
98 { color = "#a00", value = record.minus2_unfulfilled_count + record.minus2_fulfilled_count },
99 { color = "#0a0", value = record.plus2_unfulfilled_count + record.plus2_fulfilled_count },
100 { color = "#8f8", value = record.plus1_unfulfilled_count + record.plus1_fulfilled_count },
101 { color = "#ddd", value = max_value - record.plus1_unfulfilled_count - record.plus2_unfulfilled_count - record.plus1_fulfilled_count - record.plus2_fulfilled_count },
102 }
103 }
104 end
105 end
106 },
107 {
108 label = _"My opinion",
109 content = function(record)
110 local degree
111 local opinion = Opinion:by_pk(app.session.member.id, record.id)
112 if opinion then
113 degree = opinion.degree
114 end
115 ui.container{
116 attr = { class = "suggestion_my_opinion" },
117 content = function()
118 if initiative.issue.state == "voting" or initiative.issue.state == "closed" then
119 ui.tag{
120 tag = "span",
121 attr = { class = "action" .. (degree == -2 and " active_red2" or "") },
122 content = _"must not"
123 }
124 ui.tag{
125 tag = "span",
126 attr = { class = "action" .. (degree == -1 and " active_red1" or "") },
127 content = _"should not"
128 }
129 ui.tag{
130 tag = "span",
131 attr = { class = "action" .. (degree == nil and " active" or "") },
132 content = _"neutral"
133 }
134 ui.tag{
135 tag = "span",
136 attr = { class = "action" .. (degree == 1 and " active_green1" or "") },
137 content = _"should"
138 }
139 ui.tag{
140 tag = "span",
141 attr = { class = "action" .. (degree == 2 and " active_green2" or "") },
142 content = _"must"
143 }
144 else
145 ui.link{
146 attr = { class = "action" .. (degree == -2 and " active_red2" or "") },
147 text = _"must not",
148 module = "opinion",
149 action = "update",
150 routing = { default = { mode = "redirect", module = request.get_module(), view = request.get_view(), id = param.get_id_cgi(), params = param.get_all_cgi() } },
151 params = {
152 suggestion_id = record.id,
153 degree = -2
154 },
155 partial = partial
156 }
157 slot.put(" ")
158 ui.link{
159 attr = { class = "action" .. (degree == -1 and " active_red1" or "") },
160 text = _"should not",
161 module = "opinion",
162 action = "update",
163 routing = { default = { mode = "redirect", module = request.get_module(), view = request.get_view(), id = param.get_id_cgi(), params = param.get_all_cgi() } },
164 params = {
165 suggestion_id = record.id,
166 degree = -1
167 },
168 partial = partial
169 }
170 slot.put(" ")
171 ui.link{
172 attr = { class = "action" .. (degree == nil and " active" or "") },
173 text = _"neutral",
174 module = "opinion",
175 action = "update",
176 routing = { default = { mode = "redirect", module = request.get_module(), view = request.get_view(), id = param.get_id_cgi(), params = param.get_all_cgi() } },
177 params = {
178 suggestion_id = record.id,
179 delete = true
180 },
181 partial = partial
182 }
183 slot.put(" ")
184 ui.link{
185 attr = { class = "action" .. (degree == 1 and " active_green1" or "") },
186 text = _"should",
187 module = "opinion",
188 action = "update",
189 routing = { default = { mode = "redirect", module = request.get_module(), view = request.get_view(), id = param.get_id_cgi(), params = param.get_all_cgi() } },
190 params = {
191 suggestion_id = record.id,
192 degree = 1
193 },
194 partial = partial
195 }
196 slot.put(" ")
197 ui.link{
198 attr = { class = "action" .. (degree == 2 and " active_green2" or "") },
199 text = _"must",
200 module = "opinion",
201 action = "update",
202 routing = { default = { mode = "redirect", module = request.get_module(), view = request.get_view(), id = param.get_id_cgi(), params = param.get_all_cgi() } },
203 params = {
204 suggestion_id = record.id,
205 degree = 2
206 },
207 partial = partial
208 }
209 end
210 end
211 }
212 end
213 },
214 {
215 content = function(record)
216 local opinion = Opinion:by_pk(app.session.member.id, record.id)
217 if opinion and not opinion.fulfilled then
218 ui.image{ static = "icons/16/cross.png" }
219 end
220 end
221 },
222 {
223 label = _"Suggestion currently not implemented",
224 label_attr = { style = "width: 101px;" },
225 content = function(record)
226 if record.minus2_unfulfilled_count then
227 local max_value = record.initiative.issue.population
228 ui.bargraph{
229 max_value = max_value,
230 width = 50,
231 bars = {
232 { color = "#ddd", value = max_value - record.minus2_unfulfilled_count - record.minus1_unfulfilled_count },
233 { color = "#f88", value = record.minus1_unfulfilled_count },
234 { color = "#a00", value = record.minus2_unfulfilled_count },
235 { color = "#0a0", value = record.plus2_unfulfilled_count },
236 { color = "#8f8", value = record.plus1_unfulfilled_count },
237 { color = "#ddd", value = max_value - record.plus1_unfulfilled_count - record.plus2_unfulfilled_count },
238 }
239 }
240 end
241 end
242 },
243 {
244 content = function(record)
245 local opinion = Opinion:by_pk(app.session.member.id, record.id)
246 if opinion and opinion.fulfilled then
247 ui.image{ static = "icons/16/tick.png" }
248 end
249 end
250 },
251 {
252 label = _"Suggestion currently implemented",
253 label_attr = { style = "width: 101px;" },
254 content = function(record)
255 if record.minus2_fulfilled_count then
256 local max_value = record.initiative.issue.population
257 ui.bargraph{
258 max_value = max_value,
259 width = 50,
260 bars = {
261 { color = "#ddd", value = max_value - record.minus2_fulfilled_count - record.minus1_fulfilled_count },
262 { color = "#f88", value = record.minus1_fulfilled_count },
263 { color = "#a00", value = record.minus2_fulfilled_count },
264 { color = "#0a0", value = record.plus2_fulfilled_count },
265 { color = "#8f8", value = record.plus1_fulfilled_count },
266 { color = "#ddd", value = max_value - record.plus1_fulfilled_count - record.plus2_fulfilled_count },
267 }
268 }
269 end
270 end
271 },
272 {
273 label_attr = { style = "width: 200px;" },
274 content = function(record)
275 local degree
276 local opinion = Opinion:by_pk(app.session.member.id, record.id)
277 if opinion then
278 degree = opinion.degree
279 end
280 if opinion then
281 if not opinion.fulfilled then
282 local text = ""
283 if opinion.degree > 0 then
284 text = _"Mark suggestion as implemented and express satisfaction"
285 else
286 text = _"Mark suggestion as implemented and express dissatisfaction"
287 end
288 ui.link{
289 attr = { class = "action" },
290 text = text,
291 module = "opinion",
292 action = "update",
293 routing = { default = { mode = "redirect", module = request.get_module(), view = request.get_view(), id = param.get_id_cgi(), params = param.get_all_cgi() } },
294 params = {
295 suggestion_id = record.id,
296 fulfilled = true
297 },
298 partial = partial
299 }
300 else
301 if opinion.degree > 0 then
302 text = _"Mark suggestion as not implemented and express dissatisfaction"
303 else
304 text = _"Mark suggestion as not implemented and express satisfaction"
305 end
306 ui.link{
307 attr = { class = "action" },
308 text = text,
309 module = "opinion",
310 action = "update",
311 routing = { default = { mode = "redirect", module = request.get_module(), view = request.get_view(), id = param.get_id_cgi(), params = param.get_all_cgi() } },
312 params = {
313 suggestion_id = record.id,
314 fulfilled = false
315 },
316 partial = partial
317 }
318 end
319 end
320 end
321 },
322 {
323 content = function(record)
324 local opinion = Opinion:by_pk(app.session.member.id, record.id)
325 if opinion then
326 if (opinion.fulfilled and opinion.degree > 0) or (not opinion.fulfilled and opinion.degree < 0) then
327 ui.image{ static = "icons/16/thumb_up_green.png" }
328 else
329 ui.image{ static = "icons/16/thumb_down_red.png" }
330 end
331 end
332 end
333 },
334 }
335 }
336 end
337 }
338 end
339 }