liquid_feedback_frontend

view app/main/area/_list.lua @ 280:808269b7f41c

More repositioning and optical enhancements
author bsw
date Thu Feb 16 14:08:55 2012 +0100 (2012-02-16)
parents fecd4c13054a
children 6c88b4bfb56c
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", style = "width: 100%; table-layout: fixed;" },
36 records = areas_selector:exec(),
37 columns = {
38 {
39 label_attr = { style = "width: 2em;" },
40 content = function(record)
41 if record.is_member then
42 local text = _"Member of area"
43 ui.image{
44 attr = { title = text, alt = text, style = "vertical-align: middle;" },
45 static = "icons/16/user_gray.png",
46 }
47 end
48 end
49 },
50 {
51 label_attr = { style = "width: 2em;" },
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 label_attr = { style = "width: 110px" },
72 content = function(record)
73 if record.member_weight and record.direct_member_count then
74 local max_value = MemberCount:get()
75 ui.bargraph{
76 max_value = max_value,
77 width = 100,
78 bars = {
79 { color = "#444", value = record.direct_member_count },
80 { color = "#777", value = record.member_weight - record.direct_member_count },
81 { color = "#ddd", value = max_value - record.member_weight },
82 }
83 }
84 end
85 end
86 },
87 {
88 label_attr = { style = "width: 100%" },
89 content = function(record)
90 ui.link{
91 text = record.name,
92 module = "area",
93 view = "show",
94 id = record.id
95 }
96 end
97 },
98 {
99 label = function()
100 local title = _"New"
101 ui.image{
102 attr = { title = title, alt = title },
103 static = "icons/16/new.png"
104 }
105 end,
106 field_attr = field_attr,
107 label_attr = label_attr,
108 content = function(record)
109 ui.link{
110 text = tostring(record.issues_new_count),
111 module = "area",
112 view = "show",
113 id = record.id,
114 params = { filter = "new", tab = "issues" }
115 }
116 end
117 },
118 {
119 label = function()
120 local title = _"Discussion"
121 ui.image{
122 attr = { title = title, alt = title },
123 static = "icons/16/comments.png"
124 }
125 end,
126 field_attr = field_attr,
127 label_attr = label_attr,
128 content = function(record)
129 ui.link{
130 text = tostring(record.issues_discussion_count),
131 module = "area",
132 view = "show",
133 id = record.id,
134 params = { filter = "accepted", tab = "issues" }
135 }
136 end
137 },
138 {
139 label = function()
140 local title = _"Frozen"
141 ui.image{
142 attr = { title = title, alt = title },
143 static = "icons/16/lock.png"
144 }
145 end,
146 field_attr = field_attr,
147 label_attr = label_attr,
148 content = function(record)
149 ui.link{
150 text = tostring(record.issues_frozen_count),
151 module = "area",
152 view = "show",
153 id = record.id,
154 params = { filter = "half_frozen", tab = "issues" }
155 }
156 end
157 },
158 {
159 label = function()
160 local title = _"Voting"
161 ui.image{
162 attr = { title = title, alt = title },
163 static = "icons/16/email_open.png"
164 }
165 end,
166 field_attr = field_attr,
167 label_attr = label_attr,
168 content = function(record)
169 ui.link{
170 text = tostring(record.issues_voting_count),
171 module = "area",
172 view = "show",
173 id = record.id,
174 params = { filter = "frozen", tab = "issues" }
175 }
176 end
177 },
178 {
179 label = function()
180 local title = _"Finished"
181 ui.image{
182 attr = { title = title, alt = title },
183 static = "icons/16/tick.png"
184 }
185 end,
186 field_attr = field_attr,
187 label_attr = label_attr,
188 content = function(record)
189 ui.link{
190 text = tostring(record.issues_finished_count),
191 module = "area",
192 view = "show",
193 id = record.id,
194 params = { filter = "finished", issue_list = "newest", tab = "issues" }
195 }
196 end
197 },
198 {
199 label = function()
200 local title = _"Cancelled"
201 ui.image{
202 attr = { title = title, alt = title },
203 static = "icons/16/cross.png"
204 }
205 end,
206 field_attr = field_attr,
207 label_attr = label_attr,
208 content = function(record)
209 ui.link{
210 text = tostring(record.issues_cancelled_count),
211 module = "area",
212 view = "show",
213 id = record.id,
214 params = { filter = "cancelled", issue_list = "newest", tab = "issues" }
215 }
216 end
217 },
218 {
219 content = function(record)
220 if record.issues_to_vote_count > 0 then
221 ui.link{
222 attr = { class = "not_voted" },
223 text = _"Not yet voted" .. ": " .. tostring(record.issues_to_vote_count),
224 module = "area",
225 view = "show",
226 id = record.id,
227 params = {
228 filter = "frozen",
229 filter_voting = "not_voted",
230 tab = "issues"
231 }
232 }
233 end
234 end
235 },
236 }
237 }
238 --[[
239 ui.bargraph_legend{
240 width = 25,
241 bars = {
242 { color = "#444", label = _"Direct membership" },
243 { color = "#777", label = _"Membership by delegation" },
244 { color = "#ddd", label = _"No membership at all" },
245 }
246 }
248 slot.put("<br /> &nbsp; ")
251 if app.session.member_id then
252 ui.image{
253 attr = { title = title, alt = title },
254 static = "icons/16/user_gray.png"
255 }
256 slot.put(" ")
257 slot.put(_"Member of area")
258 slot.put(" &nbsp; ")
260 ui.image{
261 attr = { title = title, alt = title },
262 static = "icons/16/link.png"
263 }
264 slot.put(" ")
265 slot.put(_"Area delegated")
266 slot.put(" &nbsp; ")
267 end
269 ui.image{
270 attr = { title = title, alt = title },
271 static = "icons/16/new.png"
272 }
273 slot.put(" ")
274 slot.put(_"New")
275 slot.put(" &nbsp; ")
277 ui.image{
278 attr = { title = title, alt = title },
279 static = "icons/16/comments.png"
280 }
281 slot.put(" ")
282 slot.put(_"Discussion")
283 slot.put(" &nbsp; ")
285 ui.image{
286 attr = { title = title, alt = title },
287 static = "icons/16/lock.png"
288 }
289 slot.put(" ")
290 slot.put(_"Frozen")
291 slot.put(" &nbsp; ")
293 ui.image{
294 attr = { title = title, alt = title },
295 static = "icons/16/email_open.png"
296 }
297 slot.put(" ")
298 slot.put(_"Voting")
299 slot.put(" &nbsp; ")
301 ui.image{
302 attr = { title = title, alt = title },
303 static = "icons/16/tick.png"
304 }
305 slot.put(" ")
306 slot.put(_"Finished")
307 slot.put(" &nbsp; ")
309 ui.image{
310 attr = { title = title, alt = title },
311 static = "icons/16/cross.png"
312 }
313 slot.put(" ")
314 slot.put(_"Cancelled")
316 --]]

Impressum / About Us