liquid_feedback_frontend

annotate app/main/area/_list.lua @ 249:52b125fada5b

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

Impressum / About Us