liquid_feedback_frontend
view app/main/initiative/_list_element.lua @ 311:b3506522d043
Fixed a translation
| author | bsw | 
|---|---|
| date | Mon Feb 27 16:18:56 2012 +0100 (2012-02-27) | 
| parents | 44f9a09ea51c | 
| children | 5e6bdf07e3a1 | 
 line source
     1 local initiative = param.get("initiative", "table")
     2 local selected = param.get("selected", atom.boolean)
     4 local head_name = "initiative_head_" ..    tostring(initiative.id)
     5 local link_name = "initiative_link_" ..    tostring(initiative.id)
     6 local name      = "initiative_content_" .. tostring(initiative.id)
     7 local icon_name = "initiative_icon_" ..    tostring(initiative.id)
     9 ui.container{
    10   attr = { class = "ui_tabs" .. (initiative.id == for_initiative_id and " active" or "") },
    11   content = function()
    12     local module = "initiative"
    13     local view = "show"
    14     local id = initiative.id
    15     local params = {}
    16     ui.container{
    17       attr = {
    18         name = name,
    19         class = "ui_tabs_accordeon_head",
    20         id = head_name,
    21       },
    22       content = function()
    24         ui.list{
    25           attr = { class = "nohover" },
    26           records = { { a = 1} },
    27           columns = {
    28             {
    29               field_attr = { style = "width: 3em; text-align: center;"},
    30               content = function()
    31                 if initiative.issue.accepted and initiative.issue.closed and initiative.issue.ranks_available or initiative.admitted == false then 
    32                   ui.field.rank{ image_attr = { id = icon_name }, attr = { class = "rank" }, value = initiative.rank }
    33                 else
    34                   slot.put(" ")
    35                 end
    36               end
    37             },
    39             {
    40               field_attr = { style = "width: 110px;"},
    41               content = function()
    42                 if initiative.issue.fully_frozen and initiative.issue.closed then
    43                   if initiative.issue.ranks_available then 
    44                     if initiative.negative_votes and initiative.positive_votes then
    45                       local max_value = initiative.issue.voter_count
    46                       ui.bargraph{
    47                         max_value = max_value,
    48                         width = 100,
    49                         bars = {
    50                           { color = "#0a0", value = initiative.positive_votes },
    51                           { color = "#aaa", value = max_value - initiative.negative_votes - initiative.positive_votes },
    52                           { color = "#a00", value = initiative.negative_votes },
    53                         }
    54                       }
    55                     else
    56                       slot.put(" ")
    57                     end
    58                   else
    59                     slot.put(_"Counting of votes")
    60                   end
    61                 else
    62                   local max_value = initiative.issue.population or 0
    63                   ui.bargraph{
    64                     max_value = max_value,
    65                     width = 100,
    66                     quorum = max_value * (initiative.issue.policy.initiative_quorum_num / initiative.issue.policy.initiative_quorum_den),
    67                     quorum_color = "#00F",
    68                     bars = {
    69                       { color = "#0a0", value = (initiative.satisfied_supporter_count or 0) },
    70                       { color = "#bbb", value = (initiative.supporter_count or 0) - (initiative.satisfied_supporter_count or 0) },
    71                       { color = "#eee", value = max_value - (initiative.supporter_count or 0) },
    72                     }
    73                   }
    74                 end
    75               end
    76             },
    78             {
    79               content = function()
    80                 local link_class = "initiative_link"
    81                 if initiative.revoked then
    82                   link_class = "revoked"
    83                 end
    84                 if selected then
    85                   link_class = link_class .. " selected"
    86                 end
    87                 if initiative.is_supporter then
    88                   link_class = link_class .. " supported"
    89                 end
    90                 if initiative.is_potential_supporter then
    91                   link_class = link_class .. " potentially_supported"
    92                 end
    93                 if initiative.is_supporter_via_delegation then
    94                   link_class = link_class .. " supported"
    95                 end
    96                 ui.link{
    97                   attr = { id = link_name, class = link_class },
    98                   content = function()
    99                     local name
   100                     if initiative.name_highlighted then
   101                       name = encode.highlight(initiative.name_highlighted)
   102                     else
   103                       name = encode.html(initiative.shortened_name)
   104                     end
   105                     ui.tag{ content = "i" .. initiative.id .. ": " }
   106                     slot.put(name)
   107                   end,
   108                   module  = module,
   109                   view    = view,
   110                   id      = id,
   111                   params  = params,
   112                 }
   114                 if initiative.is_supporter then
   115                   slot.put(" ")
   116                   local label = _"You are supporter of this initiative"
   117                   ui.image{
   118                     attr = { alt = label, title = label },
   119                     static = "icons/16/thumb_up_green.png"
   120                   }
   121                 end
   123                 if initiative.is_supporter_via_delegation then
   124                   slot.put(" ")
   125                   local label = _"You are supporter of this initiative via delegation"
   126                   ui.image{
   127                     attr = { alt = label, title = label },
   128                     static = "icons/16/thumb_up_green.png"
   129                   }
   130                 end
   132                 if initiative.is_initiator then
   133                   slot.put(" ")
   134                   local label = _"You are initiator of this initiative"
   135                   ui.image{
   136                     attr = { alt = label, title = label },
   137                     static = "icons/16/user_edit.png"
   138                   }
   139                 end
   141               end
   142             }
   143           }
   144         }
   145       end
   146     }
   147   end
   148 }
   150 if ui.is_partial_loading_enabled() then
   151   ui.container{
   152     attr = {
   153       id = name,
   154       class = "ui_tabs_accordeon_content",
   155     },
   156     content = function()
   157       ui.container{
   158         attr = { id = name .. "_content", style = "clear: left;" },
   159         content = function()
   160           execute.view{
   161             module = "initiative",
   162             view = "show_partial",
   163             params = {
   164               initiative = initiative,
   165             }
   166           }
   167         end
   168       }
   169     end
   170   }
   171 end
