liquid_feedback_frontend
view app/main/initiative/_list_element.lua @ 1028:350a57518529
Added canceled_by_admin state to state name table
| author | bsw | 
|---|---|
| date | Sun Aug 11 23:00:20 2013 +0200 (2013-08-11) | 
| parents | c7215c18168b | 
| children | 701a5cf6b067 | 
 line source
     1 local initiative = param.get("initiative", "table")
     2 local selected = param.get("selected", atom.boolean)
     3 local for_member = param.get("for_member", "table") or app.session.member
     5 local class = "initiative"
     7 if selected then
     8   class = class .. " selected"
     9 end
    11 if initiative.polling then
    12   class = class .. " polling"
    13 end
    15 ui.container{ attr = { class = class }, content = function()
    17   ui.container{ attr = { class = "rank" }, content = function()
    18     if initiative.issue.fully_frozen and initiative.issue.closed
    19       or initiative.admitted == false
    20     then 
    21       ui.field.rank{ attr = { class = "rank" }, value = initiative.rank, eligible = initiative.eligible }
    22     elseif not initiative.issue.closed then
    23       ui.image{ static = "icons/16/script.png" }
    24     else
    25       ui.image{ static = "icons/16/cross.png" }
    26     end
    27   end }
    29   ui.container{ attr = { class = "bar" }, content = function()
    30     if initiative.issue.fully_frozen and initiative.issue.closed then
    31       if initiative.negative_votes and initiative.positive_votes then
    32         local max_value = initiative.issue.voter_count
    33         ui.bargraph{
    34           max_value = max_value,
    35           width = 100,
    36           bars = {
    37             { color = "#0a5", value = initiative.positive_votes },
    38             { color = "#aaa", value = max_value - initiative.negative_votes - initiative.positive_votes },
    39             { color = "#a00", value = initiative.negative_votes },
    40           }
    41         }
    42       else
    43          slot.put(" ")
    44       end
    45     else
    46       local max_value = initiative.issue.population or 0
    47       local quorum
    48       if initiative.issue.accepted then
    49         quorum = initiative.issue.policy.initiative_quorum_num / initiative.issue.policy.initiative_quorum_den
    50       else
    51         quorum = initiative.issue.policy.issue_quorum_num / initiative.issue.policy.issue_quorum_den
    52       end
    53       ui.bargraph{
    54         max_value = max_value,
    55         width = 100,
    56         quorum = max_value * quorum,
    57         quorum_color = "#00F",
    58         bars = {
    59           { color = "#0a5", value = (initiative.satisfied_supporter_count or 0) },
    60           { color = "#aaa", value = (initiative.supporter_count or 0) - (initiative.satisfied_supporter_count or 0) },
    61           { color = "#fff", value = max_value - (initiative.supporter_count or 0) },
    62         }
    63       }
    64     end
    65   end }
    67   if app.session.member_id then
    68     ui.container{ attr = { class = "interest" }, content = function()
    69       if initiative.member_info.initiated then
    70         local label 
    71         if for_member and for_member.id ~= app.session.member_id then
    72           label = _"This member is initiator of this initiative"
    73         else
    74           label = _"You are initiator of this initiative"
    75         end
    76         ui.image{
    77           attr = { alt = label, title = label },
    78           static = "icons/16/user_edit.png"
    79         }
    80       elseif initiative.member_info.directly_supported then
    81         if initiative.member_info.satisfied then
    82           if for_member and for_member.id ~= app.session.member_id then
    83             label = _"This member is supporter of this initiative"
    84           else
    85             local label = _"You are supporter of this initiative"
    86           end
    87           ui.image{
    88             attr = { alt = label, title = label },
    89             static = "icons/16/thumb_up_green.png"
    90           }
    91         else
    92           if for_member and for_member.id ~= app.session.member_id then
    93             label = _"This member is potential supporter of this initiative"
    94           else
    95             local label = _"You are potential supporter of this initiative"
    96           end
    97           ui.image{
    98             attr = { alt = label, title = label },
    99             static = "icons/16/thumb_up.png"
   100           }
   101         end
   102       elseif initiative.member_info.supported then
   103         if initiative.member_info.satisfied then
   104           if for_member and for_member.id ~= app.session.member_id then
   105             label = _"This member is supporter of this initiative via delegation"
   106           else
   107             local label = _"You are supporter of this initiative via delegation"
   108           end
   109           ui.image{
   110             attr = { alt = label, title = label },
   111             static = "icons/16/thumb_up_green_arrow.png"
   112           }
   113         else
   114           if for_member and for_member.id ~= app.session.member_id then
   115             label = _"This member is potential supporter of this initiative via delegation"
   116           else
   117             local label = _"You are potential supporter of this initiative via delegation"
   118           end
   119           ui.image{
   120             attr = { alt = label, title = label },
   121             static = "icons/16/thumb_up_arrow.png"
   122           }
   123         end
   124       end
   125     end }
   126   end
   128   ui.container{ attr = { class = "name" }, content = function()
   129     local link_class = "initiative_link"
   130     if initiative.revoked then
   131       link_class = "revoked"
   132     end
   133     ui.link{
   134       attr = { class = link_class },
   135       content = function()
   136         local name
   137         if initiative.name_highlighted then
   138           name = encode.highlight(initiative.name_highlighted)
   139         else
   140           name = encode.html(initiative.shortened_name)
   141         end
   142         ui.tag{ content = "i" .. initiative.id .. ": " }
   143         slot.put(name)
   144       end,
   145       module  = "initiative",
   146       view    = "show",
   147       id      = initiative.id
   148     }
   150   end }
   152 end }
