bsw@211: local issue = param.get("issue", "table") bsw@213: local initiative_id = param.get("initiative_id", atom.integer) bsw@211: bsw@215: local alternative_initiatives = param.get("alternative_initiatives", "table") bsw@215: bsw@211: local initiatives = issue.initiatives bsw@211: bsw@211: local interested_members_selector = Member:new_selector() 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 interested_members = interested_members_selector:exec() bsw@211: bsw@211: local interest = issue.interest bsw@211: bsw@211: local trustees = Member:new_selector() bsw@211: :add_field("delegation_chain.*") bsw@211: :join("delegation_chain(" .. tostring(app.session.member.id) .. ", NULL, " .. tostring(issue.id or "NULL") .. ")", "delegation_chain", "member.id = delegation_chain.member_id") bsw@211: :add_order_by("index") bsw@211: :exec() bsw@211: bsw@211: local delegating_interest = issue.delegating_interest bsw@211: bsw@211: ui.box{ class = "issue", content = function() bsw@211: bsw@213: ui.box_row{ class = "unit_name head2", content = function() ui.box_col{ content = function() bsw@211: ui.link{ bsw@215: module = "lf2", view = "index", id = 1, bsw@211: content = "DE / Berlin / Friedrichshain-Kreuzberg" bsw@211: } bsw@211: end } end } bsw@211: bsw@213: ui.box_row{ class = "area_name head2", content = function() ui.box_col{ content = function() bsw@211: ui.link{ bsw@211: module = "lf2", view = "area", id = issue.area_id, bsw@211: content = issue.area.name bsw@211: } bsw@211: end } end } bsw@211: bsw@215: ui.box_row{ class = "issue_id head2", content = function() ui.box_col{ class = "head", content = function() bsw@215: ui.link{ bsw@215: module = "lf2", view = "issue", id = issue.id, bsw@215: content = _("Issue ##{id}", { id = issue.id }) bsw@215: } bsw@215: end } end } bsw@215: bsw@213: ui.box_row{ class = "policy_name head2", content = function() ui.box_col{ content = function() bsw@211: ui.link{ bsw@211: module = "lf2", view = "policy", id = issue.policy_id, bsw@211: content = issue.policy.name bsw@211: } bsw@211: end } end } bsw@211: bsw@215: ui.box_row{ class = "time_left head", content = function() bsw@211: ui.box_col{ content = issue.closed and _("Closed since #{date}", { date = format.date(issue.closed.date) }) or _("#{time_left} left", { time_left = issue.state_time_left }) } bsw@211: end } bsw@211: bsw@211: ui.box_row{ class = "interest hoverbutton_container", content = function() ui.box_col{ content = function() bsw@211: if interest then bsw@211: ui.image{ static = "lf2/icon_star.png" } bsw@211: if issue.closed then bsw@211: slot.put(" ", _"You were interested in this issue") bsw@211: else bsw@211: slot.put(" ", _"You are interested in this issue") bsw@211: end bsw@211: else bsw@213: if not issue.closed and not issue.fully_frozen then bsw@213: ui.image{ static = "lf2/icon_star_grey.png" } bsw@213: end bsw@215: slot.put(" ", _"You are not interested in this issue") bsw@211: end bsw@211: bsw@211: if issue.closed then bsw@211: ui.container{ attr = { class = "hoverbutton noaction"}, content = function() bsw@211: ui.container{ attr = { class = "content"}, content = function() bsw@211: slot.put(" ", encode.html(_"This issue is closed")) bsw@211: end } bsw@211: end } bsw@211: elseif issue.fully_frozen then bsw@211: ui.container{ attr = { class = "hoverbutton noaction"}, content = function() bsw@211: ui.container{ attr = { class = "content"}, content = function() bsw@211: slot.put(" ", encode.html(_"This issue is in voting")) bsw@211: end } bsw@211: end } bsw@211: else bsw@211: if interest then bsw@211: ui.link{ bsw@211: module = "interest", action = "update", params = { issue_id = issue.id, delete = true }, bsw@211: routing = { default = { bsw@213: mode = "redirect", module = "lf2", view = initiative_id and "initiative" or "issue", id = initiative_id or issue.id, bsw@211: } }, bsw@211: attr = { class = "hoverbutton red"}, bsw@211: content = function() bsw@211: ui.container{ attr = { class = "content"}, content = function() bsw@211: ui.image{ static = "lf2/icon_star_crossed.png" } bsw@211: slot.put(" ", encode.html(_"Remove my interest")) bsw@211: end } bsw@211: end bsw@211: } bsw@211: bsw@211: else bsw@211: ui.link{ bsw@211: module = "interest", action = "update", params = { issue_id = issue.id }, bsw@211: routing = { default = { bsw@213: mode = "redirect", module = "lf2", view = initiative_id and "initiative" or "issue", id = initiative_id or issue.id, bsw@211: } }, bsw@211: attr = { class = "hoverbutton green"}, bsw@211: content = function() bsw@211: ui.container{ attr = { class = "content"}, content = function() bsw@211: ui.image{ static = "lf2/icon_star.png" } bsw@211: slot.put(" ", encode.html(_"Add my interest")) bsw@211: end bsw@211: } bsw@211: end } bsw@211: bsw@211: end bsw@211: end bsw@211: end } end } bsw@211: bsw@211: ui.box_row{ class = "delegation hoverbutton_container", content = function() ui.box_col{ content = function() bsw@213: if trustees[1].scope_out then bsw@215: ui.image{ static = "lf2/icon_delegation.png" } bsw@215: slot.put(" ") bsw@213: if trustees[1].disabled_out == false then bsw@213: if trustees[1].scope_out == "issue" then bsw@215: slot.put(encode.html(_"Issue is delegated")) bsw@213: elseif trustees[1].scope_out == "area" then bsw@215: slot.put(encode.html(_"Area is delegated")) bsw@213: elseif trustees[1].scope_out == "global" then bsw@215: slot.put(encode.html(_"Unit wide delegated")) bsw@213: end bsw@213: else bsw@213: if trustees[1].scope_out == "issue" then bsw@213: slot.put(encode.html(_"Issue delegation abandoned")) bsw@213: elseif trustees[1].scope_out == "area" then bsw@213: slot.put(encode.html(_"Area delegation abandoned")) bsw@213: elseif trustees[1].scope_out == "global" then bsw@213: slot.put(encode.html(_"Global delegation abandoned")) bsw@213: end bsw@211: end bsw@211: else bsw@211: slot.put(encode.html(_"No delegation active")) bsw@211: end bsw@211: bsw@211: if issue.closed then bsw@211: ui.container{ attr = { class = "hoverbutton noaction"}, content = function() bsw@211: ui.container{ attr = { class = "content"}, content = function() bsw@211: slot.put(" ", encode.html(_"This issue is closed")) bsw@211: end } bsw@211: end } bsw@215: elseif issue.fully_frozen then bsw@215: ui.container{ attr = { class = "hoverbutton noaction"}, content = function() bsw@215: ui.container{ attr = { class = "content"}, content = function() bsw@215: slot.put(" ", encode.html(_"This issue is in voting")) bsw@215: end } bsw@215: end } bsw@211: else bsw@215: if #trustees > 1 and trustees[1].scope_out == "issue" then bsw@213: ui.link{ bsw@213: module = "lf2", view = "delegation", params = { issue_id = issue.id, initiative_id = initiative_id }, bsw@213: attr = { class = "hoverbutton red"}, content = function() bsw@211: ui.container{ attr = { class = "content"}, content = function() bsw@215: slot.put(" ", encode.html(_"Change issue delegation")) bsw@211: end } bsw@211: end } bsw@211: bsw@211: else bsw@213: ui.link{ bsw@213: module = "lf2", view = "delegation", params = { issue_id = issue.id, initiative_id = initiative_id }, bsw@213: attr = { class = "hoverbutton green"}, content = function() bsw@211: ui.container{ attr = { class = "content"}, content = function() bsw@215: slot.put(" ", encode.html(_"Set issue delegation")) bsw@213: bsw@211: end } bsw@211: end } bsw@211: bsw@211: end bsw@211: end bsw@211: bsw@211: end } end } bsw@213: bsw@213: if #trustees > 1 then bsw@211: ui.box_row{ class = "delegation", content = function() ui.box_col{ content = function() bsw@211: execute.view{ module = "lf2", view = "_avatars", params = { members = trustees, arrows = true, size = "small" } } bsw@211: end } end } bsw@211: end bsw@211: bsw@215: ui.box_row{ class = "subhead", content = function() ui.box_col{ class = "head", content = _"Initiatives in this issue" } end } bsw@215: ui.box_row{ class = "initiatives last", content = function() bsw@215: ui.box_col{ class = "scrolled", content = function() bsw@215: execute.view{ module = "lf2", view = "_issue_initiatives", params = { initiatives = alternative_initiatives, current_initiative_id = initiative_id } } bsw@215: end } bsw@215: end } bsw@215: bsw@215: bsw@211: end }