liquid_feedback_frontend
view app/main/initiative/_list_element.lua @ 639:1e4c61b4ef46
Removed unnecessary newline
| author | bsw | 
|---|---|
| date | Mon Jun 25 19:41:45 2012 +0200 (2012-06-25) | 
| parents | 53f93f0ffa6e | 
| children | ea89fa21b0ab | 
 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       local quorum
    42       if initiative.issue.accepted then
    43         quorum = initiative.issue.policy.initiative_quorum_num / initiative.issue.policy.initiative_quorum_den
    44       else
    45         quorum = initiative.issue.policy.issue_quorum_num / initiative.issue.policy.issue_quorum_den
    46       end
    47       ui.bargraph{
    48         max_value = max_value,
    49         width = 100,
    50         quorum = max_value * quorum,
    51         quorum_color = "#00F",
    52         bars = {
    53           { color = "#0a0", value = (initiative.satisfied_supporter_count or 0) },
    54           { color = "#999", value = (initiative.supporter_count or 0) - (initiative.satisfied_supporter_count or 0) },
    55           { color = "#ddd", value = max_value - (initiative.supporter_count or 0) },
    56         }
    57       }
    58     end
    59   end }
    61   if app.session.member_id then
    62     ui.container{ attr = { class = "interest" }, content = function()
    63       if initiative.member_info.initiated then
    64         local label = _"You are initiator of this initiative"
    65         ui.image{
    66           attr = { alt = label, title = label },
    67           static = "icons/16/user_edit.png"
    68         }
    69       elseif initiative.member_info.directly_supported then
    70         if initiative.member_info.satisfied then
    71           local label = _"You are supporter of this initiative"
    72           ui.image{
    73             attr = { alt = label, title = label },
    74             static = "icons/16/thumb_up_green.png"
    75           }
    76         else
    77           local label = _"You are potential supporter of this initiative"
    78           ui.image{
    79             attr = { alt = label, title = label },
    80             static = "icons/16/thumb_up.png"
    81           }
    82         end
    83       elseif initiative.member_info.supported then
    84         if initiative.member_info.satisfied then
    85           local label = _"You are supporter of this initiative via delegation"
    86           ui.image{
    87             attr = { alt = label, title = label },
    88             static = "icons/16/thumb_up_green_arrow.png"
    89           }
    90         else
    91           local label = _"You are potential supporter of this initiative via delegation"
    92           ui.image{
    93             attr = { alt = label, title = label },
    94             static = "icons/16/thumb_up_arrow.png"
    95           }
    96         end
    97       end
    98     end }
    99   end
   101   ui.container{ attr = { class = "name" }, content = function()
   102     local link_class = "initiative_link"
   103     if initiative.revoked then
   104       link_class = "revoked"
   105     end
   106     if selected then
   107       link_class = link_class .. " selected"
   108     end
   109     if initiative.is_supporter then
   110       link_class = link_class .. " supported"
   111     end
   112     if initiative.is_potential_supporter then
   113       link_class = link_class .. " potentially_supported"
   114     end
   115     if initiative.is_supporter_via_delegation then
   116       link_class = link_class .. " supported"
   117     end
   118     ui.link{
   119       attr = { class = link_class },
   120       content = function()
   121         local name
   122         if initiative.name_highlighted then
   123           name = encode.highlight(initiative.name_highlighted)
   124         else
   125           name = encode.html(initiative.shortened_name)
   126         end
   127         ui.tag{ content = "i" .. initiative.id .. ": " }
   128         slot.put(name)
   129       end,
   130       module  = "initiative",
   131       view    = "show",
   132       id      = initiative.id
   133     }
   135   end }
   137 end }
