liquid_feedback_frontend
view app/main/initiative/_list_element.lua @ 782:e370594368e8
Optical enhancements
| author | bsw | 
|---|---|
| date | Fri Jun 29 00:10:17 2012 +0200 (2012-06-29) | 
| parents | 21ae6ff8629a | 
| children | a1ff5d08f0f4 | 
 line source
     1 local initiative = param.get("initiative", "table")
     2 local selected = param.get("selected", atom.boolean)
     4 local class = "initiative"
     6 if selected then
     7   class = class .. " selected"
     8 end
    10 ui.container{ attr = { class = class }, content = function()
    12   ui.container{ attr = { class = "rank" }, content = function()
    13     if initiative.issue.accepted and initiative.issue.closed
    14       and initiative.issue.ranks_available or initiative.admitted == false
    15     then 
    16       ui.field.rank{ attr = { class = "rank" }, value = initiative.rank, eligible = initiative.eligible }
    17     elseif not initiative.issue.closed then
    18       ui.image{ static = "icons/16/script.png" }
    19     else
    20       ui.image{ static = "icons/16/cross.png" }
    21     end
    22   end }
    24   ui.container{ attr = { class = "bar" }, content = function()
    25     if initiative.issue.fully_frozen and initiative.issue.closed then
    26       if initiative.issue.ranks_available then 
    27         if initiative.negative_votes and initiative.positive_votes then
    28           local max_value = initiative.issue.voter_count
    29           ui.bargraph{
    30             max_value = max_value,
    31             width = 100,
    32             bars = {
    33               { color = "#0a5", value = initiative.positive_votes },
    34               { color = "#aaa", value = max_value - initiative.negative_votes - initiative.positive_votes },
    35               { color = "#a00", value = initiative.negative_votes },
    36             }
    37           }
    38         else
    39           slot.put(" ")
    40         end
    41       else
    42         slot.put(_"Counting of votes")
    43       end
    44     else
    45       local max_value = initiative.issue.population or 0
    46       local quorum
    47       if initiative.issue.accepted then
    48         quorum = initiative.issue.policy.initiative_quorum_num / initiative.issue.policy.initiative_quorum_den
    49       else
    50         quorum = initiative.issue.policy.issue_quorum_num / initiative.issue.policy.issue_quorum_den
    51       end
    52       ui.bargraph{
    53         max_value = max_value,
    54         width = 100,
    55         quorum = max_value * quorum,
    56         quorum_color = "#00F",
    57         bars = {
    58           { color = "#0a5", value = (initiative.satisfied_supporter_count or 0) },
    59           { color = "#aaa", value = (initiative.supporter_count or 0) - (initiative.satisfied_supporter_count or 0) },
    60           { color = "#fff", value = max_value - (initiative.supporter_count or 0) },
    61         }
    62       }
    63     end
    64   end }
    66   if app.session.member_id then
    67     ui.container{ attr = { class = "interest" }, content = function()
    68       if initiative.member_info.initiated then
    69         local label = _"You are initiator of this initiative"
    70         ui.image{
    71           attr = { alt = label, title = label },
    72           static = "icons/16/user_edit.png"
    73         }
    74       elseif initiative.member_info.directly_supported then
    75         if initiative.member_info.satisfied then
    76           local label = _"You are supporter of this initiative"
    77           ui.image{
    78             attr = { alt = label, title = label },
    79             static = "icons/16/thumb_up_green.png"
    80           }
    81         else
    82           local label = _"You are potential supporter of this initiative"
    83           ui.image{
    84             attr = { alt = label, title = label },
    85             static = "icons/16/thumb_up.png"
    86           }
    87         end
    88       elseif initiative.member_info.supported then
    89         if initiative.member_info.satisfied then
    90           local label = _"You are supporter of this initiative via delegation"
    91           ui.image{
    92             attr = { alt = label, title = label },
    93             static = "icons/16/thumb_up_green_arrow.png"
    94           }
    95         else
    96           local label = _"You are potential supporter of this initiative via delegation"
    97           ui.image{
    98             attr = { alt = label, title = label },
    99             static = "icons/16/thumb_up_arrow.png"
   100           }
   101         end
   102       end
   103     end }
   104   end
   106   ui.container{ attr = { class = "name" }, content = function()
   107     local link_class = "initiative_link"
   108     if initiative.revoked then
   109       link_class = "revoked"
   110     end
   111     ui.link{
   112       attr = { class = link_class },
   113       content = function()
   114         local name
   115         if initiative.name_highlighted then
   116           name = encode.highlight(initiative.name_highlighted)
   117         else
   118           name = encode.html(initiative.shortened_name)
   119         end
   120         ui.tag{ content = "i" .. initiative.id .. ": " }
   121         slot.put(name)
   122       end,
   123       module  = "initiative",
   124       view    = "show",
   125       id      = initiative.id
   126     }
   128   end }
   130 end }
