liquid_feedback_frontend

view app/main/suggestion/_list_element.lua @ 1062:f03fbffc1800

New layout for suggestion details view
author bsw
date Wed Jul 16 21:52:17 2014 +0200 (2014-07-16)
parents cc64a4fc6ab6
children
line source
2 local initiative = param.get("initiative", "table")
3 local suggestions_selector = param.get("suggestions_selector", "table")
5 suggestions_selector:add_order_by("plus2_unfulfilled_count + plus1_unfulfilled_count DESC, id")
7 local tab_id = param.get("tab_id")
8 local show_name = param.get("show_name", atom.boolean)
9 if show_name == nil then
10 show_name = true
11 end
12 local show_filter = param.get("show_filter", atom.boolean)
13 if show_filter == nil then
14 show_filter = true
15 end
17 local partial = {
18 routing = {
19 default = {
20 mode = "redirect",
21 module = "initiative",
22 view = "show_tab",
23 params = {
24 initiative_id = initiative.id,
25 tab = "suggestions",
26 tab_id = tab_id
27 },
28 }
29 }
30 }
32 local ui_filters = ui.filters
33 if true or not show_filter then
34 ui_filters = function(args) args.content() end
35 end
37 ui.container{ attr = { class = "box" },
38 content = function()
39 ui.paginate{
40 selector = suggestions_selector,
41 content = function()
42 ui.list{
43 attr = { style = "table-layout: fixed;" },
44 records = suggestions_selector:exec(),
45 columns = {
46 {
47 label = show_name and _"Suggestion" or nil,
48 content = function(record)
49 if show_name then
50 ui.link{
51 text = record.name,
52 module = "suggestion",
53 view = "show",
54 id = record.id
55 }
56 end
57 end
58 },
59 {
60 label = _"Collective opinion of supporters",
61 label_attr = { style = "width: 101px;" },
62 content = function(record)
63 if record.minus2_unfulfilled_count then
64 local max_value = record.initiative.supporter_count
65 ui.bargraph{
66 max_value = max_value,
67 width = 100,
68 bars = {
69 { color = "#0a0", value = record.plus2_unfulfilled_count + record.plus2_fulfilled_count },
70 { color = "#8f8", value = record.plus1_unfulfilled_count + record.plus1_fulfilled_count },
71 { color = "#eee", value = max_value - record.minus2_unfulfilled_count - record.minus1_unfulfilled_count - record.minus2_fulfilled_count - record.minus1_fulfilled_count - record.plus1_unfulfilled_count - record.plus2_unfulfilled_count - record.plus1_fulfilled_count - record.plus2_fulfilled_count},
72 { color = "#f88", value = record.minus1_unfulfilled_count + record.minus1_fulfilled_count },
73 { color = "#a00", value = record.minus2_unfulfilled_count + record.minus2_fulfilled_count },
74 }
75 }
76 end
77 end
78 },
79 {
80 label = _"Suggestion currently not implemented",
81 label_attr = { style = "width: 101px;" },
82 content = function(record)
83 if record.minus2_unfulfilled_count then
84 local max_value = record.initiative.supporter_count
85 ui.bargraph{
86 max_value = max_value,
87 width = 100,
88 bars = {
89 { color = "#0a0", value = record.plus2_unfulfilled_count },
90 { color = "#8f8", value = record.plus1_unfulfilled_count },
91 { color = "#eee", value = max_value - record.minus2_unfulfilled_count - record.minus1_unfulfilled_count - record.plus1_unfulfilled_count - record.plus2_unfulfilled_count },
92 { color = "#f88", value = record.minus1_unfulfilled_count },
93 { color = "#a00", value = record.minus2_unfulfilled_count },
94 }
95 }
96 end
97 end
98 },
99 {
100 label = _"Suggestion currently implemented",
101 label_attr = { style = "width: 101px;" },
102 content = function(record)
103 if record.minus2_fulfilled_count then
104 local max_value = record.initiative.supporter_count
105 ui.bargraph{
106 max_value = max_value,
107 width = 100,
108 bars = {
109 { color = "#0a0", value = record.plus2_fulfilled_count },
110 { color = "#8f8", value = record.plus1_fulfilled_count },
111 { color = "#eee", value = max_value - record.minus2_fulfilled_count - record.minus1_fulfilled_count - record.plus1_fulfilled_count - record.plus2_fulfilled_count},
112 { color = "#f88", value = record.minus1_fulfilled_count },
113 { color = "#a00", value = record.minus2_fulfilled_count },
114 }
115 }
116 end
117 end
118 },
119 }
120 }
121 end
122 }
123 end
124 }

Impressum / About Us