liquid_feedback_frontend
view app/main/issue/_list.lua @ 118:93f4e465b50d
add initiator support in delegation
if a delegation is issued from the initiative view, the initiators
from that one are added to the delegation target list. this makes it easier to delegate to the author without the need to add him to the contact list.
if a delegation is issued from the initiative view, the initiators
from that one are added to the delegation target list. this makes it easier to delegate to the author without the need to add him to the contact list.
author | Daniel Poelzleithner <poelzi@poelzi.org> |
---|---|
date | Mon Sep 20 20:32:04 2010 +0200 (2010-09-20) |
parents | 733f65c0c0a0 |
children | 4fb486bce608 |
line source
1 local issues_selector = param.get("issues_selector", "table")
3 if app.session.member_id then
4 issues_selector
5 :left_join("interest", "_interest", { "_interest.issue_id = issue.id AND _interest.member_id = ?", app.session.member.id} )
6 :add_field("(_interest.member_id NOTNULL)", "is_interested")
7 end
9 ui.add_partial_param_names{
10 "filter",
11 "filter_open",
12 "filter_voting",
13 "filter_interest",
14 "issue_list"
15 }
17 local filters = {}
19 filters[#filters+1] = {
20 label = _"Filter",
21 {
22 name = "open",
23 label = _"Open",
24 selector_modifier = function(selector)
25 selector:add_where("issue.closed ISNULL")
26 end
27 },
28 {
29 name = "new",
30 label = _"New",
31 selector_modifier = function(selector)
32 selector:add_where("issue.accepted ISNULL AND issue.closed ISNULL")
33 end
34 },
35 {
36 name = "accepted",
37 label = _"In discussion",
38 selector_modifier = function(selector)
39 selector:add_where("issue.accepted NOTNULL AND issue.half_frozen ISNULL AND issue.closed ISNULL")
40 end
41 },
42 {
43 name = "half_frozen",
44 label = _"Frozen",
45 selector_modifier = function(selector)
46 selector:add_where("issue.half_frozen NOTNULL AND issue.fully_frozen ISNULL")
47 end
48 },
49 {
50 name = "frozen",
51 label = _"Voting",
52 selector_modifier = function(selector)
53 selector:add_where("issue.fully_frozen NOTNULL AND issue.closed ISNULL")
54 filter_voting = true
55 end
56 },
57 {
58 name = "finished",
59 label = _"Finished",
60 selector_modifier = function(selector)
61 selector:add_where("issue.closed NOTNULL AND issue.fully_frozen NOTNULL")
62 end
63 },
64 {
65 name = "cancelled",
66 label = _"Cancelled",
67 selector_modifier = function(selector)
68 selector:add_where("issue.closed NOTNULL AND issue.fully_frozen ISNULL")
69 end
70 },
71 {
72 name = "any",
73 label = _"Any",
74 selector_modifier = function(selector) end
75 },
76 }
79 if app.session.member and param.get("filter") == "frozen" then
80 filters[#filters+1] = {
81 label = _"Filter",
82 name = "filter_voting",
83 {
84 name = "any",
85 label = _"Any",
86 selector_modifier = function() end
87 },
88 {
89 name = "not_voted",
90 label = _"Not voted",
91 selector_modifier = function(selector)
92 selector:left_join("direct_voter", nil, { "direct_voter.issue_id = issue.id AND direct_voter.member_id = ?", app.session.member.id })
93 selector:add_where("direct_voter.member_id ISNULL")
94 end
95 },
96 {
97 name = "voted",
98 label = _"Voted",
99 selector_modifier = function(selector)
100 selector:join("direct_voter", nil, { "direct_voter.issue_id = issue.id AND direct_voter.member_id = ?", app.session.member.id })
101 end
102 },
103 }
104 end
107 filters[#filters+1] = {
108 label = _"Filter",
109 name = "filter_interest",
110 {
111 name = "any",
112 label = _"Any",
113 selector_modifier = function() end
114 },
115 {
116 name = "my",
117 label = _"Interested",
118 selector_modifier = function(selector)
119 selector:join("interest", "filter_interest", { "filter_interest.issue_id = issue.id AND filter_interest.member_id = ? ", app.session.member.id })
120 end
121 },
122 {
123 name = "supported",
124 label = _"Supported",
125 selector_modifier = function(selector)
126 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 })
127 end
128 },
129 {
130 name = "potentially_supported",
131 label = _"Potential supported",
132 selector_modifier = function(selector)
133 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 })
134 end
135 },
136 {
137 name = "initiated",
138 label = _"Initiated",
139 selector_modifier = function(selector)
140 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 })
141 end
142 },
143 }
145 if not param.get("no_sort", atom.boolean) then
146 filters[#filters+1] = {
147 label = _"Order by",
148 name = "issue_list",
149 {
150 name = "max_potential_support",
151 label = _"Max potential support",
152 selector_modifier = function(selector)
153 selector:add_order_by("(SELECT max(supporter_count) FROM initiative WHERE initiative.issue_id = issue.id) DESC")
154 end
155 },
156 {
157 name = "max_support",
158 label = _"Max support",
159 selector_modifier = function(selector)
160 selector:add_order_by("(SELECT max(satisfied_supporter_count) FROM initiative WHERE initiative.issue_id = issue.id) DESC")
161 end
162 },
163 {
164 name = "population",
165 label = _"Population",
166 selector_modifier = function(selector)
167 selector:add_order_by("issue.population DESC")
168 end
169 },
170 {
171 name = "newest",
172 label = _"Newest",
173 selector_modifier = function(selector)
174 selector:add_order_by("issue.created DESC")
175 end
176 },
177 {
178 name = "oldest",
179 label = _"Oldest",
180 selector_modifier = function(selector)
181 selector:add_order_by("issue.created")
182 end
183 }
184 }
185 end
187 filters.content = function()
188 local ui_paginate = ui.paginate
189 if param.get("per_page") == "all" then
190 ui_paginate = function(args) args.content() end
191 end
192 ui_paginate{
193 per_page = tonumber(param.get("per_page")),
194 selector = issues_selector,
195 content = function()
196 local highlight_string = param.get("highlight_string", "string")
197 local issues = issues or issues_selector:exec()
198 -- issues:load(initiatives)
199 ui.list{
200 attr = { class = "issues" },
201 records = issues,
202 columns = {
203 {
204 label = _"Issue",
205 content = function(record)
206 if not param.get("for_area_list", atom.boolean) then
207 ui.field.text{
208 value = record.area.name
209 }
210 slot.put("<br />")
211 end
212 if record.is_interested then
213 local label = _"You are interested in this issue",
214 ui.image{
215 attr = { alt = label, title = label },
216 static = "icons/16/eye.png"
217 }
218 slot.put(" ")
219 end
220 ui.link{
221 text = _("Issue ##{id}", { id = tostring(record.id) }),
222 module = "issue",
223 view = "show",
224 id = record.id
225 }
226 if record.state == "new" then
227 ui.image{
228 static = "icons/16/new.png"
229 }
230 end
231 slot.put("<br />")
232 slot.put("<br />")
233 if record.old_state then
234 ui.field.text{ value = format.time(record.sort) }
235 ui.field.text{ value = Issue:get_state_name_for_state(record.old_state) .. " > " .. Issue:get_state_name_for_state(record.new_state) }
236 else
237 end
238 end
239 },
240 {
241 label = _"State",
242 content = function(record)
243 if record.state == "voting" then
244 ui.link{
245 content = _"Voting",
246 module = "vote",
247 view = "list",
248 params = { issue_id = record.id }
249 }
250 else
251 ui.field.issue_state{ value = record.state }
252 end
253 end
254 },
255 {
256 label = _"Initiatives",
257 content = function(record)
258 local initiatives_selector = record:get_reference_selector("initiatives")
259 local highlight_string = param.get("highlight_string")
260 if highlight_string then
261 initiatives_selector:add_field( {'"highlight"("initiative"."name", ?)', highlight_string }, "name_highlighted")
262 end
263 execute.view{
264 module = "initiative",
265 view = "_list",
266 params = {
267 issue = record,
268 initiatives_selector = initiatives_selector,
269 highlight_string = highlight_string,
270 per_page = app.session.member_id and tonumber(app.session.member:get_setting_value("initiatives_preview_limit") or 3) or 3,
271 no_sort = true,
272 limit = app.session.member_id and tonumber(app.session.member:get_setting_value("initiatives_preview_limit") or 3) or 3
273 }
274 }
275 end
276 },
277 }
278 }
279 end
280 }
281 end
283 filters.selector = issues_selector
284 filters.label = _"Change filters and order"
286 if param.get("no_filter", atom.boolean) then
287 filters.content()
288 else
289 ui.filters(filters)
290 end
292 if param.get("legend", atom.boolean) ~= false then
293 local filter = param.get_all_cgi().filter
294 if not filter or filter == "any" or filter ~= "finished" then
295 ui.bargraph_legend{
296 width = 25,
297 bars = {
298 { color = "#0a0", label = _"Supporter" },
299 { color = "#777", label = _"Potential supporter" },
300 { color = "#ddd", label = _"No support at all" },
301 }
302 }
303 end
304 if not filter or filter == "any" or filter == "finished" then
305 ui.bargraph_legend{
306 width = 25,
307 bars = {
308 { color = "#0a0", label = _"Yes" },
309 { color = "#aaa", label = _"Abstention" },
310 { color = "#a00", label = _"No" },
311 }
312 }
313 end
314 end