bsw@525: local issue = param.get("issue", "table") bsw@525: local initiative_limit = param.get("initiative_limit", atom.integer) bsw@525: local for_listing = param.get("for_listing", atom.boolean) bsw@574: local for_initiative = param.get("for_initiative", "table") bsw@574: local for_initiative_id = for_initiative and for_initiative.id or nil bsw@525: bsw@525: local direct_voter bsw@525: if app.session.member_id then bsw@547: direct_voter = issue.member_info.direct_voted bsw@525: end bsw@525: bsw@525: local voteable = app.session.member_id and issue.state == 'voting' and bsw@525: app.session.member:has_voting_right_for_unit_id(issue.area.unit_id) bsw@525: bsw@691: local vote_link_text = direct_voter and _"Change vote" or _"Vote now" bsw@525: bsw@525: bsw@525: local class = "issue" bsw@525: if issue.is_interested then bsw@525: class = class .. " interested" bsw@525: elseif issue.is_interested_by_delegation_to_member_id then bsw@525: class = class .. " interested_by_delegation" bsw@525: end bsw@525: bsw@525: ui.container{ attr = { class = class }, content = function() bsw@525: bsw@525: execute.view{ module = "delegation", view = "_info", params = { issue = issue } } bsw@525: bsw@635: if for_listing then bsw@635: ui.container{ attr = { class = "content" }, content = function() bsw@678: ui.link{ bsw@678: module = "unit", view = "show", id = issue.area.unit_id, bsw@678: attr = { class = "unit_link" }, text = issue.area.unit.name bsw@678: } bsw@678: slot.put(" ") bsw@678: ui.link{ bsw@678: module = "area", view = "show", id = issue.area_id, bsw@678: attr = { class = "area_link" }, text = issue.area.name bsw@678: } bsw@635: end } bsw@635: end bsw@635: bsw@525: ui.container{ attr = { class = "title" }, content = function() bsw@525: bsw@525: ui.link{ bsw@525: attr = { class = "issue_id" }, bsw@525: text = _("#{policy_name} ##{issue_id}", { bsw@525: policy_name = issue.policy.name, bsw@525: issue_id = issue.id bsw@525: }), bsw@525: module = "issue", bsw@525: view = "show", bsw@525: id = issue.id bsw@525: } bsw@525: end } bsw@525: bsw@525: ui.tag{ bsw@525: attr = { class = "content issue_policy_info" }, bsw@525: tag = "div", bsw@525: content = function() bsw@525: bsw@525: ui.tag{ attr = { class = "event_name" }, content = issue.state_name } bsw@525: bsw@525: if issue.state_time_left then bsw@525: slot.put(" · ") bsw@525: if issue.state_time_left:sub(1,1) == "-" then bsw@550: if issue.state == "accepted" then bsw@525: ui.tag{ content = _("Discussion starts soon") } bsw@525: elseif issue.state == "discussion" then bsw@525: ui.tag{ content = _("Verification starts soon") } bsw@525: elseif issue.state == "frozen" then bsw@525: ui.tag{ content = _("Voting starts soon") } bsw@525: elseif issue.state == "voting" then bsw@525: ui.tag{ content = _("Counting starts soon") } bsw@525: end bsw@525: else bsw@723: ui.tag{ content = _("#{time_left} left", { time_left = issue.state_time_left:gsub("%..*", ""):gsub("days", _"days"):gsub("day", _"day") }) } bsw@525: end bsw@525: end bsw@525: bsw@525: end bsw@525: } bsw@525: bsw@572: local links = {} bsw@525: bsw@525: if voteable then bsw@572: links[#links+1] ={ bsw@525: content = vote_link_text, bsw@525: module = "vote", bsw@525: view = "list", bsw@525: params = { issue_id = issue.id } bsw@525: } bsw@525: end bsw@525: bsw@525: if app.session.member_id then bsw@572: bsw@572: if issue.member_info.own_participation then bsw@572: if issue.closed then bsw@572: links[#links+1] = { content = _"You were interested" } bsw@572: else bsw@572: links[#links+1] = { content = _"You are interested" } bsw@572: end bsw@572: end bsw@572: bsw@572: if not issue.closed and not issue.fully_frozen then bsw@572: if issue.member_info.own_participation then bsw@572: links[#links+1] = { bsw@572: in_brackets = true, bsw@572: text = _"Withdraw", bsw@572: module = "interest", bsw@572: action = "update", bsw@572: params = { issue_id = issue.id, delete = true }, bsw@572: routing = { bsw@572: default = { bsw@572: mode = "redirect", bsw@572: module = request.get_module(), bsw@572: view = request.get_view(), bsw@572: id = param.get_id_cgi(), bsw@572: params = param.get_all_cgi() bsw@572: } bsw@572: } bsw@572: } bsw@572: elseif app.session.member:has_voting_right_for_unit_id(issue.area.unit_id) then bsw@572: links[#links+1] = { bsw@572: text = _"Add my interest", bsw@572: module = "interest", bsw@572: action = "update", bsw@572: params = { issue_id = issue.id }, bsw@572: routing = { bsw@572: default = { bsw@572: mode = "redirect", bsw@572: module = request.get_module(), bsw@572: view = request.get_view(), bsw@572: id = param.get_id_cgi(), bsw@572: params = param.get_all_cgi() bsw@572: } bsw@572: } bsw@572: } bsw@572: end bsw@572: end bsw@525: end bsw@525: bsw@573: if not issue.closed and app.session.member_id and app.session.member:has_voting_right_for_unit_id(issue.area.unit_id) then bsw@547: if issue.member_info.own_delegation_scope ~= "issue" then bsw@574: links[#links+1] = { text = _"Delegate issue", module = "delegation", view = "show", params = { issue_id = issue.id, initiative_id = for_initiative_id } } bsw@529: else bsw@574: links[#links+1] = { text = _"Change issue delegation", module = "delegation", view = "show", params = { issue_id = issue.id, initiative_id = for_initiative_id } } bsw@529: end bsw@529: end bsw@529: bsw@525: if config.issue_discussion_url_func then bsw@525: local url = config.issue_discussion_url_func(issue) bsw@572: links[#links+1] = { bsw@525: attr = { target = "_blank" }, bsw@525: external = url, bsw@525: content = _"Discussion on issue" bsw@525: } bsw@525: end bsw@525: bsw@525: if config.etherpad and app.session.member then bsw@572: links[#links+1] = { bsw@525: attr = { target = "_blank" }, bsw@525: external = issue.etherpad_url, bsw@525: content = _"Issue pad" bsw@525: } bsw@525: end bsw@525: bsw@525: bsw@525: if app.session.member_id and app.session.member:has_voting_right_for_unit_id(issue.area.unit_id) then bsw@525: if not issue.fully_frozen and not issue.closed then bsw@572: links[#links+1] = { bsw@525: attr = { class = "action" }, bsw@525: text = _"Create alternative initiative", bsw@525: module = "initiative", bsw@525: view = "new", bsw@525: params = { issue_id = issue.id } bsw@525: } bsw@525: end bsw@525: end bsw@525: bsw@572: ui.container{ attr = { class = "content actions" }, content = function() bsw@572: for i, link in ipairs(links) do bsw@572: if link.in_brackets then bsw@572: slot.put(" (") bsw@572: elseif i > 1 then bsw@572: slot.put(" · ") bsw@572: end bsw@582: if link.module or link.external then bsw@572: ui.link(link) bsw@572: else bsw@572: ui.tag(link) bsw@572: end bsw@572: if link.in_brackets then bsw@572: slot.put(")") bsw@572: end bsw@572: end bsw@525: end } bsw@525: bsw@525: if not for_listing then bsw@527: if issue.state == "cancelled" then bsw@527: local policy = issue.policy bsw@527: ui.container{ bsw@527: attr = { class = "not_admitted_info" }, bsw@527: content = _("This issue has been cancelled. It failed the quorum of #{quorum}.", { quorum = format.percentage(policy.issue_quorum_num / policy.issue_quorum_den) }) bsw@527: } bsw@527: end bsw@525: end bsw@525: bsw@642: ui.container{ attr = { class = "initiative_list content" }, content = function() bsw@525: bsw@525: local initiatives_selector = issue:get_reference_selector("initiatives") bsw@525: local highlight_string = param.get("highlight_string") bsw@525: if highlight_string then bsw@525: initiatives_selector:add_field( {'"highlight"("initiative"."name", ?)', highlight_string }, "name_highlighted") bsw@525: end bsw@525: execute.view{ bsw@525: module = "initiative", bsw@525: view = "_list", bsw@525: params = { bsw@525: issue = issue, bsw@525: initiatives_selector = initiatives_selector, bsw@715: highlight_initiative = for_initiative, bsw@525: highlight_string = highlight_string, bsw@525: no_sort = true, bsw@715: limit = (for_listing or for_initiative) and 5 or nil, bsw@525: for_member = for_member bsw@525: } bsw@525: } bsw@525: end } bsw@525: end } bsw@525: