liquid_feedback_frontend
view app/main/initiative/_list_element.lua @ 1125:71eb36b43e76
Added missing translation function calls in initiative show view
| author | bsw | 
|---|---|
| date | Wed Dec 24 12:10:54 2014 +0100 (2014-12-24) | 
| parents | 701a5cf6b067 | 
| children | 904f6807f7fa | 
 line source
     1 local initiative = param.get("initiative", "table")
     2 local for_event = param.get("for_event", atom.boolean)
     4 local issue = initiative.issue
     6 local class = "initiative"
     8 if initiative.rank == 1 then
     9   class = class .. " rank1"
    10 end
    12 if initiative.revoked then
    13   class = class .. " revoked"
    14 end
    16 ui.container{
    17   attr = { class = class },
    18   content = function ()
    19     if initiative.rank ~= 1 and not for_event then
    20       execute.view {
    21         module = "initiative", view = "_bargraph", params = {
    22           initiative = initiative,
    23           battled_initiative = issue.initiatives[1]
    24         }
    25       }
    26       slot.put(" ")
    27     end
    28     ui.tag {
    29       attr = { class = "initiative_name" },
    30       content = function()
    31         ui.link {
    32           text = initiative.display_name,
    33           module = "initiative", view = "show", id = initiative.id
    34         }
    35         slot.put(" ")
    36         if initiative.vote_grade ~= nil then
    37           if initiative.vote_grade > 0 then
    38             local text = _"voted yes"
    39             ui.image { attr = { class = "icon16", title = text, alt = text }, static = "icons/32/support_satisfied.png" }
    40           elseif initiative.vote_grade == 0 then
    41           elseif initiative.vote_grade < 0 then
    42             local text = _"voted no"
    43             ui.image { attr = { class = "icon16", title = text, alt = text }, static = "icons/32/voted_no.png" }
    44           end
    45         elseif app.session.member then
    46           if initiative.member_info.supported then
    47             if initiative.member_info.satisfied then
    48               local text = _"supporter"
    49               ui.image { attr = { class = "icon16", title = text, alt = text }, static = "icons/32/support_satisfied.png" }
    50             else
    51               local text = _"supporter with restricting suggestions"
    52               ui.image { attr = { class = "icon16", title = text, alt = text }, static = "icons/32/support_unsatisfied.png" }
    53             end           
    54           end
    55         end
    56       end
    57     }
    59   end
    60 }
    62 if initiative.rank == 1 
    63   and issue.voter_count 
    64   and initiative.positive_votes ~= nil 
    65   and initiative.negative_votes ~= nil 
    66   and not for_event
    67 then
    68   function percent(p, q)
    69     if q > 0 then
    70       return math.floor(p / q * 100) .. "%"
    71     else
    72       return "0%"
    73     end
    74   end
    75   local result = ""
    76   if initiative.eligible then
    77     result = _("Reached #{sign}#{num}/#{den}", {
    78       sign = issue.policy.direct_majority_strict and ">" or "≥",
    79       num = issue.policy.direct_majority_num,
    80       den = issue.policy.direct_majority_den
    81     })
    82   else
    83     result = _("Failed  #{sign}#{num}/#{den}", {
    84       sign = issue.policy.direct_majority_strict and ">" or "≥",
    85       num = issue.policy.direct_majority_num,
    86       den = issue.policy.direct_majority_den
    87     })
    88   end
    89   local neutral_count = issue.voter_count - initiative.positive_votes - initiative.negative_votes
    91   local result_text 
    93   if issue.voter_count > 0 then
    94     result_text = _("#{result}: #{yes_count} Yes (#{yes_percent}), #{no_count} No (#{no_percent}), #{neutral_count} Abstention (#{neutral_percent})", {
    95       result = result,
    96       yes_count = initiative.positive_votes,
    97       yes_percent = percent(initiative.positive_votes, issue.voter_count),
    98       neutral_count = neutral_count,
    99       neutral_percent = percent(neutral_count, issue.voter_count),
   100       no_count = initiative.negative_votes,
   101       no_percent = percent(initiative.negative_votes, issue.voter_count)
   102     })
   103   else
   104     result_text = _("#{result}: No votes (0)", { result = result })
   105   end
   107   ui.container { attr = { class = "result" }, content = result_text }
   109 end
