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@211: bsw@211: slot.select("sidebar", function() bsw@211: bsw@213: execute.view{ module = "lf2", view = "_sidebar_issue", params = { issue = issue, initiative_id = initiative.id } } bsw@211: bsw@211: execute.view{ module = "lf2", view = "_sidebar_initiatives", params = { bsw@212: initiatives = alternative_initiatives, bsw@212: head_content = function() ui.tag{ content = _"Alternative initiatives" } end bsw@211: } } bsw@211: 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@211: 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@211: ui.box_row{ class = "head2", content = function() ui.box_col{ content = function() bsw@211: if initiative.issue.fully_frozen and initiative.issue.closed then bsw@211: ui.link{ external = "#votes", text = _("#{vote_count} votes", { vote_count = #voting_members }) } bsw@211: slot.put(" · ") bsw@211: end bsw@211: ui.link{ external = "#suggestions", text = _("#{suggestion_count} suggestions", { suggestion_count = 23 }) } bsw@211: slot.put(" · ") bsw@211: ui.link{ external = "#supporters", text = _("#{supporter_count} supporters", { supporter_count = #supporting_members }) } bsw@211: end } end } bsw@211: bsw@211: ui.box_row{ content = function() ui.box_col{ content = function() bsw@211: execute.view{ module = "lf2", view = "_draft", params = { draft = draft } } bsw@211: end } end } bsw@211: end bsw@211: } bsw@211: bsw@211: if initiative.issue.fully_frozen and initiative.issue.closed then bsw@211: ui.boxhead{ name = "votes", content = _"Votes" } bsw@211: ui.box{ bsw@211: content = function() bsw@211: ui.box_row{ content = function() ui.box_col{ content = function() bsw@211: execute.view{ module = "lf2", view = "_avatars", params = { members = voting_members } } bsw@211: end } end } bsw@211: end bsw@211: } bsw@211: end bsw@211: bsw@211: ui.boxhead{ name = "suggestions", content = _"Suggestions" } bsw@211: ui.box{ bsw@211: content = function() bsw@211: ui.box_row{ content = function() ui.box_col{ content = function() bsw@211: slot.put("suggestions") bsw@211: end } end } bsw@211: end bsw@211: } bsw@211: bsw@211: ui.boxhead{ name = "supporters", content = _"Supporters" } bsw@211: ui.box{ bsw@211: content = function() bsw@211: ui.box_row{ content = function() ui.box_col{ content = function() bsw@211: execute.view{ module = "lf2", view = "_avatars", params = { members = supporting_members } } bsw@211: end } end } bsw@211: end bsw@211: } bsw@211: