bsw@211: slot.set_layout("lf2") bsw@211: bsw@213: slot.put_into("leftright_pre", '
') bsw@213: bsw@211: local initiative = Initiative:by_id(param.get_id()) bsw@211: bsw@211: local issue = initiative.issue bsw@213: issue:load("interest_for_member", { member_id = app.session.member_id }, "interest") bsw@211: bsw@211: local supporting_members_selector = Member:new_selector() bsw@211: :join("direct_supporter_snapshot", "dss", { "dss.issue_id = ? AND dss.initiative_id = ? AND dss.member_id = member.id and dss.event = (select latest_snapshot_event from issue where id = ?)", issue.id, initiative.id, issue.id }) bsw@211: :join("direct_interest_snapshot", "dis", { "dis.issue_id = ? AND dis.member_id = member.id and dis.event = (select latest_snapshot_event from issue where id = ?)", issue.id, issue.id }) bsw@211: :add_field("dis.weight", "weight") bsw@211: :add_order_by("dis.weight DESC") bsw@211: local supporting_members = supporting_members_selector:exec() bsw@211: bsw@211: local voting_members_selector = Member:new_selector() bsw@211: :join("direct_voter", nil, { "direct_voter.issue_id = ? AND direct_voter.member_id = member.id", issue.id }) bsw@211: :add_field("direct_voter.weight", "weight") bsw@211: :add_order_by("direct_voter.weight DESC") bsw@211: local voting_members = voting_members_selector:exec() bsw@211: bsw@211: local alternative_initiatives = initiative.issue.initiatives bsw@211: alternative_initiatives:load("initiating_members", nil, "initiating_members") bsw@211: bsw@215: local support = Supporter:by_pk(initiative.id, app.session.member.id) bsw@215: bsw@215: app.topnav_phase = issue.phase bsw@217: app.topnav_area_id = issue.area_id bsw@217: app.topnav_unit_id = issue.area.unit_id bsw@211: bsw@211: slot.select("sidebar", function() bsw@211: bsw@215: execute.view{ module = "lf2", view = "_sidebar_issue", params = { issue = issue, initiative_id = initiative.id, alternative_initiatives = alternative_initiatives } } bsw@215: bsw@211: execute.view{ module = "lf2", view = "_sidebar_drafts", params = { bsw@211: initiative = initiative bsw@211: } } bsw@211: bsw@211: end) bsw@211: bsw@211: local draft = initiative.current_draft bsw@211: bsw@211: ui.box{ bsw@211: content = function() bsw@211: bsw@217: ui.box_row{ class = "initiative head", content = function() ui.box_col { content = function() bsw@211: execute.view{ module = "lf2", view = "_initiative", params = { initiative = initiative } } bsw@211: end } end } bsw@211: bsw@217: if initiative.issue.closed then bsw@217: ui.box_row{ content = function() ui.box_col{ content = function() bsw@215: if initiative.issue.accepted then bsw@215: if initiative.admitted then bsw@215: if initiative.agreed then bsw@215: if initiative.rank == 1 then bsw@215: ui.image{ static = "lf2/icon_award_gold.png" } bsw@215: slot.put(" ") bsw@215: ui.tag{ content = _"Approved" } bsw@215: else bsw@215: ui.image{ static = "lf2/icon_award_silver.png" } bsw@215: slot.put(" ") bsw@215: ui.tag{ content = _("Not approved (rank #{rank})", { rank = initiative.rank }) } bsw@215: end bsw@215: else bsw@215: ui.image{ static = "lf2/icon_cross.png" } bsw@215: slot.put(" ") bsw@217: ui.tag{ content = _"Initiative not approved (no majority)" } bsw@215: end bsw@217: slot.put(" · ") bsw@217: ui.tag{ class = "yes_count", content = _("#{count} Yes", { count = initiative.positive_votes }) } bsw@217: slot.put(" · ") bsw@217: ui.tag{ class = "no_count", content = _("#{count} No", { count = initiative.negative_votes }) } bsw@217: slot.put(" · ") bsw@217: ui.tag{ class = "abstention_count", content = _("#{count} Abstention", { count = initiative.issue.voter_count - initiative.positive_votes - initiative.negative_votes }) } bsw@217: bsw@215: else bsw@215: ui.image{ static = "lf2/icon_cross.png" } bsw@215: slot.put(" ") bsw@217: ui.tag{ content = _"Initiative not admitted (quorum failed)" } bsw@215: end bsw@215: else bsw@215: ui.image{ static = "lf2/icon_cross.png" } bsw@215: slot.put(" ") bsw@217: ui.tag{ content = _"Issue not accepted (quorum failed)" } bsw@215: end bsw@217: end } end } bsw@217: end bsw@217: bsw@217: ui.box_row{ class = "", content = function() ui.box_col{ content = function() bsw@211: if initiative.issue.fully_frozen and initiative.issue.closed then bsw@215: if initiative.admitted and initiative.issue.ranks_available then bsw@215: ui.link{ external = "#votes", text = _("#{vote_count}+#{delegated_weight} votes", { vote_count = #voting_members, delegated_weight = initiative.issue.voter_count - #voting_members }) } bsw@217: slot.put(" · ") bsw@215: end bsw@215: end bsw@211: ui.link{ external = "#suggestions", text = _("#{suggestion_count} suggestions", { suggestion_count = 23 }) } bsw@211: slot.put(" · ") bsw@215: ui.link{ external = "#supporters", text = _("#{supporter_count}+#{delegated_weight} supporters", { supporter_count = #supporting_members, delegated_weight = initiative.supporter_count - #supporting_members }) } bsw@211: end } end } bsw@211: bsw@215: execute.view{ module = "lf2", view = "_initiative_support", params = { bsw@215: initiative = initiative bsw@215: } } bsw@215: bsw@215: ui.box_row{ class = "subhead", content = function() ui.box_col{ class = "head", content = _"Current draft" } end } bsw@217: ui.box_row{ class = "member_content", content = function() ui.box_col{ class = "draft", content = function() bsw@211: execute.view{ module = "lf2", view = "_draft", params = { draft = draft } } bsw@211: end } end } bsw@211: bsw@215: if initiative.issue.fully_frozen and initiative.issue.closed then bsw@215: ui.box_row{ class = "subhead", content = function() ui.box_col{ class = "head", content = _"Voters" } end } bsw@211: ui.box_row{ content = function() ui.box_col{ content = function() bsw@216: execute.view{ module = "lf2", view = "_avatars", params = { members = voting_members, issue_id = initiative.issue_id } } bsw@211: end } end } bsw@211: end bsw@211: bsw@215: ui.box_row{ class = "subhead", content = function() ui.box_col{ class = "head", content = _"Suggestions" } end } bsw@211: ui.box_row{ content = function() ui.box_col{ content = function() bsw@211: slot.put("suggestions") bsw@211: end } end } bsw@215: bsw@215: ui.box_row{ class = "subhead", content = function() ui.box_col{ class = "head", content = _"Supporters" } end } bsw@211: ui.box_row{ content = function() ui.box_col{ content = function() bsw@216: execute.view{ module = "lf2", view = "_avatars", params = { members = supporting_members, issue_id = initiative.issue_id } } bsw@211: end } end } bsw@215: bsw@215: end }