liquid_feedback_frontend
view app/main/initiative/_list_element.lua @ 362:f0a59bbf659a
Search only for activated members
| author | bsw | 
|---|---|
| date | Thu Mar 01 00:07:46 2012 +0100 (2012-03-01) | 
| parents | 7d6a3c411f99 | 
| children | 76d7eafb3893 | 
 line source
     1 local initiative = param.get("initiative", "table")
     2 local selected = param.get("selected", atom.boolean)
     4 ui.list{
     5   attr = { class = "nohover" },
     6   records = { { a = 1} },
     7   columns = {
     8     {
     9       field_attr = { style = "width: 3em; text-align: center;"},
    10       content = function()
    11         if
    12           initiative.issue.accepted and initiative.issue.closed
    13           and initiative.issue.ranks_available or initiative.admitted == false
    14         then 
    15           ui.field.rank{ attr = { class = "rank" }, value = initiative.rank, eligible = initiative.eligible }
    16         else
    17           slot.put(" ")
    18         end
    19       end
    20     },
    22     {
    23       field_attr = { style = "width: 100px;"},
    24       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 = "#0a0", 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           ui.bargraph{
    47             max_value = max_value,
    48             width = 100,
    49             quorum = max_value * (initiative.issue.policy.initiative_quorum_num / initiative.issue.policy.initiative_quorum_den),
    50             quorum_color = "#00F",
    51             bars = {
    52               { color = "#0a0", value = (initiative.satisfied_supporter_count or 0) },
    53               { color = "#bbb", value = (initiative.supporter_count or 0) - (initiative.satisfied_supporter_count or 0) },
    54               { color = "#f7f7f7", value = max_value - (initiative.supporter_count or 0) },
    55             }
    56           }
    57         end
    58       end
    59     },
    60     {
    61       field_attr = { style = "width: 24px;" },
    62       content = function()
    63         if initiative.is_initiator then
    64           slot.put(" ")
    65           local label = _"You are initiator of this initiative"
    66           ui.image{
    67             attr = { alt = label, title = label },
    68             static = "icons/16/user_edit.png"
    69           }
    70         elseif initiative.is_supporter then
    71           slot.put(" ")
    72           local label = _"You are supporter of this initiative"
    73           ui.image{
    74             attr = { alt = label, title = label },
    75             static = "icons/16/thumb_up_green.png"
    76           }
    77         elseif initiative.is_potential_supporter then
    78           slot.put(" ")
    79           local label = _"You are potentially supporter of this initiative"
    80           ui.image{
    81             attr = { alt = label, title = label },
    82             static = "icons/16/thumb_up.png"
    83           }
    84         elseif initiative.is_supporter_via_delegation then
    85           slot.put(" ")
    86           local label = _"You are supporter of this initiative via delegation"
    87           ui.image{
    88             attr = { alt = label, title = label },
    89             static = "icons/16/thumb_up_green.png"
    90           }
    91         end
    93       end
    94     },
    95     {
    96       content = function()
    97         local link_class = "initiative_link"
    98         if initiative.revoked then
    99           link_class = "revoked"
   100         end
   101         if selected then
   102           link_class = link_class .. " selected"
   103         end
   104         if initiative.is_supporter then
   105           link_class = link_class .. " supported"
   106         end
   107         if initiative.is_potential_supporter then
   108           link_class = link_class .. " potentially_supported"
   109         end
   110         if initiative.is_supporter_via_delegation then
   111           link_class = link_class .. " supported"
   112         end
   113         ui.link{
   114           attr = { class = link_class },
   115           content = function()
   116             local name
   117             if initiative.name_highlighted then
   118               name = encode.highlight(initiative.name_highlighted)
   119             else
   120               name = encode.html(initiative.shortened_name)
   121             end
   122             ui.tag{ content = "i" .. initiative.id .. ": " }
   123             slot.put(name)
   124           end,
   125           module  = "initiative",
   126           view    = "show",
   127           id      = initiative.id
   128         }
   130       end
   131     }
   132   }
   133 }
