liquid_feedback_frontend

view app/main/area/_list.lua @ 278:fecd4c13054a

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

Impressum / About Us