liquid_feedback_frontend
view app/main/suggestion/_list.lua @ 3:768faea1096d
Version alpha4
Members interested in an issue or supporting an initiative have a weight information attached. Browsing the members causing that weight is possible.
Initiatives may provide a link to an external discussion platform
Direct link on every initiative page to create an alternative initiative
Bugfix: No error when clicking "neutral", when "neutral" is currently selected
Members interested in an issue or supporting an initiative have a weight information attached. Browsing the members causing that weight is possible.
Initiatives may provide a link to an external discussion platform
Direct link on every initiative page to create an alternative initiative
Bugfix: No error when clicking "neutral", when "neutral" is currently selected
| author | bsw |
|---|---|
| date | Mon Nov 30 12:00:00 2009 +0100 (2009-11-30) |
| parents | 5c601807d397 |
| children | 80c215dbf076 |
line source
1 local suggestions_selector = param.get("suggestions_selector", "table")
3 ui.paginate{
4 selector = suggestions_selector,
5 content = function()
6 ui.list{
7 attr = { style = "table-layout: fixed;" },
8 records = suggestions_selector:exec(),
9 columns = {
10 {
11 label = _"Suggestion",
12 content = function(record)
13 ui.link{
14 text = record.name,
15 module = "suggestion",
16 view = "show",
17 id = record.id
18 }
19 end
20 },
21 {
22 label = _"Collective opinion",
23 label_attr = { style = "width: 101px;" },
24 content = function(record)
25 if record.minus2_unfulfilled_count then
26 local max_value = record.initiative.issue.population
27 ui.bargraph{
28 max_value = max_value,
29 width = 100,
30 bars = {
31 { color = "#ddd", value = max_value - record.minus2_unfulfilled_count - record.minus1_unfulfilled_count - record.minus2_fulfilled_count - record.minus1_fulfilled_count },
32 { color = "#f88", value = record.minus1_unfulfilled_count + record.minus1_fulfilled_count },
33 { color = "#a00", value = record.minus2_unfulfilled_count + record.minus2_fulfilled_count },
34 { color = "#0a0", value = record.plus2_unfulfilled_count + record.plus2_fulfilled_count },
35 { color = "#8f8", value = record.plus1_unfulfilled_count + record.plus1_fulfilled_count },
36 { color = "#ddd", value = max_value - record.plus1_unfulfilled_count - record.plus2_unfulfilled_count - record.plus1_fulfilled_count - record.plus2_fulfilled_count },
37 }
38 }
39 end
40 end
41 },
42 {
43 label = _"My opinion",
44 content = function(record)
45 local degree
46 local opinion = Opinion:by_pk(app.session.member.id, record.id)
47 if opinion then
48 degree = opinion.degree
49 end
50 ui.link{
51 attr = { class = "action" .. (degree == -2 and " active_red2" or "") },
52 text = _"must not",
53 module = "opinion",
54 action = "update",
55 routing = { default = { mode = "redirect", module = request.get_module(), view = request.get_view(), id = param.get_id_cgi(), params = param.get_all_cgi() } },
56 params = {
57 suggestion_id = record.id,
58 degree = -2
59 }
60 }
61 ui.link{
62 attr = { class = "action" .. (degree == -1 and " active_red1" or "") },
63 text = _"should not",
64 module = "opinion",
65 action = "update",
66 routing = { default = { mode = "redirect", module = request.get_module(), view = request.get_view(), id = param.get_id_cgi(), params = param.get_all_cgi() } },
67 params = {
68 suggestion_id = record.id,
69 degree = -1
70 }
71 }
72 ui.link{
73 attr = { class = "action" .. (degree == nil and " active" or "") },
74 text = _"neutral",
75 module = "opinion",
76 action = "update",
77 routing = { default = { mode = "redirect", module = request.get_module(), view = request.get_view(), id = param.get_id_cgi(), params = param.get_all_cgi() } },
78 params = {
79 suggestion_id = record.id,
80 delete = true
81 }
82 }
83 ui.link{
84 attr = { class = "action" .. (degree == 1 and " active_green1" or "") },
85 text = _"should",
86 module = "opinion",
87 action = "update",
88 routing = { default = { mode = "redirect", module = request.get_module(), view = request.get_view(), id = param.get_id_cgi(), params = param.get_all_cgi() } },
89 params = {
90 suggestion_id = record.id,
91 degree = 1
92 }
93 }
94 ui.link{
95 attr = { class = "action" .. (degree == 2 and " active_green2" or "") },
96 text = _"must",
97 module = "opinion",
98 action = "update",
99 routing = { default = { mode = "redirect", module = request.get_module(), view = request.get_view(), id = param.get_id_cgi(), params = param.get_all_cgi() } },
100 params = {
101 suggestion_id = record.id,
102 degree = 2
103 }
104 }
105 end
106 },
107 {
108 content = function(record)
109 local opinion = Opinion:by_pk(app.session.member.id, record.id)
110 if opinion and not opinion.fulfilled then
111 ui.image{ static = "icons/16/cross.png" }
112 end
113 end
114 },
115 {
116 label = _"Suggestion currently not implemented",
117 label_attr = { style = "width: 101px;" },
118 content = function(record)
119 if record.minus2_unfulfilled_count then
120 local max_value = record.initiative.issue.population
121 ui.bargraph{
122 max_value = max_value,
123 width = 100,
124 bars = {
125 { color = "#ddd", value = max_value - record.minus2_unfulfilled_count - record.minus1_unfulfilled_count },
126 { color = "#f88", value = record.minus1_unfulfilled_count },
127 { color = "#a00", value = record.minus2_unfulfilled_count },
128 { color = "#0a0", value = record.plus2_unfulfilled_count },
129 { color = "#8f8", value = record.plus1_unfulfilled_count },
130 { color = "#ddd", value = max_value - record.plus1_unfulfilled_count - record.plus2_unfulfilled_count },
131 }
132 }
133 end
134 end
135 },
136 {
137 content = function(record)
138 local opinion = Opinion:by_pk(app.session.member.id, record.id)
139 if opinion and opinion.fulfilled then
140 ui.image{ static = "icons/16/tick.png" }
141 end
142 end
143 },
144 {
145 label = _"Suggestion currently implemented",
146 label_attr = { style = "width: 101px;" },
147 content = function(record)
148 if record.minus2_fulfilled_count then
149 local max_value = record.initiative.issue.population
150 ui.bargraph{
151 max_value = max_value,
152 width = 100,
153 bars = {
154 { color = "#ddd", value = max_value - record.minus2_fulfilled_count - record.minus1_fulfilled_count },
155 { color = "#f88", value = record.minus1_fulfilled_count },
156 { color = "#a00", value = record.minus2_fulfilled_count },
157 { color = "#0a0", value = record.plus2_fulfilled_count },
158 { color = "#8f8", value = record.plus1_fulfilled_count },
159 { color = "#ddd", value = max_value - record.plus1_fulfilled_count - record.plus2_fulfilled_count },
160 }
161 }
162 end
163 end
164 },
165 {
166 label_attr = { style = "width: 200px;" },
167 content = function(record)
168 local degree
169 local opinion = Opinion:by_pk(app.session.member.id, record.id)
170 if opinion then
171 degree = opinion.degree
172 end
173 if opinion then
174 if not opinion.fulfilled then
175 local text = ""
176 if opinion.degree > 0 then
177 text = _"Mark suggestion as implemented and express satisfaction"
178 else
179 text = _"Mark suggestion as implemented and express dissatisfaction"
180 end
181 ui.link{
182 attr = { class = "action" },
183 text = text,
184 module = "opinion",
185 action = "update",
186 routing = { default = { mode = "redirect", module = request.get_module(), view = request.get_view(), id = param.get_id_cgi(), params = param.get_all_cgi() } },
187 params = {
188 suggestion_id = record.id,
189 fulfilled = true
190 }
191 }
192 else
193 if opinion.degree > 0 then
194 text = _"Mark suggestion as not implemented and express dissatisfaction"
195 else
196 text = _"Mark suggestion as not implemented and express satisfaction"
197 end
198 ui.link{
199 attr = { class = "action" },
200 text = text,
201 module = "opinion",
202 action = "update",
203 routing = { default = { mode = "redirect", module = request.get_module(), view = request.get_view(), id = param.get_id_cgi(), params = param.get_all_cgi() } },
204 params = {
205 suggestion_id = record.id,
206 fulfilled = false
207 }
208 }
209 end
210 end
211 end
212 },
213 {
214 content = function(record)
215 local opinion = Opinion:by_pk(app.session.member.id, record.id)
216 if opinion then
217 if (opinion.fulfilled and opinion.degree > 0) or (not opinion.fulfilled and opinion.degree < 0) then
218 ui.image{ static = "icons/16/thumb_up_green.png" }
219 else
220 ui.image{ static = "icons/16/thumb_down_red.png" }
221 end
222 end
223 end
224 },
225 }
226 }
227 end
228 }
