liquid_feedback_frontend

annotate app/main/initiative/_sidebar_state.lua @ 1376:2ff3ae341a6e

Check optional checkbox in action
author bsw
date Wed Aug 08 17:28:10 2018 +0200 (2018-08-08)
parents 32cc544d5a5b
children 7cdc537f991f
rev   line source
bsw@1045 1 local initiative = param.get("initiative", "table")
bsw@1045 2
bsw@1045 3
bsw@1045 4 -- voting results
bsw@1045 5 if initiative.issue.fully_frozen and initiative.issue.closed and initiative.admitted
bsw@1045 6 and initiative.issue.voter_count then
bsw@1045 7 local class = initiative.winner and "sectionRow admitted_info" or "sectionRow not_admitted_info"
bsw@1045 8 ui.container{
bsw@1045 9 attr = { class = class },
bsw@1045 10 content = function()
bsw@1045 11 local max_value = initiative.issue.voter_count
bsw@1045 12 local positive_votes = initiative.positive_votes
bsw@1045 13 local negative_votes = initiative.negative_votes
bsw@1045 14 local abstention_votes = max_value -
bsw@1045 15 negative_votes -
bsw@1045 16 positive_votes
bsw@1045 17 local head_text
bsw/jbe@1309 18
bsw/jbe@1309 19 util.initiative_pie( initiative )
bsw/jbe@1309 20
bsw@1045 21 if initiative.winner then
bsw@1045 22 head_text = _"Approved"
bsw@1045 23 elseif initiative.rank then
bsw@1045 24 head_text = _("Rejected (rank #{rank})", { rank = initiative.rank })
bsw@1045 25 else
bsw@1045 26 head_text = _"Rejected"
bsw@1045 27 end
bsw@1045 28
bsw@1045 29 ui.heading { level = 1, content = head_text }
bsw@1045 30
bsw@1045 31 ui.tag { tag = "table", content = function ()
bsw@1045 32 ui.tag { tag = "tr", attr = { class = "yes" }, content = function ()
bsw@1045 33 ui.tag { tag = "td", content =
bsw@1045 34 tostring(positive_votes)
bsw@1045 35 }
bsw@1045 36 ui.tag { tag = "th", content = _"Yes" }
bsw@1045 37 ui.tag { tag = "td", content =
bsw@1210 38 format.percent_floor(positive_votes, max_value)
bsw@1045 39 }
bsw@1045 40 ui.tag { tag = "th", content = _"Yes" }
bsw@1045 41 end }
bsw/jbe@1309 42 ui.tag { tag = "tr", attr = { class = "no" }, content = function ()
bsw/jbe@1309 43 ui.tag { tag = "td", content =
bsw/jbe@1309 44 tostring(negative_votes)
bsw/jbe@1309 45 }
bsw/jbe@1309 46 ui.tag { tag = "th", content = _"No" }
bsw/jbe@1309 47 ui.tag { tag = "td", content =
bsw/jbe@1309 48 format.percent_floor(negative_votes, max_value)
bsw/jbe@1309 49 }
bsw/jbe@1309 50 ui.tag { tag = "th", content = _"No" }
bsw/jbe@1309 51 end }
bsw@1045 52 ui.tag { tag = "tr", attr = { class = "abstention" }, content = function ()
bsw@1045 53 ui.tag { tag = "td", content =
bsw@1045 54 tostring(abstention_votes)
bsw@1045 55 }
bsw@1045 56 ui.tag { tag = "th", content = _"Abstention" }
bsw@1045 57 ui.tag { tag = "td", content =
bsw@1210 58 format.percent_floor(abstention_votes, max_value)
bsw@1045 59 }
bsw@1045 60 ui.tag { tag = "th", content = _"Abstention" }
bsw@1045 61 end }
bsw@1045 62 end }
bsw@1045 63 end
bsw@1045 64 }
bsw@1045 65 end
bsw@1045 66
bsw@1045 67 -- initiative not admitted info
bsw@1045 68 if initiative.admitted == false then
bsw@1045 69 local policy = initiative.issue.policy
bsw@1045 70 ui.container{
bsw@1045 71 attr = { class = "sectionRow not_admitted_info" },
bsw@1045 72 content = function ()
bsw@1045 73 ui.heading { level = 1, content = _"Initiative not admitted" }
bsw@1045 74 ui.container { content = _("This initiative has not been admitted! It failed the 2nd quorum of #{quorum}.", { quorum = format.percentage ( policy.initiative_quorum_num / policy.initiative_quorum_den ) } ) }
bsw@1045 75 end
bsw@1045 76 }
bsw@1045 77 end
bsw@1045 78
bsw@1045 79 -- initiative revoked info
bsw@1045 80 if initiative.revoked then
bsw@1045 81 ui.container{
bsw@1045 82 attr = { class = "sectionRow revoked_info" },
bsw@1045 83 content = function()
bsw@1045 84 ui.heading { level = 1, content = _"Initiative revoked" }
bsw@1045 85 slot.put(_("This initiative has been revoked at #{revoked} by:", {
bsw@1045 86 revoked = format.timestamp(initiative.revoked)
bsw@1045 87 }))
bsw@1045 88 slot.put(" ")
bsw@1053 89 if app.session:has_access("authors_pseudonymous") then
bsw@1053 90 ui.link{
bsw@1053 91 module = "member", view = "show", id = initiative.revoked_by_member_id,
bsw@1053 92 content = initiative.revoked_by_member.name
bsw@1053 93 }
bsw@1053 94 else
bsw@1055 95 ui.tag{ content = _"[Not public]" }
bsw@1053 96 end
bsw@1045 97 local suggested_initiative = initiative.suggested_initiative
bsw@1045 98 if suggested_initiative then
bsw@1045 99 slot.put("<br /><br />")
bsw@1045 100 slot.put(_("The initiators suggest to support the following initiative:"))
bsw@1045 101 slot.put("<br />")
bsw@1045 102 ui.link{
bsw@1045 103 content = suggested_initiative.display_name,
bsw@1045 104 module = "initiative",
bsw@1045 105 view = "show",
bsw@1045 106 id = suggested_initiative.id
bsw@1045 107 }
bsw@1045 108 end
bsw@1045 109 end
bsw@1045 110 }
bsw@1045 111 end
bsw/jbe@1309 112

Impressum / About Us