liquid_feedback_frontend
view app/main/area/_list.lua @ 270:08a5e1226da2
Fixed error when issue population is zero
author | bsw |
---|---|
date | Tue Feb 07 20:03:31 2012 +0100 (2012-02-07) |
parents | 55c2806c7113 |
children | aec9df5b4cd3 |
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 :add_field({ "(SELECT member.name FROM delegation LEFT JOIN member ON delegation.trustee_id = member.id WHERE delegation.scope = 'area' AND delegation.area_id = area.id AND truster_id = ?)", app.session.member.id }, "area_delegation_name")
22 else
23 areas_selector:add_field("0", "issues_to_vote_count")
24 end
26 local label_attr = { style = "text-align: right; width: 4em;" }
27 local field_attr = { style = "text-align: right; width: 4em;" }
29 ui.list{
30 attr = { class = "area_list" },
31 records = areas_selector:exec(),
32 columns = {
33 {
34 content = function(record)
35 if record.is_member then
36 local text = _"Member of area"
37 ui.image{
38 attr = { title = text, alt = text, style = "vertical-align: middle;" },
39 static = "icons/16/user_gray.png",
40 }
41 end
42 end
43 },
44 {
45 content = function(record)
46 if record.area_delegation_name then
47 local text = _("Area delegated to '#{name}'", { name = record.area_delegation_name })
48 ui.image{
49 attr = { title = text, alt = text, style = "vertical-align: middle;" },
50 static = "icons/16/link.png",
51 }
52 end
53 end
54 },
55 {
56 content = function(record)
57 if record.member_weight and record.direct_member_count then
58 local max_value = MemberCount:get()
59 ui.bargraph{
60 max_value = max_value,
61 width = 100,
62 bars = {
63 { color = "#444", value = record.direct_member_count },
64 { color = "#777", value = record.member_weight - record.direct_member_count },
65 { color = "#ddd", value = max_value - record.member_weight },
66 }
67 }
68 end
69 end
70 },
71 {
72 content = function(record)
73 ui.link{
74 text = record.name,
75 module = "area",
76 view = "show",
77 id = record.id
78 }
79 end
80 },
81 {
82 label = function()
83 local title = _"New"
84 ui.image{
85 attr = { title = title, alt = title },
86 static = "icons/16/new.png"
87 }
88 end,
89 field_attr = field_attr,
90 label_attr = label_attr,
91 content = function(record)
92 ui.link{
93 text = tostring(record.issues_new_count),
94 module = "area",
95 view = "show",
96 id = record.id,
97 params = { filter = "new", tab = "issues" }
98 }
99 end
100 },
101 {
102 label = function()
103 local title = _"Discussion"
104 ui.image{
105 attr = { title = title, alt = title },
106 static = "icons/16/comments.png"
107 }
108 end,
109 field_attr = field_attr,
110 label_attr = label_attr,
111 content = function(record)
112 ui.link{
113 text = tostring(record.issues_discussion_count),
114 module = "area",
115 view = "show",
116 id = record.id,
117 params = { filter = "accepted", tab = "issues" }
118 }
119 end
120 },
121 {
122 label = function()
123 local title = _"Frozen"
124 ui.image{
125 attr = { title = title, alt = title },
126 static = "icons/16/lock.png"
127 }
128 end,
129 field_attr = field_attr,
130 label_attr = label_attr,
131 content = function(record)
132 ui.link{
133 text = tostring(record.issues_frozen_count),
134 module = "area",
135 view = "show",
136 id = record.id,
137 params = { filter = "half_frozen", tab = "issues" }
138 }
139 end
140 },
141 {
142 label = function()
143 local title = _"Voting"
144 ui.image{
145 attr = { title = title, alt = title },
146 static = "icons/16/email_open.png"
147 }
148 end,
149 field_attr = field_attr,
150 label_attr = label_attr,
151 content = function(record)
152 ui.link{
153 text = tostring(record.issues_voting_count),
154 module = "area",
155 view = "show",
156 id = record.id,
157 params = { filter = "frozen", tab = "issues" }
158 }
159 end
160 },
161 {
162 label = function()
163 local title = _"Finished"
164 ui.image{
165 attr = { title = title, alt = title },
166 static = "icons/16/tick.png"
167 }
168 end,
169 field_attr = field_attr,
170 label_attr = label_attr,
171 content = function(record)
172 ui.link{
173 text = tostring(record.issues_finished_count),
174 module = "area",
175 view = "show",
176 id = record.id,
177 params = { filter = "finished", issue_list = "newest", tab = "issues" }
178 }
179 end
180 },
181 {
182 label = function()
183 local title = _"Cancelled"
184 ui.image{
185 attr = { title = title, alt = title },
186 static = "icons/16/cross.png"
187 }
188 end,
189 field_attr = field_attr,
190 label_attr = label_attr,
191 content = function(record)
192 ui.link{
193 text = tostring(record.issues_cancelled_count),
194 module = "area",
195 view = "show",
196 id = record.id,
197 params = { filter = "cancelled", issue_list = "newest", tab = "issues" }
198 }
199 end
200 },
201 {
202 content = function(record)
203 if record.issues_to_vote_count > 0 then
204 ui.link{
205 attr = { class = "not_voted" },
206 text = _"Not yet voted" .. ": " .. tostring(record.issues_to_vote_count),
207 module = "area",
208 view = "show",
209 id = record.id,
210 params = {
211 filter = "frozen",
212 filter_voting = "not_voted",
213 tab = "issues"
214 }
215 }
216 end
217 end
218 },
219 }
220 }
222 ui.bargraph_legend{
223 width = 25,
224 bars = {
225 { color = "#444", label = _"Direct membership" },
226 { color = "#777", label = _"Membership by delegation" },
227 { color = "#ddd", label = _"No membership at all" },
228 }
229 }
231 slot.put("<br /> ")
234 if app.session.member_id then
235 ui.image{
236 attr = { title = title, alt = title },
237 static = "icons/16/user_gray.png"
238 }
239 slot.put(" ")
240 slot.put(_"Member of area")
241 slot.put(" ")
243 ui.image{
244 attr = { title = title, alt = title },
245 static = "icons/16/link.png"
246 }
247 slot.put(" ")
248 slot.put(_"Area delegated")
249 slot.put(" ")
250 end
252 ui.image{
253 attr = { title = title, alt = title },
254 static = "icons/16/new.png"
255 }
256 slot.put(" ")
257 slot.put(_"New")
258 slot.put(" ")
260 ui.image{
261 attr = { title = title, alt = title },
262 static = "icons/16/comments.png"
263 }
264 slot.put(" ")
265 slot.put(_"Discussion")
266 slot.put(" ")
268 ui.image{
269 attr = { title = title, alt = title },
270 static = "icons/16/lock.png"
271 }
272 slot.put(" ")
273 slot.put(_"Frozen")
274 slot.put(" ")
276 ui.image{
277 attr = { title = title, alt = title },
278 static = "icons/16/email_open.png"
279 }
280 slot.put(" ")
281 slot.put(_"Voting")
282 slot.put(" ")
284 ui.image{
285 attr = { title = title, alt = title },
286 static = "icons/16/tick.png"
287 }
288 slot.put(" ")
289 slot.put(_"Finished")
290 slot.put(" ")
292 ui.image{
293 attr = { title = title, alt = title },
294 static = "icons/16/cross.png"
295 }
296 slot.put(" ")
297 slot.put(_"Cancelled")