liquid_feedback_frontend
view app/main/initiative/_list.lua @ 1105:1b4bda1107b9
Fixed error when showing area before area member count is calculated first time
| author | bsw | 
|---|---|
| date | Mon Nov 10 17:35:48 2014 +0100 (2014-11-10) | 
| parents | 701a5cf6b067 | 
| children | 32cc544d5a5b | 
 line source
     1 local member = param.get("member", "table") or app.session.member
     3 local initiatives = param.get("initiatives", "table")
     4 local highlight_initiative_id = param.get ( "highlight_initiative_id", "number" )
     6 local for_initiative = param.get("initiative", "table")
     8 local for_event = param.get("for_event", atom.boolean)
    10 if for_initiative then
    11   initiatives = { for_initiative }
    12 end
    14 ui.tag { 
    15   tag = "ul",
    16   attr = { class = "initiatives" },
    17   content = function ()
    18     local last_group
    19     for i, initiative in ipairs(initiatives) do
    20       local group
    21       if initiative.issue.closed then
    22         if initiative.rank == 1 then
    23           group = "1st_rank"
    24         elseif initiative.admitted then
    25           group = "admitted"
    26         elseif initiative.revoked_by_member_id then
    27           group = "revoked"
    28         else
    29           group = "not_admitted"
    30         end
    31       end
    32       if not for_initiative and group ~= last_group and not for_event then
    34         local text
    35         if group == "admitted" then
    36           if initiative.issue.state == "finished_with_winner" then
    37             text = _"Competing initiatives in pairwise comparison to winner:"
    38           else
    39             text = _"Competing initiatives in pairwise comparison to best initiative:"
    40           end
    41         end
    42         if group == "not_admitted" then
    43           text = _("Competing initiatives failed the 2nd quorum (#{num}/#{den}):", {
    44             num = initiative.issue.policy.initiative_quorum_num,
    45             den = initiative.issue.policy.initiative_quorum_den
    46           } )
    47         end
    48         if text then
    49           slot.put("<br />")
    50           ui.container { attr = { class = "result" }, content = text }
    51         end
    52         last_group = group
    53       end
    55       local class = ""
    56       if highlight_initiative_id == initiative.id then
    57         class = "highlighted"
    58       end
    59       if app.session.member then
    60         if initiative.member_info.supported then
    61           class = class .. " supported"
    62         end
    63         if initiative.member_info.satisfied then
    64           class = class .. " satisfied"
    65         end
    66       end
    67       ui.tag {
    68         tag = "li", attr = { class = class },
    69         content = function ()
    70           execute.view {
    71             module = "initiative", view = "_list_element", params = {
    72               initiative = initiative, for_event = for_event
    73             }
    74           }
    75         end
    76       }
    77     end
    78   end 
    79 }
