bsw/jbe@19: local initiative = param.get("initiative", "table") bsw@1045: local for_event = param.get("for_event", atom.boolean) bsw/jbe@1309: local for_member = param.get("for_member", "table") bsw@1045: bsw@1045: local issue = initiative.issue bsw/jbe@19: bsw/jbe@1309: if initiative.vote_grade ~= nil then bsw/jbe@1309: if initiative.vote_grade > 0 then bsw/jbe@1309: local text = _"voted yes" bsw/jbe@1309: ui.container{ attr = { class = "mdl-list__item-avatar positive" }, content = function() bsw/jbe@1309: ui.tag{ tag = "i", attr = { class = "material-icons", title = text }, content = "thumb_up" } bsw/jbe@1309: end } bsw/jbe@1309: elseif initiative.vote_grade == 0 then bsw/jbe@1309: elseif initiative.vote_grade < 0 then bsw/jbe@1309: local text = _"voted no" bsw/jbe@1309: ui.container{ attr = { class = "mdl-list__item-avatar negative" }, content = function() bsw/jbe@1309: ui.tag{ tag = "i", attr = { class = "material-icons", title = text }, content = "thumb_down" } bsw/jbe@1309: end } bsw/jbe@1309: end bsw/jbe@1309: end bsw/jbe@19: bsw/jbe@1309: local class = "initiative mdl-list__item-primary-content" bsw@1045: if initiative.rank == 1 then bsw@1045: class = class .. " rank1" bsw@715: end bsw@1045: if initiative.revoked then bsw@1045: class = class .. " revoked" bsw@898: end bsw@898: bsw@1045: ui.container{ bsw@1045: attr = { class = class }, bsw@1045: content = function () bsw/jbe@1309: ui.container { bsw@1045: attr = { class = "initiative_name" }, bsw@1045: content = function() bsw/jbe@1309: if not for_member and app.session.member then bsw/jbe@1309: if initiative.member_info.supported then bsw/jbe@1309: if initiative.member_info.satisfied then bsw/jbe@1309: ui.tag{ tag = "i", attr = { id = "lf-initiative__support-" .. initiative.id, class = "material-icons material-icons-small" }, content = "thumb_up" } bsw/jbe@1309: --ui.container { attr = { class = "mdl-tooltip", ["for"] = "lf-initiative__support-" .. initiative.id }, content = _"You are supporter of this initiative" } bsw/jbe@1309: else bsw/jbe@1309: 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" } bsw/jbe@1309: --ui.container { attr = { class = "mdl-tooltip", ["for"] = "lf-initiative__support-" .. initiative.id }, content = _"supporter with restricting suggestions" } bsw/jbe@1309: end bsw/jbe@1309: slot.put(" ") bsw/jbe@1309: end bsw/jbe@1309: end bsw@1045: ui.link { bsw@1045: text = initiative.display_name, bsw@1045: module = "initiative", view = "show", id = initiative.id bsw@551: } bsw/jbe@1309: end bsw/jbe@1309: } bsw/jbe@1309: ui.container{ attr = { class = "mdl-list__item-text-body" }, content = function() bsw/jbe@1309: local draft_content = initiative.current_draft.content bsw/jbe@1309: if config.initiative_abstract then bsw/jbe@1309: local abstract = string.match(draft_content, "(.+)") bsw/jbe@1309: if abstract then bsw/jbe@1309: slot.put(abstract) bsw/jbe@1309: end bsw/jbe@1309: end bsw/jbe@1309: if not config.voting_only then bsw/jbe@1309: if app.session:has_access("authors_pseudonymous") then bsw/jbe@1309: local initiator_members = initiative:get_reference_selector("initiating_members") bsw/jbe@1309: :add_field("initiator.accepted", "accepted") bsw/jbe@1309: :add_order_by("member.name") bsw/jbe@1309: :add_where("initiator.accepted") bsw/jbe@1309: :exec() bsw/jbe@1309: bsw/jbe@1309: local initiators = {} bsw/jbe@1309: for i, member in ipairs(initiator_members) do bsw/jbe@1309: if member.accepted then bsw/jbe@1309: initiators[#initiators+1] = member.name bsw/jbe@1309: end bsw@862: end bsw/jbe@1309: ui.tag{ content = _"by" } bsw/jbe@1309: slot.put(" ") bsw/jbe@1309: ui.tag{ content = table.concat(initiators, ", ") } bsw/jbe@1309: slot.put("
") bsw@556: end bsw@551: end bsw/jbe@1309: if initiative.rank ~= 1 and (issue.voter_count == nil or issue.voter_count > 0) and not for_event then bsw/jbe@1309: if not config.voting_only or issue.closed then bsw/jbe@1309: execute.view { bsw/jbe@1309: module = "initiative", view = "_bargraph", params = { bsw/jbe@1309: initiative = initiative, bsw/jbe@1309: battled_initiative = issue.initiatives[1] bsw/jbe@1309: } bsw/jbe@1309: } bsw/jbe@1309: bsw/jbe@1309: slot.put("   ") bsw/jbe@1309: bsw/jbe@1309: ui.supporter_count(initiative) bsw/jbe@1309: end bsw/jbe@1309: end bsw/jbe@1309: bsw/jbe@1309: if initiative.positive_votes ~= nil then bsw/jbe@1309: bsw/jbe@1309: local result_text bsw/jbe@1309: bsw/jbe@1309: if issue.voter_count == 0 then bsw/jbe@1309: result_text = _("No votes (0)", { result = result }) bsw/jbe@1309: bsw/jbe@1309: elseif initiative.rank == 1 and not for_event then bsw/jbe@1309: local result = "" bsw/jbe@1309: if initiative.eligible then bsw/jbe@1309: result = _("Reached #{sign}#{num}/#{den}", { bsw/jbe@1309: sign = issue.policy.direct_majority_strict and ">" or "≥", bsw/jbe@1309: num = issue.policy.direct_majority_num, bsw/jbe@1309: den = issue.policy.direct_majority_den bsw/jbe@1309: }) bsw/jbe@1309: else bsw/jbe@1309: result = _("Failed #{sign}#{num}/#{den}", { bsw/jbe@1309: sign = issue.policy.direct_majority_strict and ">" or "≥", bsw/jbe@1309: num = issue.policy.direct_majority_num, bsw/jbe@1309: den = issue.policy.direct_majority_den bsw/jbe@1309: }) bsw/jbe@1309: end bsw/jbe@1309: local neutral_count = issue.voter_count - initiative.positive_votes - initiative.negative_votes bsw/jbe@1309: bsw/jbe@1309: result_text = _("#{result}: #{yes_count} Yes (#{yes_percent}), #{no_count} No (#{no_percent}), #{neutral_count} Abstention (#{neutral_percent})", { bsw/jbe@1309: result = result, bsw/jbe@1309: yes_count = initiative.positive_votes, bsw/jbe@1309: yes_percent = format.percent_floor(initiative.positive_votes, issue.voter_count), bsw/jbe@1309: neutral_count = neutral_count, bsw/jbe@1309: neutral_percent = format.percent_floor(neutral_count, issue.voter_count), bsw/jbe@1309: no_count = initiative.negative_votes, bsw/jbe@1309: no_percent = format.percent_floor(initiative.negative_votes, issue.voter_count) bsw/jbe@1309: }) bsw/jbe@1309: bsw/jbe@1309: end bsw/jbe@1309: bsw/jbe@1309: ui.container { attr = { class = "result" }, content = result_text } bsw/jbe@1309: bsw/jbe@1309: end bsw/jbe@1309: bsw/jbe@1309: end } bsw@1045: bsw@556: end bsw@1045: } bsw@1045: