liquid_feedback_frontend

view app/main/area/_list.lua @ 275:fc14e76afe31

Made filter better useable
author bsw
date Sun Feb 12 13:42:08 2012 +0100 (2012-02-12)
parents aec9df5b4cd3
children fecd4c13054a
line source
1 local areas_selector = param.get("areas_selector", "table")
3 areas_selector
4 :reset_fields()
5 :add_field("area.id", nil, { "grouped" })
6 :add_field("area.name", nil, { "grouped" })
7 :add_field("member_weight", nil, { "grouped" })
8 :add_field("direct_member_count", nil, { "grouped" })
9 :add_field("(SELECT COUNT(*) FROM issue WHERE issue.area_id = area.id AND issue.accepted ISNULL AND issue.closed ISNULL)", "issues_new_count")
10 :add_field("(SELECT COUNT(*) FROM issue WHERE issue.area_id = area.id AND issue.accepted NOTNULL AND issue.half_frozen ISNULL AND issue.closed ISNULL)", "issues_discussion_count")
11 :add_field("(SELECT COUNT(*) FROM issue WHERE issue.area_id = area.id AND issue.half_frozen NOTNULL AND issue.fully_frozen ISNULL AND issue.closed ISNULL)", "issues_frozen_count")
12 :add_field("(SELECT COUNT(*) FROM issue WHERE issue.area_id = area.id AND issue.fully_frozen NOTNULL AND issue.closed ISNULL)", "issues_voting_count")
13 :add_field("(SELECT COUNT(*) FROM issue WHERE issue.area_id = area.id AND issue.fully_frozen NOTNULL AND issue.closed NOTNULL)", "issues_finished_count")
14 :add_field("(SELECT COUNT(*) FROM issue WHERE issue.area_id = area.id AND issue.fully_frozen ISNULL AND issue.closed NOTNULL)", "issues_cancelled_count")
16 if app.session.member_id then
17 areas_selector
18 :add_field({ "(SELECT COUNT(*) FROM issue LEFT JOIN direct_voter ON direct_voter.issue_id = issue.id AND direct_voter.member_id = ? WHERE issue.area_id = area.id AND issue.fully_frozen NOTNULL AND issue.closed ISNULL AND direct_voter.member_id ISNULL)", app.session.member.id }, "issues_to_vote_count")
19 :left_join("membership", "_membership", { "_membership.area_id = area.id AND _membership.member_id = ?", app.session.member.id })
20 :add_field("_membership.member_id NOTNULL", "is_member", { "grouped" })
21 :left_join("delegation", nil, {
22 "delegation.truster_id = ? AND delegation.area_id = area.id AND delegation.scope = 'area'", app.session.member_id
23 })
24 :left_join("member", nil, "member.id = delegation.trustee_id")
25 :add_field("member.id", "trustee_member_id", { "grouped" })
26 :add_field("member.name", "trustee_member_name", { "grouped" })
27 else
28 areas_selector:add_field("0", "issues_to_vote_count")
29 end
31 local label_attr = { style = "text-align: right; width: 4em;" }
32 local field_attr = { style = "text-align: right; width: 4em;" }
34 ui.list{
35 attr = { class = "area_list" },
36 records = areas_selector:exec(),
37 columns = {
38 {
39 content = function(record)
40 if record.is_member then
41 local text = _"Member of area"
42 ui.image{
43 attr = { title = text, alt = text, style = "vertical-align: middle;" },
44 static = "icons/16/user_gray.png",
45 }
46 end
47 end
48 },
49 {
50 content = function(record)
51 if record.trustee_member_id then
52 local trustee_member = Member:by_id(record.trustee_member_id)
53 local text = _("Area delegated to '#{name}'", { name = record.trustee_member_name })
54 execute.view{
55 module = "member_image",
56 view = "_show",
57 params = {
58 member = trustee_member,
59 image_type = "avatar",
60 show_dummy = true,
61 class = "micro_avatar",
62 popup_text = text
63 }
64 }
65 end
66 end
67 },
68 {
69 content = function(record)
70 if record.member_weight and record.direct_member_count then
71 local max_value = MemberCount:get()
72 ui.bargraph{
73 max_value = max_value,
74 width = 100,
75 bars = {
76 { color = "#444", value = record.direct_member_count },
77 { color = "#777", value = record.member_weight - record.direct_member_count },
78 { color = "#ddd", value = max_value - record.member_weight },
79 }
80 }
81 end
82 end
83 },
84 {
85 content = function(record)
86 ui.link{
87 text = record.name,
88 module = "area",
89 view = "show",
90 id = record.id
91 }
92 end
93 },
94 {
95 label = function()
96 local title = _"New"
97 ui.image{
98 attr = { title = title, alt = title },
99 static = "icons/16/new.png"
100 }
101 end,
102 field_attr = field_attr,
103 label_attr = label_attr,
104 content = function(record)
105 ui.link{
106 text = tostring(record.issues_new_count),
107 module = "area",
108 view = "show",
109 id = record.id,
110 params = { filter = "new", tab = "issues" }
111 }
112 end
113 },
114 {
115 label = function()
116 local title = _"Discussion"
117 ui.image{
118 attr = { title = title, alt = title },
119 static = "icons/16/comments.png"
120 }
121 end,
122 field_attr = field_attr,
123 label_attr = label_attr,
124 content = function(record)
125 ui.link{
126 text = tostring(record.issues_discussion_count),
127 module = "area",
128 view = "show",
129 id = record.id,
130 params = { filter = "accepted", tab = "issues" }
131 }
132 end
133 },
134 {
135 label = function()
136 local title = _"Frozen"
137 ui.image{
138 attr = { title = title, alt = title },
139 static = "icons/16/lock.png"
140 }
141 end,
142 field_attr = field_attr,
143 label_attr = label_attr,
144 content = function(record)
145 ui.link{
146 text = tostring(record.issues_frozen_count),
147 module = "area",
148 view = "show",
149 id = record.id,
150 params = { filter = "half_frozen", tab = "issues" }
151 }
152 end
153 },
154 {
155 label = function()
156 local title = _"Voting"
157 ui.image{
158 attr = { title = title, alt = title },
159 static = "icons/16/email_open.png"
160 }
161 end,
162 field_attr = field_attr,
163 label_attr = label_attr,
164 content = function(record)
165 ui.link{
166 text = tostring(record.issues_voting_count),
167 module = "area",
168 view = "show",
169 id = record.id,
170 params = { filter = "frozen", tab = "issues" }
171 }
172 end
173 },
174 {
175 label = function()
176 local title = _"Finished"
177 ui.image{
178 attr = { title = title, alt = title },
179 static = "icons/16/tick.png"
180 }
181 end,
182 field_attr = field_attr,
183 label_attr = label_attr,
184 content = function(record)
185 ui.link{
186 text = tostring(record.issues_finished_count),
187 module = "area",
188 view = "show",
189 id = record.id,
190 params = { filter = "finished", issue_list = "newest", tab = "issues" }
191 }
192 end
193 },
194 {
195 label = function()
196 local title = _"Cancelled"
197 ui.image{
198 attr = { title = title, alt = title },
199 static = "icons/16/cross.png"
200 }
201 end,
202 field_attr = field_attr,
203 label_attr = label_attr,
204 content = function(record)
205 ui.link{
206 text = tostring(record.issues_cancelled_count),
207 module = "area",
208 view = "show",
209 id = record.id,
210 params = { filter = "cancelled", issue_list = "newest", tab = "issues" }
211 }
212 end
213 },
214 {
215 content = function(record)
216 if record.issues_to_vote_count > 0 then
217 ui.link{
218 attr = { class = "not_voted" },
219 text = _"Not yet voted" .. ": " .. tostring(record.issues_to_vote_count),
220 module = "area",
221 view = "show",
222 id = record.id,
223 params = {
224 filter = "frozen",
225 filter_voting = "not_voted",
226 tab = "issues"
227 }
228 }
229 end
230 end
231 },
232 }
233 }
234 --[[
235 ui.bargraph_legend{
236 width = 25,
237 bars = {
238 { color = "#444", label = _"Direct membership" },
239 { color = "#777", label = _"Membership by delegation" },
240 { color = "#ddd", label = _"No membership at all" },
241 }
242 }
244 slot.put("<br /> &nbsp; ")
247 if app.session.member_id then
248 ui.image{
249 attr = { title = title, alt = title },
250 static = "icons/16/user_gray.png"
251 }
252 slot.put(" ")
253 slot.put(_"Member of area")
254 slot.put(" &nbsp; ")
256 ui.image{
257 attr = { title = title, alt = title },
258 static = "icons/16/link.png"
259 }
260 slot.put(" ")
261 slot.put(_"Area delegated")
262 slot.put(" &nbsp; ")
263 end
265 ui.image{
266 attr = { title = title, alt = title },
267 static = "icons/16/new.png"
268 }
269 slot.put(" ")
270 slot.put(_"New")
271 slot.put(" &nbsp; ")
273 ui.image{
274 attr = { title = title, alt = title },
275 static = "icons/16/comments.png"
276 }
277 slot.put(" ")
278 slot.put(_"Discussion")
279 slot.put(" &nbsp; ")
281 ui.image{
282 attr = { title = title, alt = title },
283 static = "icons/16/lock.png"
284 }
285 slot.put(" ")
286 slot.put(_"Frozen")
287 slot.put(" &nbsp; ")
289 ui.image{
290 attr = { title = title, alt = title },
291 static = "icons/16/email_open.png"
292 }
293 slot.put(" ")
294 slot.put(_"Voting")
295 slot.put(" &nbsp; ")
297 ui.image{
298 attr = { title = title, alt = title },
299 static = "icons/16/tick.png"
300 }
301 slot.put(" ")
302 slot.put(_"Finished")
303 slot.put(" &nbsp; ")
305 ui.image{
306 attr = { title = title, alt = title },
307 static = "icons/16/cross.png"
308 }
309 slot.put(" ")
310 slot.put(_"Cancelled")
312 --]]

Impressum / About Us