liquid_feedback_frontend
view app/main/area/_list.lua @ 336:4cdf615ff358
Correctly interpret initiative.winner when showing approved information in initiative view (fix)
| author | bsw | 
|---|---|
| date | Tue Feb 28 18:47:00 2012 +0100 (2012-02-28) | 
| parents | 6c88b4bfb56c | 
| children | 76d7eafb3893 | 
 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 }
   220 --[[
   221 ui.bargraph_legend{
   222   width = 25,
   223   bars = {
   224     { color = "#444", label = _"Direct membership" },
   225     { color = "#777", label = _"Membership by delegation" },
   226     { color = "#ddd", label = _"No membership at all" },
   227   }
   228 }
   230 slot.put("<br />   ")
   233 if app.session.member_id then
   234   ui.image{
   235     attr = { title = title, alt = title },
   236     static = "icons/16/user_gray.png"
   237   }
   238   slot.put(" ")
   239   slot.put(_"Member of area")
   240   slot.put("   ")
   242   ui.image{
   243     attr = { title = title, alt = title },
   244     static = "icons/16/link.png"
   245   }
   246   slot.put(" ")
   247   slot.put(_"Area delegated")
   248   slot.put("   ")
   249 end
   251 ui.image{
   252   attr = { title = title, alt = title },
   253   static = "icons/16/new.png"
   254 }
   255 slot.put(" ")
   256 slot.put(_"New")
   257 slot.put("   ")
   259 ui.image{
   260   attr = { title = title, alt = title },
   261   static = "icons/16/comments.png"
   262 }
   263 slot.put(" ")
   264 slot.put(_"Discussion")
   265 slot.put("   ")
   267 ui.image{
   268   attr = { title = title, alt = title },
   269   static = "icons/16/lock.png"
   270 }
   271 slot.put(" ")
   272 slot.put(_"Frozen")
   273 slot.put("   ")
   275 ui.image{
   276   attr = { title = title, alt = title },
   277   static = "icons/16/email_open.png"
   278 }
   279 slot.put(" ")
   280 slot.put(_"Voting")
   281 slot.put("   ")
   283 ui.image{
   284   attr = { title = title, alt = title },
   285   static = "icons/16/tick.png"
   286 }
   287 slot.put(" ")
   288 slot.put(_"Finished")
   289 slot.put("   ")
   291 ui.image{
   292   attr = { title = title, alt = title },
   293   static = "icons/16/cross.png"
   294 }
   295 slot.put(" ")
   296 slot.put(_"Cancelled")
   298 --]]
