liquid_feedback_frontend
view app/main/initiative/_list_element.lua @ 1218:bb10f001443e
Fixed syntax error in unit sidebar occured after last bug fix again again
| author | bsw | 
|---|---|
| date | Mon Jul 27 23:33:26 2015 +0200 (2015-07-27) | 
| parents | 7e48d429389f | 
| children | 32cc544d5a5b | 
 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   local result = ""
    69   if initiative.eligible then
    70     result = _("Reached #{sign}#{num}/#{den}", {
    71       sign = issue.policy.direct_majority_strict and ">" or "≥",
    72       num = issue.policy.direct_majority_num,
    73       den = issue.policy.direct_majority_den
    74     })
    75   else
    76     result = _("Failed  #{sign}#{num}/#{den}", {
    77       sign = issue.policy.direct_majority_strict and ">" or "≥",
    78       num = issue.policy.direct_majority_num,
    79       den = issue.policy.direct_majority_den
    80     })
    81   end
    82   local neutral_count = issue.voter_count - initiative.positive_votes - initiative.negative_votes
    84   local result_text 
    86   if issue.voter_count > 0 then
    87     result_text = _("#{result}: #{yes_count} Yes (#{yes_percent}), #{no_count} No (#{no_percent}), #{neutral_count} Abstention (#{neutral_percent})", {
    88       result = result,
    89       yes_count = initiative.positive_votes,
    90       yes_percent = format.percent_floor(initiative.positive_votes, issue.voter_count),
    91       neutral_count = neutral_count,
    92       neutral_percent = format.percent_floor(neutral_count, issue.voter_count),
    93       no_count = initiative.negative_votes,
    94       no_percent = format.percent_floor(initiative.negative_votes, issue.voter_count)
    95     })
    96   else
    97     result_text = _("#{result}: No votes (0)", { result = result })
    98   end
   100   ui.container { attr = { class = "result" }, content = result_text }
   102 end
