rev |
line source |
bsw/jbe@0
|
1 local issues_selector = param.get("issues_selector", "table")
|
bsw/jbe@0
|
2
|
bsw@11
|
3 issues_selector
|
bsw@11
|
4 :left_join("interest", "_interest", { "_interest.issue_id = issue.id AND _interest.member_id = ?", app.session.member.id} )
|
bsw@11
|
5 :add_field("(_interest.member_id NOTNULL)", "is_interested")
|
bsw@11
|
6
|
bsw/jbe@5
|
7 local ui_filter = ui.filter
|
bsw/jbe@5
|
8 if param.get("filter", atom.boolean) == false then
|
bsw/jbe@5
|
9 ui_filter = function(args) args.content() end
|
bsw/jbe@5
|
10 end
|
bsw/jbe@0
|
11
|
bsw@10
|
12 if param.get("no_filter", atom.boolean) then
|
bsw@10
|
13 ui_filter = function(args) args.content() end
|
bsw@10
|
14 end
|
bsw@10
|
15
|
bsw/jbe@5
|
16 local filter_voting = false
|
bsw/jbe@5
|
17 ui_filter{
|
bsw/jbe@0
|
18 selector = issues_selector,
|
bsw@2
|
19 filters = {
|
bsw@2
|
20 {
|
bsw@2
|
21 type = "boolean",
|
bsw/jbe@6
|
22 name = "open",
|
bsw/jbe@6
|
23 label = _"Open",
|
bsw/jbe@6
|
24 selector_modifier = function(selector, value)
|
bsw/jbe@6
|
25 if value then
|
bsw/jbe@6
|
26 selector:add_where("issue.closed ISNULL")
|
bsw/jbe@6
|
27 end
|
bsw/jbe@6
|
28 end
|
bsw@2
|
29 },
|
bsw/jbe@0
|
30 {
|
bsw@2
|
31 type = "boolean",
|
bsw@2
|
32 name = "new",
|
bsw@2
|
33 label = _"New",
|
bsw@2
|
34 selector_modifier = function(selector, value)
|
bsw@2
|
35 if value then
|
bsw@2
|
36 selector:add_where("issue.accepted ISNULL AND issue.closed ISNULL")
|
bsw@2
|
37 end
|
bsw@2
|
38 end
|
bsw@2
|
39 },
|
bsw@2
|
40 {
|
bsw@2
|
41 type = "boolean",
|
bsw@2
|
42 name = "accepted",
|
bsw@2
|
43 label = _"In discussion",
|
bsw@2
|
44 selector_modifier = function(selector, value)
|
bsw@2
|
45 if value then
|
bsw@2
|
46 selector:add_where("issue.accepted NOTNULL AND issue.half_frozen ISNULL AND issue.closed ISNULL")
|
bsw@2
|
47 end
|
bsw@2
|
48 end
|
bsw/jbe@0
|
49 },
|
bsw/jbe@0
|
50 {
|
bsw@2
|
51 type = "boolean",
|
bsw@2
|
52 name = "half_frozen",
|
bsw@2
|
53 label = _"Frozen",
|
bsw@2
|
54 selector_modifier = function(selector, value)
|
bsw@2
|
55 if value then
|
bsw/jbe@5
|
56 selector:add_where("issue.half_frozen NOTNULL AND issue.fully_frozen ISNULL")
|
bsw@2
|
57 end
|
bsw@2
|
58 end
|
bsw@2
|
59 },
|
bsw@2
|
60 {
|
bsw@2
|
61 type = "boolean",
|
bsw@2
|
62 name = "frozen",
|
bsw@2
|
63 label = _"Voting",
|
bsw@2
|
64 selector_modifier = function(selector, value)
|
bsw@2
|
65 if value then
|
bsw@2
|
66 selector:add_where("issue.fully_frozen NOTNULL AND issue.closed ISNULL")
|
bsw/jbe@5
|
67 filter_voting = true
|
bsw@2
|
68 end
|
bsw@2
|
69 end
|
bsw/jbe@0
|
70 },
|
bsw/jbe@0
|
71 {
|
bsw@2
|
72 type = "boolean",
|
bsw@2
|
73 name = "finished",
|
bsw@2
|
74 label = _"Finished",
|
bsw@2
|
75 selector_modifier = function(selector, value)
|
bsw@2
|
76 if value then
|
bsw/jbe@5
|
77 selector:add_where("issue.closed NOTNULL AND issue.fully_frozen NOTNULL")
|
bsw@2
|
78 end
|
bsw@2
|
79 end
|
bsw@2
|
80 },
|
bsw@2
|
81 {
|
bsw@2
|
82 type = "boolean",
|
bsw@2
|
83 name = "cancelled",
|
bsw@2
|
84 label = _"Cancelled",
|
bsw@2
|
85 selector_modifier = function(selector, value)
|
bsw@2
|
86 if value then
|
bsw/jbe@5
|
87 selector:add_where("issue.closed NOTNULL AND issue.accepted ISNULL")
|
bsw@2
|
88 end
|
bsw@2
|
89 end
|
bsw@2
|
90 },
|
bsw/jbe@0
|
91 },
|
bsw/jbe@0
|
92 content = function()
|
bsw/jbe@5
|
93 local ui_filter = ui.filter
|
bsw/jbe@5
|
94 if not filter_voting then
|
bsw/jbe@5
|
95 ui_filter = function(args) args.content() end
|
bsw/jbe@5
|
96 end
|
bsw@10
|
97 if param.get("no_filter", atom.boolean) then
|
bsw@10
|
98 ui_filter = function(args) args.content() end
|
bsw@10
|
99 end
|
bsw/jbe@5
|
100 ui_filter{
|
bsw/jbe@0
|
101 selector = issues_selector,
|
bsw/jbe@5
|
102 name = "filter_voting",
|
bsw/jbe@5
|
103 filters = {
|
bsw@2
|
104 {
|
bsw/jbe@5
|
105 type = "boolean",
|
bsw/jbe@5
|
106 name = "any",
|
bsw/jbe@5
|
107 label = _"Any",
|
bsw/jbe@5
|
108 selector_modifier = function() end
|
bsw@2
|
109 },
|
bsw@2
|
110 {
|
bsw/jbe@5
|
111 type = "boolean",
|
bsw/jbe@5
|
112 name = "not_voted",
|
bsw/jbe@5
|
113 label = _"Not voted",
|
bsw/jbe@5
|
114 selector_modifier = function(selector, value)
|
bsw/jbe@5
|
115 if value then
|
bsw/jbe@5
|
116 selector:left_join("direct_voter", nil, { "direct_voter.issue_id = issue.id AND direct_voter.member_id = ?", app.session.member.id })
|
bsw/jbe@5
|
117 selector:add_where("direct_voter.member_id ISNULL")
|
bsw/jbe@5
|
118 end
|
bsw/jbe@5
|
119 end
|
bsw@2
|
120 },
|
bsw@2
|
121 {
|
bsw/jbe@5
|
122 type = "boolean",
|
bsw/jbe@5
|
123 name = "voted",
|
bsw/jbe@5
|
124 label = _"Voted",
|
bsw/jbe@5
|
125 selector_modifier = function(selector, value)
|
bsw/jbe@5
|
126 if value then
|
bsw/jbe@5
|
127 selector:join("direct_voter", nil, { "direct_voter.issue_id = issue.id AND direct_voter.member_id = ?", app.session.member.id })
|
bsw/jbe@5
|
128 end
|
bsw/jbe@5
|
129 end
|
bsw/jbe@5
|
130 },
|
bsw@2
|
131 },
|
bsw/jbe@0
|
132 content = function()
|
bsw/jbe@5
|
133 local ui_filter = ui.filter
|
bsw/jbe@5
|
134 if param.get("filter", atom.boolean) == false then
|
bsw/jbe@5
|
135 ui_filter = function(args) args.content() end
|
bsw/jbe@5
|
136 end
|
bsw/jbe@5
|
137 ui_filter{
|
bsw@2
|
138 selector = issues_selector,
|
bsw/jbe@5
|
139 name = "filter_interest",
|
bsw/jbe@5
|
140 filters = {
|
bsw/jbe@5
|
141 {
|
bsw/jbe@5
|
142 type = "boolean",
|
bsw/jbe@5
|
143 name = "any",
|
bsw/jbe@5
|
144 label = _"Any",
|
bsw/jbe@5
|
145 selector_modifier = function() end
|
bsw/jbe@5
|
146 },
|
bsw/jbe@5
|
147 {
|
bsw/jbe@5
|
148 type = "boolean",
|
bsw/jbe@5
|
149 name = "my",
|
bsw/jbe@5
|
150 label = _"Interested",
|
bsw/jbe@5
|
151 selector_modifier = function(selector, value)
|
bsw/jbe@5
|
152 if value then
|
bsw/jbe@5
|
153 selector:join("interest", "filter_interest", { "filter_interest.issue_id = issue.id AND filter_interest.member_id = ? ", app.session.member.id })
|
bsw/jbe@5
|
154 end
|
bsw/jbe@5
|
155 end
|
bsw/jbe@5
|
156 },
|
bsw@11
|
157 {
|
bsw@11
|
158 type = "boolean",
|
bsw@11
|
159 name = "supported",
|
bsw@11
|
160 label = _"Supported",
|
bsw@11
|
161 selector_modifier = function(selector, value)
|
bsw@11
|
162 if value then
|
bsw@11
|
163 selector:add_where({ "EXISTS (SELECT 1 FROM initiative JOIN supporter ON supporter.initiative_id = initiative.id AND supporter.member_id = ? LEFT JOIN opinion ON opinion.initiative_id = initiative.id AND opinion.member_id = ? AND ((opinion.degree = 2 AND NOT fulfilled) OR (opinion.degree = -2 AND fulfilled)) WHERE initiative.issue_id = issue.id AND opinion.member_id ISNULL LIMIT 1)", app.session.member.id, app.session.member.id })
|
bsw@11
|
164 end
|
bsw@11
|
165 end
|
bsw@11
|
166 },
|
bsw@11
|
167 {
|
bsw@11
|
168 type = "boolean",
|
bsw@11
|
169 name = "potentially_supported",
|
bsw@11
|
170 label = _"Potential supported",
|
bsw@11
|
171 selector_modifier = function(selector, value)
|
bsw@11
|
172 if value then
|
bsw@11
|
173 selector:add_where({ "EXISTS (SELECT 1 FROM initiative JOIN supporter ON supporter.initiative_id = initiative.id AND supporter.member_id = ? JOIN opinion ON opinion.initiative_id = initiative.id AND opinion.member_id = ? AND ((opinion.degree = 2 AND NOT fulfilled) OR (opinion.degree = -2 AND fulfilled)) WHERE initiative.issue_id = issue.id LIMIT 1)", app.session.member.id, app.session.member.id })
|
bsw@11
|
174 end
|
bsw@11
|
175 end
|
bsw@11
|
176 },
|
bsw@11
|
177 {
|
bsw@11
|
178 type = "boolean",
|
bsw@11
|
179 name = "initiated",
|
bsw@11
|
180 label = _"Initiated",
|
bsw@11
|
181 selector_modifier = function(selector, value)
|
bsw@11
|
182 if value then
|
bsw@11
|
183 selector:add_where({ "EXISTS (SELECT 1 FROM initiative JOIN initiator ON initiator.initiative_id = initiative.id AND initiator.member_id = ? WHERE initiative.issue_id = issue.id)", app.session.member.id })
|
bsw@11
|
184 end
|
bsw@11
|
185 end
|
bsw@11
|
186 },
|
bsw/jbe@5
|
187 },
|
bsw@2
|
188 content = function()
|
bsw@10
|
189 local ui_order = ui.order
|
bsw@10
|
190 if param.get("no_sort", atom.boolean) then
|
bsw@10
|
191 ui_order = function(args) args.content() end
|
bsw@10
|
192 end
|
bsw@10
|
193 ui_order{
|
bsw/jbe@5
|
194 name = "issue_list",
|
bsw/jbe@5
|
195 selector = issues_selector,
|
bsw/jbe@5
|
196 options = {
|
bsw@2
|
197 {
|
bsw/jbe@5
|
198 name = "max_potential_support",
|
bsw/jbe@5
|
199 label = _"Max potential support",
|
bsw/jbe@5
|
200 selector_modifier = function(selector)
|
bsw/jbe@6
|
201 selector:add_order_by("(SELECT max(supporter_count) FROM initiative WHERE initiative.issue_id = issue.id) DESC")
|
bsw@2
|
202 end
|
bsw@2
|
203 },
|
bsw@2
|
204 {
|
bsw/jbe@5
|
205 name = "max_support",
|
bsw/jbe@5
|
206 label = _"Max support",
|
bsw/jbe@5
|
207 selector_modifier = function(selector)
|
bsw/jbe@6
|
208 selector:add_order_by("(SELECT max(satisfied_supporter_count) FROM initiative WHERE initiative.issue_id = issue.id) DESC")
|
bsw@2
|
209 end
|
bsw@2
|
210 },
|
bsw@2
|
211 {
|
bsw/jbe@5
|
212 name = "population",
|
bsw/jbe@5
|
213 label = _"Population",
|
bsw/jbe@5
|
214 order_by = "issue.population DESC"
|
bsw/jbe@5
|
215 },
|
bsw/jbe@5
|
216 {
|
bsw/jbe@5
|
217 name = "newest",
|
bsw/jbe@5
|
218 label = _"Newest",
|
bsw/jbe@5
|
219 order_by = "issue.created DESC"
|
bsw/jbe@5
|
220 },
|
bsw/jbe@5
|
221 {
|
bsw/jbe@5
|
222 name = "oldest",
|
bsw/jbe@5
|
223 label = _"Oldest",
|
bsw/jbe@5
|
224 order_by = "issue.created"
|
bsw/jbe@5
|
225 }
|
bsw/jbe@5
|
226 },
|
bsw/jbe@5
|
227 content = function()
|
bsw@10
|
228 local ui_paginate = ui.paginate
|
bsw@10
|
229 if param.get("per_page") == "all" then
|
bsw@10
|
230 ui_paginate = function(args) args.content() end
|
bsw@10
|
231 end
|
bsw@10
|
232 ui_paginate{
|
bsw@10
|
233 per_page = tonumber(param.get("per_page")),
|
bsw/jbe@5
|
234 selector = issues_selector,
|
bsw/jbe@5
|
235 content = function()
|
bsw/jbe@5
|
236 local highlight_string = param.get("highlight_string", "string")
|
bsw/jbe@5
|
237 local issues = issues or issues_selector:exec()
|
bsw/jbe@5
|
238 -- issues:load(initiatives)
|
bsw/jbe@5
|
239 ui.list{
|
bsw/jbe@5
|
240 attr = { class = "issues" },
|
bsw/jbe@5
|
241 records = issues,
|
bsw/jbe@5
|
242 columns = {
|
bsw/jbe@5
|
243 {
|
bsw/jbe@5
|
244 label = _"Issue",
|
bsw/jbe@5
|
245 content = function(record)
|
bsw/jbe@5
|
246 if not param.get("for_area_list", atom.boolean) then
|
bsw/jbe@5
|
247 ui.field.text{
|
bsw/jbe@5
|
248 value = record.area.name
|
bsw/jbe@5
|
249 }
|
bsw/jbe@5
|
250 slot.put("<br />")
|
bsw/jbe@5
|
251 end
|
bsw@11
|
252 if record.is_interested then
|
bsw@11
|
253 local label = _"You are interested in this issue",
|
bsw@11
|
254 ui.image{
|
bsw@11
|
255 attr = { alt = label, title = label },
|
bsw@11
|
256 static = "icons/16/eye.png"
|
bsw@11
|
257 }
|
bsw@11
|
258 slot.put(" ")
|
bsw@11
|
259 end
|
bsw/jbe@5
|
260 ui.link{
|
bsw@10
|
261 text = _("Issue ##{id}", { id = tostring(record.id) }),
|
bsw/jbe@5
|
262 module = "issue",
|
bsw/jbe@5
|
263 view = "show",
|
bsw/jbe@5
|
264 id = record.id
|
bsw/jbe@5
|
265 }
|
bsw/jbe@5
|
266 if record.state == "new" then
|
bsw/jbe@5
|
267 ui.image{
|
bsw/jbe@5
|
268 static = "icons/16/new.png"
|
bsw/jbe@5
|
269 }
|
bsw/jbe@5
|
270 end
|
bsw/jbe@5
|
271 slot.put("<br />")
|
bsw/jbe@5
|
272 slot.put("<br />")
|
bsw@10
|
273 if record.old_state then
|
bsw@10
|
274 ui.field.text{ value = format.time(record.sort) }
|
bsw@10
|
275 ui.field.text{ value = Issue:get_state_name_for_state(record.old_state) .. " > " .. Issue:get_state_name_for_state(record.new_state) }
|
bsw@10
|
276 else
|
bsw@10
|
277 end
|
bsw/jbe@5
|
278 end
|
bsw/jbe@5
|
279 },
|
bsw/jbe@5
|
280 {
|
bsw/jbe@5
|
281 label = _"State",
|
bsw/jbe@5
|
282 content = function(record)
|
bsw/jbe@6
|
283 if record.state == "voting" then
|
bsw/jbe@6
|
284 ui.link{
|
bsw/jbe@6
|
285 content = _"Voting",
|
bsw/jbe@6
|
286 module = "vote",
|
bsw/jbe@6
|
287 view = "list",
|
bsw/jbe@6
|
288 params = { issue_id = record.id }
|
bsw/jbe@6
|
289 }
|
bsw/jbe@6
|
290 else
|
bsw/jbe@6
|
291 ui.field.issue_state{ value = record.state }
|
bsw/jbe@6
|
292 end
|
bsw/jbe@5
|
293 end
|
bsw/jbe@5
|
294 },
|
bsw/jbe@5
|
295 {
|
bsw/jbe@5
|
296 label = _"Initiatives",
|
bsw/jbe@5
|
297 content = function(record)
|
bsw/jbe@5
|
298 local initiatives_selector = record:get_reference_selector("initiatives")
|
bsw/jbe@5
|
299 local highlight_string = param.get("highlight_string")
|
bsw/jbe@5
|
300 if highlight_string then
|
bsw/jbe@5
|
301 initiatives_selector:add_field( {'"highlight"("initiative"."name", ?)', highlight_string }, "name_highlighted")
|
bsw/jbe@5
|
302 end
|
bsw/jbe@5
|
303 execute.view{
|
bsw/jbe@5
|
304 module = "initiative",
|
bsw/jbe@5
|
305 view = "_list",
|
bsw/jbe@5
|
306 params = {
|
bsw/jbe@5
|
307 issue = record,
|
bsw/jbe@5
|
308 initiatives_selector = initiatives_selector,
|
bsw/jbe@5
|
309 highlight_string = highlight_string,
|
bsw@10
|
310 per_page = param.get("initiatives_per_page", atom.number),
|
bsw@10
|
311 no_sort = param.get("initiatives_no_sort", atom.boolean)
|
bsw/jbe@5
|
312 }
|
bsw/jbe@5
|
313 }
|
bsw/jbe@5
|
314 end
|
bsw/jbe@5
|
315 },
|
bsw@2
|
316 }
|
bsw@2
|
317 }
|
bsw@2
|
318 end
|
bsw/jbe@5
|
319 }
|
bsw/jbe@5
|
320 end
|
bsw@2
|
321 }
|
bsw@2
|
322 end
|
bsw/jbe@0
|
323 }
|
bsw/jbe@0
|
324 end
|
bsw/jbe@0
|
325 }
|
bsw/jbe@5
|
326 if param.get("legend", atom.boolean) ~= false then
|
bsw/jbe@5
|
327 local filter = param.get_all_cgi().filter
|
bsw/jbe@5
|
328 if not filter or filter == "any" or filter ~= "finished" then
|
bsw/jbe@5
|
329 ui.bargraph_legend{
|
bsw/jbe@5
|
330 width = 25,
|
bsw/jbe@5
|
331 bars = {
|
bsw/jbe@5
|
332 { color = "#0a0", label = _"Supporter" },
|
bsw/jbe@5
|
333 { color = "#777", label = _"Potential supporter" },
|
bsw/jbe@5
|
334 { color = "#ddd", label = _"No support at all" },
|
bsw/jbe@5
|
335 }
|
bsw/jbe@5
|
336 }
|
bsw/jbe@5
|
337 end
|
bsw/jbe@5
|
338 if not filter or filter == "any" or filter == "finished" then
|
bsw/jbe@5
|
339 ui.bargraph_legend{
|
bsw/jbe@5
|
340 width = 25,
|
bsw/jbe@5
|
341 bars = {
|
bsw/jbe@5
|
342 { color = "#0a0", label = _"Yes" },
|
bsw/jbe@5
|
343 { color = "#aaa", label = _"Abstention" },
|
bsw/jbe@5
|
344 { color = "#a00", label = _"No" },
|
bsw/jbe@5
|
345 }
|
bsw/jbe@5
|
346 }
|
bsw/jbe@5
|
347 end
|
bsw/jbe@5
|
348 end
|
bsw/jbe@0
|
349 end
|
bsw@2
|
350 }
|