liquid_feedback_frontend

view app/main/initiative/show.lua @ 1190:9700ce0d5541

Update installation instructions regarding Moonbridge command line options; Typo in heading of installation instructions fixed
author jbe
date Sun Mar 29 20:31:32 2015 +0200 (2015-03-29)
parents 904f6807f7fa
children fede09736f2b
line source
1 local initiative = Initiative:by_id ( param.get_id() )
2 local member = app.session.member
4 if not initiative then
5 execute.view { module = "index", view = "404" }
6 request.set_status("404 Not Found")
7 return
8 end
10 local issue_info
12 if member then
13 initiative:load_everything_for_member_id(member.id)
14 initiative.issue:load_everything_for_member_id(member.id)
15 issue_info = initiative.issue.member_info
16 end
18 execute.view {
19 module = "issue", view = "_head",
20 params = {
21 issue = initiative.issue,
22 initiative = initiative,
23 member = app.session.member
24 }
25 }
27 local direct_supporter
29 if app.session.member_id then
30 direct_supporter = initiative.issue.member_info.own_participation and initiative.member_info.supported
31 end
33 ui.script { script = [[
34 function showTab(tabId) {
35 $('.tab').hide();
36 $('.main').hide();
37 $('.main, .slot_extra .section').hide();
38 $('.' + tabId).show();
39 if (tabId == "main") $('.slot_extra .section').show();
40 };
41 showTab('main');
42 ]]}
44 execute.view{ module = "issue", view = "_sidebar_state", params = {
45 initiative = initiative
46 } }
48 execute.view {
49 module = "issue", view = "_sidebar_issue",
50 params = {
51 issue = initiative.issue,
52 highlight_initiative_id = initiative.id
53 }
54 }
56 execute.view {
57 module = "issue", view = "_sidebar_whatcanido",
58 params = { initiative = initiative }
59 }
61 execute.view {
62 module = "issue", view = "_sidebar_members", params = {
63 issue = initiative.issue, initiative = initiative
64 }
65 }
67 ui.section( function ()
68 execute.view{
69 module = "initiative", view = "_head", params = {
70 initiative = initiative
71 }
72 }
74 if direct_supporter and not initiative.issue.closed then
75 local supporter = app.session.member:get_reference_selector("supporters")
76 :add_where{ "initiative_id = ?", initiative.id }
77 :optional_object_mode()
78 :exec()
80 if supporter then
82 local old_draft_id = supporter.draft_id
83 local new_draft_id = initiative.current_draft.id
85 if old_draft_id ~= new_draft_id then
86 ui.sectionRow( "draft_updated_info", function ()
87 ui.container{
88 attr = { class = "info" },
89 content = _"The draft of this initiative has been updated!"
90 }
91 slot.put(" ")
92 ui.link{
93 content = _"show differences",
94 module = "draft",
95 view = "diff",
96 params = {
97 old_draft_id = old_draft_id,
98 new_draft_id = new_draft_id
99 }
100 }
101 if not initiative.revoked then
102 slot.put(" | ")
103 ui.link{
104 text = _"refresh my support",
105 module = "initiative",
106 action = "add_support",
107 id = initiative.id,
108 params = { draft_id = initiative.current_draft.id },
109 routing = {
110 default = {
111 mode = "redirect",
112 module = "initiative",
113 view = "show",
114 id = initiative.id
115 }
116 }
117 }
118 slot.put(" | ")
119 end
121 ui.link{
122 text = _"remove my support",
123 module = "initiative",
124 action = "remove_support",
125 id = initiative.id,
126 routing = {
127 default = {
128 mode = "redirect",
129 module = "initiative",
130 view = "show",
131 id = initiative.id
132 }
133 }
134 }
136 end )
137 end
138 end
139 end
142 ui.sectionRow( function ()
143 ui.container {
144 attr = { class = "draft" },
145 content = function ()
146 slot.put ( initiative.current_draft:get_content ( "html" ) )
147 end
148 }
149 end )
151 end)
153 ui.link { attr = { name = "suggestions" }, text = "" }
156 ui.container {
157 attr = { class = "section suggestions" },
158 content = function ()
160 if # ( initiative.suggestions ) > 0 then
162 ui.sectionHead( function ()
163 ui.heading {
164 level = 1,
165 content = _("Suggestions for improvement (#{count})", { count = # ( initiative.suggestions ) } )
166 }
167 ui.container { content = _"written and rated by the supportes of this initiative to improve the proposal and its reasons" }
168 end )
170 for i, suggestion in ipairs(initiative.suggestions) do
172 local opinion = Opinion:by_pk(app.session.member_id, suggestion.id)
174 local class = "sectionRow suggestion"
175 if suggestion.id == param.get("suggestion_id", atom.number) then
176 class = class .. " highlighted"
177 end
178 if member and not initiative.issue.fully_frozen and not initiative.issue.closed and initiative.member_info.supported then
179 class = class .. " rateable"
180 end
183 ui.tag { tag = "div", attr = { class = class, id = "s" .. suggestion.id }, content = function ()
185 if opinion then
187 ui.container { attr = { class = "opinion"}, content = function()
188 local class = ""
189 local text = ""
191 if opinion.degree == 2 then
192 class = "must"
193 text = _"must"
194 elseif opinion.degree == 1 then
195 class = "should"
196 text = _"should"
197 elseif opinion.degree == 0 then
198 class = "neutral"
199 text = _"neutral"
200 elseif opinion.degree == -1 then
201 class = "shouldnot"
202 text = _"should not"
203 elseif opinion.degree == -2 then
204 class = "mustnot"
205 text = _"must not"
206 end
208 ui.tag {
209 attr = { class = class },
210 content = text
211 }
213 slot.put ( " " )
215 if
216 (opinion.degree > 0 and not opinion.fulfilled)
217 or (opinion.degree < 0 and opinion.fulfilled)
218 then
219 ui.tag{ content = _"but" }
220 else
221 ui.tag{ content = _"and" }
222 end
224 slot.put ( " " )
226 local class = ""
227 local text = ""
229 if opinion.fulfilled then
230 class = "implemented"
231 text = _"is implemented"
232 else
233 class = "notimplemented"
234 text = _"is not implemented"
235 end
237 ui.tag {
238 attr = { class = class },
239 content = text
240 }
242 if
243 (opinion.degree > 0 and not opinion.fulfilled)
244 or (opinion.degree < 0 and opinion.fulfilled)
245 then
246 if math.abs(opinion.degree) > 1 then
247 slot.put(" !!")
248 else
249 slot.put(" !")
250 end
251 else
252 slot.put(" ✓")
253 end
255 end }
257 end
260 ui.link { attr = { name = "s" .. suggestion.id }, text = "" }
261 ui.heading { level = 2,
262 attr = { class = "suggestionHead" },
263 content = format.string(suggestion.name, {
264 truncate_at = 160, truncate_suffix = true
265 }) }
268 local plus2 = (suggestion.plus2_unfulfilled_count or 0)
269 + (suggestion.plus2_fulfilled_count or 0)
270 local plus1 = (suggestion.plus1_unfulfilled_count or 0)
271 + (suggestion.plus1_fulfilled_count or 0)
272 local minus1 = (suggestion.minus1_unfulfilled_count or 0)
273 + (suggestion.minus1_fulfilled_count or 0)
274 local minus2 = (suggestion.minus2_unfulfilled_count or 0)
275 + (suggestion.minus2_fulfilled_count or 0)
277 local with_opinion = plus2 + plus1 + minus1 + minus2
279 local neutral = (suggestion.initiative.supporter_count or 0)
280 - with_opinion
282 local neutral2 = with_opinion
283 - (suggestion.plus2_fulfilled_count or 0)
284 - (suggestion.plus1_fulfilled_count or 0)
285 - (suggestion.minus1_fulfilled_count or 0)
286 - (suggestion.minus2_fulfilled_count or 0)
288 ui.container {
289 attr = { class = "suggestionInfo" },
290 content = function ()
292 if with_opinion > 0 then
293 ui.container { attr = { class = "suggestion-rating" }, content = function ()
294 ui.tag { content = _"collective rating:" }
295 slot.put("&nbsp;")
296 ui.bargraph{
297 max_value = suggestion.initiative.supporter_count,
298 width = 100,
299 bars = {
300 { color = "#0a0", value = plus2 },
301 { color = "#8a8", value = plus1 },
302 { color = "#eee", value = neutral },
303 { color = "#a88", value = minus1 },
304 { color = "#a00", value = minus2 },
305 }
306 }
307 slot.put(" | ")
308 ui.tag { content = _"implemented:" }
309 slot.put ( "&nbsp;" )
310 ui.bargraph{
311 max_value = with_opinion,
312 width = 100,
313 bars = {
314 { color = "#0a0", value = suggestion.plus2_fulfilled_count },
315 { color = "#8a8", value = suggestion.plus1_fulfilled_count },
316 { color = "#eee", value = neutral2 },
317 { color = "#a88", value = suggestion.minus1_fulfilled_count },
318 { color = "#a00", value = suggestion.minus2_fulfilled_count },
319 }
320 }
321 end }
322 end
324 if app.session:has_access("authors_pseudonymous") then
325 util.micro_avatar ( suggestion.author )
326 else
327 slot.put("<br />")
328 end
330 ui.container {
331 attr = { class = "suggestion-text" },
332 content = function ()
333 slot.put ( suggestion:get_content( "html" ) )
336 if direct_supporter then
338 ui.container {
339 attr = { class = "rating" },
340 content = function ()
342 if not opinion then
343 opinion = {}
344 end
345 ui.form {
346 module = "opinion", action = "update", params = {
347 suggestion_id = suggestion.id
348 },
349 routing = { default = {
350 mode = "redirect",
351 module = "initiative", view = "show", id = suggestion.initiative_id,
352 params = { suggestion_id = suggestion.id },
353 anchor = "s" .. suggestion.id -- TODO webmcp
354 } },
355 content = function ()
358 ui.heading { level = 3, content = _"Should the initiator implement this suggestion?" }
359 ui.container { content = function ()
361 local active = opinion.degree == 2
362 ui.tag { tag = "input", attr = {
363 type = "radio", name = "degree", value = 2,
364 id = "s" .. suggestion.id .. "_degree2",
365 checked = active and "checked" or nil
366 } }
367 ui.tag {
368 tag = "label",
369 attr = {
370 ["for"] = "s" .. suggestion.id .. "_degree2",
371 class = active and "active-plus2" or nil,
372 },
373 content = _"must"
374 }
376 local active = opinion.degree == 1
377 ui.tag { tag = "input", attr = {
378 type = "radio", name = "degree", value = 1,
379 id = "s" .. suggestion.id .. "_degree1",
380 checked = active and "checked" or nil
381 } }
382 ui.tag {
383 tag = "label",
384 attr = {
385 ["for"] = "s" .. suggestion.id .. "_degree1",
386 class = active and "active-plus1" or nil,
387 },
388 content = _"should"
389 }
391 local active = not opinion.member_id
392 ui.tag { tag = "input", attr = {
393 type = "radio", name = "degree", value = 0,
394 id = "s" .. suggestion.id .. "_degree0",
395 checked = active and "checked" or nil
396 } }
397 ui.tag {
398 tag = "label",
399 attr = {
400 ["for"] = "s" .. suggestion.id .. "_degree0",
401 class = active and "active-neutral" or nil,
402 },
403 content = _"neutral"
404 }
406 local active = opinion.degree == -1
407 ui.tag { tag = "input", attr = {
408 type = "radio", name = "degree", value = -1,
409 id = "s" .. suggestion.id .. "_degree-1",
410 checked = active and "checked" or nil
411 } }
412 ui.tag {
413 tag = "label",
414 attr = {
415 ["for"] = "s" .. suggestion.id .. "_degree-1",
416 class = active and "active-minus1" or nil,
417 },
418 content = _"should not"
419 }
421 local active = opinion.degree == -2
422 ui.tag { tag = "input", attr = {
423 type = "radio", name = "degree", value = -2,
424 id = "s" .. suggestion.id .. "_degree-2",
425 checked = active and "checked" or nil
426 } }
427 ui.tag {
428 tag = "label",
429 attr = {
430 ["for"] = "s" .. suggestion.id .. "_degree-2",
431 class = active and "active-minus2" or nil,
432 },
433 content = _"must not"
434 }
435 end }
437 slot.put("<br />")
439 ui.heading { level = 3, content = _"Did the initiator implement this suggestion?" }
440 ui.container { content = function ()
441 local active = opinion.fulfilled == false
442 ui.tag { tag = "input", attr = {
443 type = "radio", name = "fulfilled", value = "false",
444 id = "s" .. suggestion.id .. "_notfulfilled",
445 checked = active and "checked" or nil
446 } }
447 ui.tag {
448 tag = "label",
449 attr = {
450 ["for"] = "s" .. suggestion.id .. "_notfulfilled",
451 class = active and "active-notfulfilled" or nil,
452 },
453 content = _"No (not yet)"
454 }
456 local active = opinion.fulfilled
457 ui.tag { tag = "input", attr = {
458 type = "radio", name = "fulfilled", value = "true",
459 id = "s" .. suggestion.id .. "_fulfilled",
460 checked = active and "checked" or nil
461 } }
462 ui.tag {
463 tag = "label",
464 attr = {
465 ["for"] = "s" .. suggestion.id .. "_fulfilled",
466 class = active and "active-fulfilled" or nil,
467 },
468 content = _"Yes, it's implemented"
469 }
470 end }
471 slot.put("<br />")
473 ui.tag{
474 tag = "input",
475 attr = {
476 type = "submit",
477 class = "btn btn-default",
478 value = _"publish my rating"
479 },
480 content = ""
481 }
483 end
484 }
486 end -- if not issue,fully_frozen or closed
487 }
488 end
490 local text = _"Read more"
492 if direct_supporter then
493 text = _"Show more and rate this"
494 end
496 ui.link{
497 attr = { class = "suggestion-details" },
498 content = _"Details",
499 module = "suggestion", view = "show", id = suggestion.id
500 }
502 ui.link {
503 attr = {
504 class = "suggestion-more",
505 onclick = "$('#s" .. suggestion.id .. "').removeClass('folded').addClass('unfolded'); return false;"
506 },
507 text = text
508 }
510 ui.link {
511 attr = {
512 class = "suggestion-less",
513 onclick = "$('#s" .. suggestion.id .. "').addClass('folded').removeClass('unfolded'); return false;"
514 },
515 text = _"Show less"
516 }
517 end
518 }
520 ui.script{ script = [[
521 var textEl = $('#s]] .. suggestion.id .. [[ .suggestion-text');
522 var height = textEl.height();
523 if (height > 150) $('#s]] .. suggestion.id .. [[').addClass('folded');
524 ]] }
526 end
527 } -- ui.paragraph
531 end } -- ui.tag "li"
533 end -- for i, suggestion
535 else -- if #initiative.suggestions > 0
537 local text
538 if initiative.issue.closed then
539 text = _"No suggestions"
540 else
541 text = _"No suggestions yet"
542 end
543 ui.sectionHead( function()
544 ui.heading { level = 1, content = text }
545 end)
547 end -- if #initiative.suggestions > 0
549 end
550 }

Impressum / About Us