liquid_feedback_frontend
view app/main/initiative/_list_element.lua @ 1360:7fbe8b516c2b
Fixed syntax error
| author | bsw | 
|---|---|
| date | Mon Aug 06 13:59:24 2018 +0200 (2018-08-06) | 
| parents | 32cc544d5a5b | 
| children | 97dfef4eb2d7 | 
 line source
     1 local initiative = param.get("initiative", "table")
     2 local for_event = param.get("for_event", atom.boolean)
     3 local for_member = param.get("for_member", "table")
     5 local issue = initiative.issue
     7 if initiative.vote_grade ~= nil then
     8   if initiative.vote_grade > 0 then
     9     local text = _"voted yes"
    10     ui.container{ attr = { class = "mdl-list__item-avatar positive" }, content = function()
    11       ui.tag{ tag = "i", attr = { class = "material-icons", title = text }, content = "thumb_up" }
    12     end }
    13   elseif initiative.vote_grade == 0 then
    14   elseif initiative.vote_grade < 0 then
    15     local text = _"voted no"
    16     ui.container{ attr = { class = "mdl-list__item-avatar negative" }, content = function()
    17       ui.tag{ tag = "i", attr = { class = "material-icons", title = text }, content = "thumb_down" }
    18     end }
    19   end
    20 end
    22 local class = "initiative  mdl-list__item-primary-content"
    23 if initiative.rank == 1 then
    24   class = class .. " rank1"
    25 end
    26 if initiative.revoked then
    27   class = class .. " revoked"
    28 end
    30 ui.container{
    31   attr = { class = class },
    32   content = function ()
    33     ui.container {
    34       attr = { class = "initiative_name" },
    35       content = function()
    36         if not for_member and app.session.member then
    37           if initiative.member_info.supported then
    38             if initiative.member_info.satisfied then
    39               ui.tag{ tag = "i", attr = { id = "lf-initiative__support-" .. initiative.id, class = "material-icons material-icons-small" }, content = "thumb_up" }
    40               --ui.container { attr = { class = "mdl-tooltip", ["for"] = "lf-initiative__support-" .. initiative.id }, content = _"You are supporter of this initiative" }
    41             else
    42               ui.tag{ tag = "i", attr = { id = "lf-initiative__support-" .. initiative.id, class = "material-icons material-icons-small mdl-color-text--orange-500" }, content = "thumb_up" }
    43               --ui.container { attr = { class = "mdl-tooltip", ["for"] = "lf-initiative__support-" .. initiative.id }, content = _"supporter with restricting suggestions" }
    44             end 
    45             slot.put(" ")
    46           end
    47         end
    48         ui.link {
    49           text = initiative.display_name,
    50           module = "initiative", view = "show", id = initiative.id
    51         }
    52       end
    53     }
    54     ui.container{ attr = { class = "mdl-list__item-text-body" }, content = function()
    55       local draft_content = initiative.current_draft.content
    56       if config.initiative_abstract then
    57         local abstract = string.match(draft_content, "(.+)<!%--END_OF_ABSTRACT%-->")
    58         if abstract then
    59           slot.put(abstract)
    60         end
    61       end
    62       if not config.voting_only then
    63         if app.session:has_access("authors_pseudonymous") then
    64           local initiator_members = initiative:get_reference_selector("initiating_members")
    65             :add_field("initiator.accepted", "accepted")
    66             :add_order_by("member.name")
    67             :add_where("initiator.accepted")
    68             :exec()
    70           local initiators = {}
    71           for i, member in ipairs(initiator_members) do
    72             if member.accepted then
    73               initiators[#initiators+1] = member.name
    74             end
    75           end
    76           ui.tag{ content = _"by" }
    77           slot.put(" ")
    78           ui.tag{ content = table.concat(initiators, ", ") }
    79           slot.put("<br />")
    80         end
    81       end
    82       if initiative.rank ~= 1 and (issue.voter_count == nil or issue.voter_count > 0) and not for_event then
    83         if not config.voting_only or issue.closed then
    84           execute.view {
    85             module = "initiative", view = "_bargraph", params = {
    86               initiative = initiative,
    87               battled_initiative = issue.initiatives[1]
    88             }
    89           }
    91           slot.put("   ")
    93           ui.supporter_count(initiative)
    94         end
    95       end
    97       if initiative.positive_votes ~= nil then
    99         local result_text 
   101         if issue.voter_count == 0 then
   102           result_text = _("No votes (0)", { result = result })
   104         elseif initiative.rank == 1 and not for_event then
   105           local result = ""
   106           if initiative.eligible then
   107             result = _("Reached #{sign}#{num}/#{den}", {
   108               sign = issue.policy.direct_majority_strict and ">" or "≥",
   109               num = issue.policy.direct_majority_num,
   110               den = issue.policy.direct_majority_den
   111             })
   112           else
   113             result = _("Failed  #{sign}#{num}/#{den}", {
   114               sign = issue.policy.direct_majority_strict and ">" or "≥",
   115               num = issue.policy.direct_majority_num,
   116               den = issue.policy.direct_majority_den
   117             })
   118           end
   119           local neutral_count = issue.voter_count - initiative.positive_votes - initiative.negative_votes
   121           result_text = _("#{result}: #{yes_count} Yes (#{yes_percent}), #{no_count} No (#{no_percent}), #{neutral_count} Abstention (#{neutral_percent})", {
   122             result = result,
   123             yes_count = initiative.positive_votes,
   124             yes_percent = format.percent_floor(initiative.positive_votes, issue.voter_count),
   125             neutral_count = neutral_count,
   126             neutral_percent = format.percent_floor(neutral_count, issue.voter_count),
   127             no_count = initiative.negative_votes,
   128             no_percent = format.percent_floor(initiative.negative_votes, issue.voter_count)
   129           })
   131         end
   133         ui.container { attr = { class = "result" }, content = result_text }
   135       end
   137     end }
   139   end
   140 }
