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