liquid_feedback_frontend

view app/main/suggestion/_list.lua @ 4:80c215dbf076

Version alpha5

Many optical changes and improved usability

Support for different wiki-formatting-engines

Help system
author bsw/jbe
date Thu Dec 10 12:00:00 2009 +0100 (2009-12-10)
parents 768faea1096d
children afd9f769c7ae
line source
2 local initiative = param.get("initiative", "table")
3 local suggestions_selector = param.get("suggestions_selector", "table")
5 ui.order{
6 name = name,
7 selector = suggestions_selector,
8 options = {
9 {
10 name = "all",
11 label = _"all",
12 order_by = "minus2_unfulfilled_count + minus1_unfulfilled_count + minus2_fulfilled_count + minus1_fulfilled_count + plus2_unfulfilled_count + plus1_unfulfilled_count + plus2_fulfilled_count + plus1_fulfilled_count DESC, id"
13 },
14 {
15 name = "plus2",
16 label = _"must",
17 order_by = "plus2_unfulfilled_count + plus2_fulfilled_count DESC, id"
18 },
19 {
20 name = "plus",
21 label = _"must/should",
22 order_by = "plus2_unfulfilled_count + plus1_unfulfilled_count + plus2_fulfilled_count + plus1_fulfilled_count DESC, id"
23 },
24 {
25 name = "minus",
26 label = _"must/should not",
27 order_by = "minus2_unfulfilled_count + minus1_unfulfilled_count + minus2_fulfilled_count + minus1_fulfilled_count DESC, id"
28 },
29 {
30 name = "minus2",
31 label = _"must not",
32 order_by = "minus2_unfulfilled_count + minus2_fulfilled_count DESC, id"
33 },
34 {
35 name = "unfulfilled",
36 label = _"not implemented",
37 order_by = "minus2_unfulfilled_count + minus1_unfulfilled_count + plus2_unfulfilled_count + plus1_unfulfilled_count DESC, id"
38 },
39 {
40 name = "plus2_unfulfilled",
41 label = _"must",
42 order_by = "plus2_unfulfilled_count DESC, id"
43 },
44 {
45 name = "plus_unfulfilled",
46 label = _"must/should",
47 order_by = "plus2_unfulfilled_count + plus1_unfulfilled_count DESC, id"
48 },
49 {
50 name = "minus_unfulfilled",
51 label = _"must/should not",
52 order_by = "minus2_unfulfilled_count + minus1_unfulfilled_count DESC, id"
53 },
54 {
55 name = "minus2_unfulfilled",
56 label = _"must not",
57 order_by = "minus2_unfulfilled_count DESC, id"
58 },
59 },
60 content = function()
61 ui.paginate{
62 selector = suggestions_selector,
63 content = function()
64 ui.list{
65 attr = { style = "table-layout: fixed;" },
66 records = suggestions_selector:exec(),
67 columns = {
68 {
69 label = _"Suggestion",
70 content = function(record)
71 ui.link{
72 text = record.name,
73 module = "suggestion",
74 view = "show",
75 id = record.id
76 }
77 end
78 },
79 {
80 label = _"Collective opinion",
81 label_attr = { style = "width: 101px;" },
82 content = function(record)
83 if record.minus2_unfulfilled_count then
84 local max_value = record.initiative.issue.population
85 ui.bargraph{
86 max_value = max_value,
87 width = 50,
88 bars = {
89 { color = "#ddd", value = max_value - record.minus2_unfulfilled_count - record.minus1_unfulfilled_count - record.minus2_fulfilled_count - record.minus1_fulfilled_count },
90 { color = "#f88", value = record.minus1_unfulfilled_count + record.minus1_fulfilled_count },
91 { color = "#a00", value = record.minus2_unfulfilled_count + record.minus2_fulfilled_count },
92 { color = "#0a0", value = record.plus2_unfulfilled_count + record.plus2_fulfilled_count },
93 { color = "#8f8", value = record.plus1_unfulfilled_count + record.plus1_fulfilled_count },
94 { color = "#ddd", value = max_value - record.plus1_unfulfilled_count - record.plus2_unfulfilled_count - record.plus1_fulfilled_count - record.plus2_fulfilled_count },
95 }
96 }
97 end
98 end
99 },
100 {
101 label = _"My opinion",
102 content = function(record)
103 local degree
104 local opinion = Opinion:by_pk(app.session.member.id, record.id)
105 if opinion then
106 degree = opinion.degree
107 end
108 ui.link{
109 attr = { class = "action" .. (degree == -2 and " active_red2" or "") },
110 text = _"must not",
111 module = "opinion",
112 action = "update",
113 routing = { default = { mode = "redirect", module = request.get_module(), view = request.get_view(), id = param.get_id_cgi(), params = param.get_all_cgi() } },
114 params = {
115 suggestion_id = record.id,
116 degree = -2
117 }
118 }
119 ui.link{
120 attr = { class = "action" .. (degree == -1 and " active_red1" or "") },
121 text = _"should not",
122 module = "opinion",
123 action = "update",
124 routing = { default = { mode = "redirect", module = request.get_module(), view = request.get_view(), id = param.get_id_cgi(), params = param.get_all_cgi() } },
125 params = {
126 suggestion_id = record.id,
127 degree = -1
128 }
129 }
130 ui.link{
131 attr = { class = "action" .. (degree == nil and " active" or "") },
132 text = _"neutral",
133 module = "opinion",
134 action = "update",
135 routing = { default = { mode = "redirect", module = request.get_module(), view = request.get_view(), id = param.get_id_cgi(), params = param.get_all_cgi() } },
136 params = {
137 suggestion_id = record.id,
138 delete = true
139 }
140 }
141 ui.link{
142 attr = { class = "action" .. (degree == 1 and " active_green1" or "") },
143 text = _"should",
144 module = "opinion",
145 action = "update",
146 routing = { default = { mode = "redirect", module = request.get_module(), view = request.get_view(), id = param.get_id_cgi(), params = param.get_all_cgi() } },
147 params = {
148 suggestion_id = record.id,
149 degree = 1
150 }
151 }
152 ui.link{
153 attr = { class = "action" .. (degree == 2 and " active_green2" or "") },
154 text = _"must",
155 module = "opinion",
156 action = "update",
157 routing = { default = { mode = "redirect", module = request.get_module(), view = request.get_view(), id = param.get_id_cgi(), params = param.get_all_cgi() } },
158 params = {
159 suggestion_id = record.id,
160 degree = 2
161 }
162 }
163 end
164 },
165 {
166 content = function(record)
167 local opinion = Opinion:by_pk(app.session.member.id, record.id)
168 if opinion and not opinion.fulfilled then
169 ui.image{ static = "icons/16/cross.png" }
170 end
171 end
172 },
173 {
174 label = _"Suggestion currently not implemented",
175 label_attr = { style = "width: 101px;" },
176 content = function(record)
177 if record.minus2_unfulfilled_count then
178 local max_value = record.initiative.issue.population
179 ui.bargraph{
180 max_value = max_value,
181 width = 50,
182 bars = {
183 { color = "#ddd", value = max_value - record.minus2_unfulfilled_count - record.minus1_unfulfilled_count },
184 { color = "#f88", value = record.minus1_unfulfilled_count },
185 { color = "#a00", value = record.minus2_unfulfilled_count },
186 { color = "#0a0", value = record.plus2_unfulfilled_count },
187 { color = "#8f8", value = record.plus1_unfulfilled_count },
188 { color = "#ddd", value = max_value - record.plus1_unfulfilled_count - record.plus2_unfulfilled_count },
189 }
190 }
191 end
192 end
193 },
194 {
195 content = function(record)
196 local opinion = Opinion:by_pk(app.session.member.id, record.id)
197 if opinion and opinion.fulfilled then
198 ui.image{ static = "icons/16/tick.png" }
199 end
200 end
201 },
202 {
203 label = _"Suggestion currently implemented",
204 label_attr = { style = "width: 101px;" },
205 content = function(record)
206 if record.minus2_fulfilled_count then
207 local max_value = record.initiative.issue.population
208 ui.bargraph{
209 max_value = max_value,
210 width = 50,
211 bars = {
212 { color = "#ddd", value = max_value - record.minus2_fulfilled_count - record.minus1_fulfilled_count },
213 { color = "#f88", value = record.minus1_fulfilled_count },
214 { color = "#a00", value = record.minus2_fulfilled_count },
215 { color = "#0a0", value = record.plus2_fulfilled_count },
216 { color = "#8f8", value = record.plus1_fulfilled_count },
217 { color = "#ddd", value = max_value - record.plus1_fulfilled_count - record.plus2_fulfilled_count },
218 }
219 }
220 end
221 end
222 },
223 {
224 label_attr = { style = "width: 200px;" },
225 content = function(record)
226 local degree
227 local opinion = Opinion:by_pk(app.session.member.id, record.id)
228 if opinion then
229 degree = opinion.degree
230 end
231 if opinion then
232 if not opinion.fulfilled then
233 local text = ""
234 if opinion.degree > 0 then
235 text = _"Mark suggestion as implemented and express satisfaction"
236 else
237 text = _"Mark suggestion as implemented and express dissatisfaction"
238 end
239 ui.link{
240 attr = { class = "action" },
241 text = text,
242 module = "opinion",
243 action = "update",
244 routing = { default = { mode = "redirect", module = request.get_module(), view = request.get_view(), id = param.get_id_cgi(), params = param.get_all_cgi() } },
245 params = {
246 suggestion_id = record.id,
247 fulfilled = true
248 }
249 }
250 else
251 if opinion.degree > 0 then
252 text = _"Mark suggestion as not implemented and express dissatisfaction"
253 else
254 text = _"Mark suggestion as not implemented and express satisfaction"
255 end
256 ui.link{
257 attr = { class = "action" },
258 text = text,
259 module = "opinion",
260 action = "update",
261 routing = { default = { mode = "redirect", module = request.get_module(), view = request.get_view(), id = param.get_id_cgi(), params = param.get_all_cgi() } },
262 params = {
263 suggestion_id = record.id,
264 fulfilled = false
265 }
266 }
267 end
268 end
269 end
270 },
271 {
272 content = function(record)
273 local opinion = Opinion:by_pk(app.session.member.id, record.id)
274 if opinion then
275 if (opinion.fulfilled and opinion.degree > 0) or (not opinion.fulfilled and opinion.degree < 0) then
276 ui.image{ static = "icons/16/thumb_up_green.png" }
277 else
278 ui.image{ static = "icons/16/thumb_down_red.png" }
279 end
280 end
281 end
282 },
283 }
284 }
285 end
286 }
287 end
288 }
290 if initiative then
291 ui.field.timestamp{ label = _"Last snapshot:", value = initiative.issue.snapshot }
292 end

Impressum / About Us