liquid_feedback_frontend
view app/main/initiative/_list_element.lua @ 512:d0e12e1b8761
Make member privileges editable in admin section
| author | bsw | 
|---|---|
| date | Wed Apr 11 19:03:50 2012 +0200 (2012-04-11) | 
| parents | 160b859e7180 | 
| children | 3e4f6534bb15 | 
 line source
     1 local initiative = param.get("initiative", "table")
     2 local selected = param.get("selected", atom.boolean)
     5 ui.container{ attr = { class = "initiative" }, content = function()
     7   ui.container{ attr = { class = "rank" }, content = function()
     8     if initiative.issue.accepted and initiative.issue.closed
     9       and initiative.issue.ranks_available or initiative.admitted == false
    10     then 
    11       ui.field.rank{ attr = { class = "rank" }, value = initiative.rank, eligible = initiative.eligible }
    12     elseif not initiative.issue.closed then
    13       ui.image{ static = "icons/16/script.png" }
    14     else
    15       ui.image{ static = "icons/16/cross.png" }
    16     end
    17   end }
    19   ui.container{ attr = { class = "bar" }, content = function()
    20     if initiative.issue.fully_frozen and initiative.issue.closed then
    21       if initiative.issue.ranks_available then 
    22         if initiative.negative_votes and initiative.positive_votes then
    23           local max_value = initiative.issue.voter_count
    24           ui.bargraph{
    25             max_value = max_value,
    26             width = 100,
    27             bars = {
    28               { color = "#0a0", value = initiative.positive_votes },
    29               { color = "#aaa", value = max_value - initiative.negative_votes - initiative.positive_votes },
    30               { color = "#a00", value = initiative.negative_votes },
    31             }
    32           }
    33         else
    34           slot.put(" ")
    35         end
    36       else
    37         slot.put(_"Counting of votes")
    38       end
    39     else
    40       local max_value = initiative.issue.population or 0
    41       ui.bargraph{
    42         max_value = max_value,
    43         width = 100,
    44         quorum = max_value * (initiative.issue.policy.initiative_quorum_num / initiative.issue.policy.initiative_quorum_den),
    45         quorum_color = "#00F",
    46         bars = {
    47           { color = "#0a0", value = (initiative.satisfied_supporter_count or 0) },
    48           { color = "#999", value = (initiative.supporter_count or 0) - (initiative.satisfied_supporter_count or 0) },
    49           { color = "#ddd", value = max_value - (initiative.supporter_count or 0) },
    50         }
    51       }
    52     end
    53   end }
    55   ui.container{ attr = { class = "interest" }, content = function()
    56     if initiative.is_initiator then
    57       local label = _"You are initiator of this initiative"
    58       ui.image{
    59         attr = { alt = label, title = label },
    60         static = "icons/16/user_edit.png"
    61       }
    62     elseif initiative.is_supporter then
    63       local label = _"You are supporter of this initiative"
    64       ui.image{
    65         attr = { alt = label, title = label },
    66         static = "icons/16/thumb_up_green.png"
    67       }
    68     elseif initiative.is_potential_supporter then
    69       local label = _"You are potentially supporter of this initiative"
    70       ui.image{
    71         attr = { alt = label, title = label },
    72         static = "icons/16/thumb_up.png"
    73       }
    74     elseif initiative.is_supporter_via_delegation then
    75       local label = _"You are supporter of this initiative via delegation"
    76       ui.image{
    77         attr = { alt = label, title = label },
    78         static = "icons/16/thumb_up_green.png"
    79       }
    80     end
    81   end }
    83   ui.container{ attr = { class = "name" }, content = function()
    84     local link_class = "initiative_link"
    85     if initiative.revoked then
    86       link_class = "revoked"
    87     end
    88     if selected then
    89       link_class = link_class .. " selected"
    90     end
    91     if initiative.is_supporter then
    92       link_class = link_class .. " supported"
    93     end
    94     if initiative.is_potential_supporter then
    95       link_class = link_class .. " potentially_supported"
    96     end
    97     if initiative.is_supporter_via_delegation then
    98       link_class = link_class .. " supported"
    99     end
   100     ui.link{
   101       attr = { class = link_class },
   102       content = function()
   103         local name
   104         if initiative.name_highlighted then
   105           name = encode.highlight(initiative.name_highlighted)
   106         else
   107           name = encode.html(initiative.shortened_name)
   108         end
   109         ui.tag{ content = "i" .. initiative.id .. ": " }
   110         slot.put(name)
   111       end,
   112       module  = "initiative",
   113       view    = "show",
   114       id      = initiative.id
   115     }
   117   end }
   119 end }
