liquid_feedback_frontend

view app/main/issue/_list.lua @ 8:374bbc2ff102

Version beta4

Bug fixed, which made it impossible to explicitly become interested in a topic

Fixed positioning of dialog for entering a new suggestion

Display of 404 pages
author bsw
date Sat Jan 02 12:00:00 2010 +0100 (2010-01-02)
parents 8d91bccab0bf
children 72c5e0ee7c98
line source
1 local issues_selector = param.get("issues_selector", "table")
3 local ui_filter = ui.filter
4 if param.get("filter", atom.boolean) == false then
5 ui_filter = function(args) args.content() end
6 end
8 local filter_voting = false
9 ui_filter{
10 selector = issues_selector,
11 filters = {
12 {
13 type = "boolean",
14 name = "open",
15 label = _"Open",
16 selector_modifier = function(selector, value)
17 if value then
18 selector:add_where("issue.closed ISNULL")
19 end
20 end
21 },
22 {
23 type = "boolean",
24 name = "new",
25 label = _"New",
26 selector_modifier = function(selector, value)
27 if value then
28 selector:add_where("issue.accepted ISNULL AND issue.closed ISNULL")
29 end
30 end
31 },
32 {
33 type = "boolean",
34 name = "accepted",
35 label = _"In discussion",
36 selector_modifier = function(selector, value)
37 if value then
38 selector:add_where("issue.accepted NOTNULL AND issue.half_frozen ISNULL AND issue.closed ISNULL")
39 end
40 end
41 },
42 {
43 type = "boolean",
44 name = "half_frozen",
45 label = _"Frozen",
46 selector_modifier = function(selector, value)
47 if value then
48 selector:add_where("issue.half_frozen NOTNULL AND issue.fully_frozen ISNULL")
49 end
50 end
51 },
52 {
53 type = "boolean",
54 name = "frozen",
55 label = _"Voting",
56 selector_modifier = function(selector, value)
57 if value then
58 selector:add_where("issue.fully_frozen NOTNULL AND issue.closed ISNULL")
59 filter_voting = true
60 end
61 end
62 },
63 {
64 type = "boolean",
65 name = "finished",
66 label = _"Finished",
67 selector_modifier = function(selector, value)
68 if value then
69 selector:add_where("issue.closed NOTNULL AND issue.fully_frozen NOTNULL")
70 end
71 end
72 },
73 {
74 type = "boolean",
75 name = "cancelled",
76 label = _"Cancelled",
77 selector_modifier = function(selector, value)
78 if value then
79 selector:add_where("issue.closed NOTNULL AND issue.accepted ISNULL")
80 end
81 end
82 },
83 },
84 content = function()
85 local ui_filter = ui.filter
86 if not filter_voting then
87 ui_filter = function(args) args.content() end
88 end
89 ui_filter{
90 selector = issues_selector,
91 name = "filter_voting",
92 filters = {
93 {
94 type = "boolean",
95 name = "any",
96 label = _"Any",
97 selector_modifier = function() end
98 },
99 {
100 type = "boolean",
101 name = "not_voted",
102 label = _"Not voted",
103 selector_modifier = function(selector, value)
104 if value then
105 selector:left_join("direct_voter", nil, { "direct_voter.issue_id = issue.id AND direct_voter.member_id = ?", app.session.member.id })
106 selector:add_where("direct_voter.member_id ISNULL")
107 end
108 end
109 },
110 {
111 type = "boolean",
112 name = "voted",
113 label = _"Voted",
114 selector_modifier = function(selector, value)
115 if value then
116 selector:join("direct_voter", nil, { "direct_voter.issue_id = issue.id AND direct_voter.member_id = ?", app.session.member.id })
117 end
118 end
119 },
120 },
121 content = function()
122 local ui_filter = ui.filter
123 if param.get("filter", atom.boolean) == false then
124 ui_filter = function(args) args.content() end
125 end
126 ui_filter{
127 selector = issues_selector,
128 name = "filter_interest",
129 filters = {
130 {
131 type = "boolean",
132 name = "any",
133 label = _"Any",
134 selector_modifier = function() end
135 },
136 {
137 type = "boolean",
138 name = "my",
139 label = _"Interested",
140 selector_modifier = function(selector, value)
141 if value then
142 selector:join("interest", "filter_interest", { "filter_interest.issue_id = issue.id AND filter_interest.member_id = ? ", app.session.member.id })
143 end
144 end
145 },
146 },
147 content = function()
149 ui.order{
150 name = "issue_list",
151 selector = issues_selector,
152 options = {
153 {
154 name = "max_potential_support",
155 label = _"Max potential support",
156 selector_modifier = function(selector)
157 selector:add_order_by("(SELECT max(supporter_count) FROM initiative WHERE initiative.issue_id = issue.id) DESC")
158 end
159 },
160 {
161 name = "max_support",
162 label = _"Max support",
163 selector_modifier = function(selector)
164 selector:add_order_by("(SELECT max(satisfied_supporter_count) FROM initiative WHERE initiative.issue_id = issue.id) DESC")
165 end
166 },
167 {
168 name = "population",
169 label = _"Population",
170 order_by = "issue.population DESC"
171 },
172 {
173 name = "newest",
174 label = _"Newest",
175 order_by = "issue.created DESC"
176 },
177 {
178 name = "oldest",
179 label = _"Oldest",
180 order_by = "issue.created"
181 }
182 },
183 content = function()
184 ui.paginate{
185 selector = issues_selector,
186 content = function()
187 local highlight_string = param.get("highlight_string", "string")
188 local issues = issues or issues_selector:exec()
189 -- issues:load(initiatives)
190 ui.list{
191 attr = { class = "issues" },
192 records = issues,
193 columns = {
194 {
195 label = _"Issue",
196 content = function(record)
197 if not param.get("for_area_list", atom.boolean) then
198 ui.field.text{
199 value = record.area.name
200 }
201 slot.put("<br />")
202 end
203 ui.link{
204 text = _"Issue ##{id}":gsub("#{id}", tostring(record.id)),
205 module = "issue",
206 view = "show",
207 id = record.id
208 }
209 if record.state == "new" then
210 ui.image{
211 static = "icons/16/new.png"
212 }
213 end
214 slot.put("<br />")
215 slot.put("<br />")
216 end
217 },
218 {
219 label = _"State",
220 content = function(record)
221 if record.state == "voting" then
222 ui.link{
223 content = _"Voting",
224 module = "vote",
225 view = "list",
226 params = { issue_id = record.id }
227 }
228 else
229 ui.field.issue_state{ value = record.state }
230 end
231 end
232 },
233 {
234 label = _"Initiatives",
235 content = function(record)
236 local initiatives_selector = record:get_reference_selector("initiatives")
237 local highlight_string = param.get("highlight_string")
238 if highlight_string then
239 initiatives_selector:add_field( {'"highlight"("initiative"."name", ?)', highlight_string }, "name_highlighted")
240 end
241 execute.view{
242 module = "initiative",
243 view = "_list",
244 params = {
245 issue = record,
246 initiatives_selector = initiatives_selector,
247 highlight_string = highlight_string,
248 limit = 3
249 }
250 }
251 end
252 },
253 }
254 }
255 end
256 }
257 end
258 }
259 end
260 }
261 end
262 }
263 if param.get("legend", atom.boolean) ~= false then
264 local filter = param.get_all_cgi().filter
265 if not filter or filter == "any" or filter ~= "finished" then
266 ui.bargraph_legend{
267 width = 25,
268 bars = {
269 { color = "#0a0", label = _"Supporter" },
270 { color = "#777", label = _"Potential supporter" },
271 { color = "#ddd", label = _"No support at all" },
272 }
273 }
274 end
275 if not filter or filter == "any" or filter == "finished" then
276 ui.bargraph_legend{
277 width = 25,
278 bars = {
279 { color = "#0a0", label = _"Yes" },
280 { color = "#aaa", label = _"Abstention" },
281 { color = "#a00", label = _"No" },
282 }
283 }
284 end
285 end
286 end
287 }

Impressum / About Us