bsw@1045: local initiative = param.get("initiative", "table") bsw@1045: local member = param.get("member", "table") or app.session.member bsw@1045: bsw@1045: -- TODO performance bsw@1045: local initiator bsw@1045: if member then bsw@1045: initiator = Initiator:by_pk(initiative.id, member.id) bsw@1045: end bsw@1045: bsw@1045: local initiators_members_selector = initiative:get_reference_selector("initiating_members") bsw@1045: :add_field("initiator.accepted", "accepted") bsw@1045: :add_order_by("member.name") bsw@1045: if initiator and initiator.accepted then bsw@1045: initiators_members_selector:add_where("initiator.accepted ISNULL OR initiator.accepted") bsw@1045: else bsw@1045: initiators_members_selector:add_where("initiator.accepted") bsw@1045: end bsw@1045: bsw@1045: local initiators = initiators_members_selector:exec() bsw@1045: bsw@1045: bsw/jbe@1309: ui.container{ attr = { class = "mdl-card__title mdl-card--has-fab mdl-card--border" }, content = function () bsw/jbe@1309: bsw/jbe@1309: ui.heading { bsw/jbe@1309: attr = { class = "mdl-card__title-text" }, bsw/jbe@1309: level = 2, bsw/jbe@1309: content = function() bsw/jbe@1309: ui.tag{ content = initiative.display_name } bsw/jbe@1309: end bsw/jbe@1309: } bsw@1045: bsw/jbe@1309: if app.session.member and app.session.member:has_voting_right_for_unit_id(initiative.issue.area.unit_id) then bsw/jbe@1309: if not initiative.issue.closed and not initiative.member_info.supported then bsw/jbe@1309: if not initiative.issue.fully_frozen then bsw/jbe@1309: ui.link { bsw/jbe@1309: attr = { class = "mdl-button mdl-js-button mdl-button--fab mdl-button--colored" , bsw/jbe@1309: style = "position: absolute; right: 20px; bottom: -27px;" bsw/jbe@1309: }, bsw/jbe@1309: module = "initiative", action = "add_support", bsw/jbe@1309: routing = { default = { bsw/jbe@1309: mode = "redirect", module = "initiative", view = "show", id = initiative.id bsw/jbe@1309: } }, bsw/jbe@1309: id = initiative.id, bsw/jbe@1309: content = function() bsw/jbe@1309: ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "thumb_up" } bsw/jbe@1309: end bsw@1045: } bsw/jbe@1309: end bsw/jbe@1309: end bsw/jbe@1309: if initiative.issue.fully_frozen and not initiative.issue.closed and not initiative.issue.member_info.direct_voted then bsw/jbe@1309: ui.link { bsw/jbe@1309: attr = { class = "mdl-button mdl-js-button mdl-button--fab mdl-button--colored" , bsw/jbe@1309: style = "position: absolute; right: 20px; bottom: -27px;" bsw/jbe@1309: }, bsw/jbe@1309: module = "vote", view = "list", bsw/jbe@1309: params = { issue_id = initiative.issue_id }, bsw/jbe@1309: content = function() bsw/jbe@1309: ui.tag{ tag = "i", attr = { class = "material-icons" }, content = config.voting_icon or "mail_outline" } bsw/jbe@1309: end bsw/jbe@1309: } bsw/jbe@1309: end bsw/jbe@1309: end bsw/jbe@1309: end } bsw/jbe@1309: bsw/jbe@1309: ui.container{ attr = { class = "mdl-card__content mdl-card--border" }, content = function () bsw/jbe@1309: bsw/jbe@1309: if not config.voting_only and app.session:has_access("authors_pseudonymous") then bsw@1658: ui.tag{ content = _"by" } bsw@1658: slot.put(" ") bsw/jbe@1309: for i, member in ipairs(initiators) do bsw/jbe@1309: if i > 1 then bsw/jbe@1309: slot.put(" ") bsw/jbe@1309: end bsw@1658: ui.link{ module = "member", view = "show", id = member.id, content = member.name } bsw/jbe@1309: end -- for i, member bsw/jbe@1309: end bsw/jbe@1309: bsw/jbe@1309: if member then bsw/jbe@1309: ui.container { attr = { class = "mySupport float-right right" }, content = function () bsw/jbe@1309: if initiative.issue.fully_frozen then bsw/jbe@1309: slot.put("
") bsw/jbe@1309: if initiative.issue.member_info.direct_voted then bsw/jbe@1309: ui.tag { content = _"You have voted" } bsw/jbe@1309: slot.put("
") bsw/jbe@1309: if not initiative.issue.closed then bsw/jbe@1309: ui.link { bsw/jbe@1309: module = "vote", view = "list", bsw/jbe@1309: params = { issue_id = initiative.issue.id }, bsw/jbe@1309: text = _"change vote" bsw/jbe@1309: } bsw/jbe@1309: else bsw/jbe@1309: ui.link { bsw/jbe@1309: module = "vote", view = "list", bsw/jbe@1309: params = { issue_id = initiative.issue.id }, bsw/jbe@1309: text = _"show vote" bsw/jbe@1309: } bsw/jbe@1309: end bsw/jbe@1309: slot.put(" ") bsw/jbe@1309: elseif active_trustee_id then bsw/jbe@1309: ui.tag { content = _"You have voted via delegation" } bsw/jbe@1309: ui.link { bsw/jbe@1309: content = _"Show voting ballot", bsw/jbe@1309: module = "vote", view = "list", params = { bsw/jbe@1309: issue_id = initiative.issue.id, member_id = active_trustee_id bsw/jbe@1309: } bsw/jbe@1309: } bsw/jbe@1309: elseif not initiative.issue.closed then bsw/jbe@1309: ui.link { bsw/jbe@1309: attr = { class = "btn btn-default" }, bsw/jbe@1309: module = "vote", view = "list", bsw/jbe@1309: params = { issue_id = initiative.issue.id }, bsw/jbe@1309: text = _"vote now" bsw@1045: } bsw@1045: end bsw/jbe@1309: elseif initiative.member_info.supported then bsw/jbe@1309: ui.container{ content = function() bsw/jbe@1309: ui.tag{ content = _"You are supporter" } bsw/jbe@1309: slot.put(" ") bsw/jbe@1309: if initiative.member_info.satisfied then bsw/jbe@1309: ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "thumb_up" } bsw/jbe@1309: else bsw/jbe@1309: ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "thumb_up" } bsw/jbe@1309: end bsw/jbe@1309: end } bsw/jbe@1309: if initiative.issue.member_info.own_participation then bsw/jbe@1309: ui.link { bsw/jbe@1309: attr = { class = "btn-link" }, bsw/jbe@1309: module = "initiative", action = "remove_support", bsw/jbe@1309: routing = { default = { bsw/jbe@1309: mode = "redirect", module = "initiative", view = "show", id = initiative.id bsw/jbe@1309: } }, bsw/jbe@1309: id = initiative.id, bsw/jbe@1309: text = _"remove my support" bsw/jbe@1309: } bsw/jbe@1309: bsw/jbe@1309: else bsw/jbe@1309: bsw/jbe@1309: ui.link { bsw/jbe@1309: module = "delegation", view = "show", params = { bsw/jbe@1309: issue_id = initiative.issue_id, bsw/jbe@1309: initiative_id = initiative.id bsw/jbe@1309: }, bsw/jbe@1309: content = _"via delegation" bsw/jbe@1309: } bsw/jbe@1309: bsw/jbe@1309: end bsw/jbe@1309: bsw/jbe@1309: slot.put(" ") bsw/jbe@1309: bsw/jbe@1309: end bsw/jbe@1309: end } bsw/jbe@1309: bsw/jbe@1309: end bsw/jbe@1309: bsw/jbe@1309: if config.initiative_abstract then bsw/jbe@1309: local abstract = string.match(initiative.current_draft.content, "(.+)") bsw/jbe@1309: if abstract then bsw/jbe@1309: ui.container{ bsw/jbe@1309: attr = { class = "abstract", style = "padding-right: 140px;" }, bsw/jbe@1309: content = function() slot.put(abstract) end bsw/jbe@1309: } bsw/jbe@1309: end bsw/jbe@1309: end bsw/jbe@1309: bsw/jbe@1309: ui.container { attr = { class = "support" }, content = function () bsw/jbe@1309: bsw/jbe@1309: if not config.voting_only then bsw@1045: execute.view { bsw@1045: module = "initiative", view = "_bargraph", params = { bsw@1045: initiative = initiative bsw@1045: } bsw@1045: } bsw/jbe@1309: slot.put(" ") bsw@1045: bsw/jbe@1309: ui.supporter_count(initiative) bsw@1045: end bsw@1045: bsw/jbe@1309: end } bsw/jbe@1309: bsw/jbe@1309: end } bsw@1045: bsw/jbe@1309: execute.view { bsw/jbe@1309: module = "initiative", view = "_sidebar_state", bsw/jbe@1309: params = { initiative = initiative } bsw/jbe@1309: } bsw@1045: