bsw@211: local issues = param.get("issues", "table") bsw@211: bsw@211: for i, issue in ipairs(issues) do bsw@211: local initiatives = issue.initiatives bsw@211: bsw@211: local interested_members = issue.interested_members bsw@211: bsw@211: -- prepare interest of current user bsw@211: local interest = issue.interest bsw@211: bsw@211: -- prepare trustees 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 global_delegation bsw@211: local area_delegation bsw@211: local issue_delegation bsw@211: bsw@211: for i, delegation in ipairs(issue.outgoing_delegations) do bsw@211: if delegation.scope == "global" then global_delegation = delegation bsw@211: elseif delegation.scope == "area" then area_delegation = delegation bsw@211: elseif delegation.scope == "issue" then issue_delegation = delegation bsw@211: end bsw@211: end bsw@211: bsw@211: local delegation = issue_delegation or area_delegation or global_delegation bsw@211: bsw@211: local delegating_interest = issue.delegating_interest bsw@211: bsw@211: ui.box{ class = "issue", content = function() bsw@211: bsw@211: ui.box_row{ class = "head", content = function() bsw@211: bsw@212: ui.box_col{ class = "issue_id left head", content = function() bsw@211: ui.link{ bsw@211: module = "lf2", view = "issue", id = issue.id, bsw@211: content = _("Issue ##{id}", { id = issue.id }) bsw@211: } bsw@211: end } bsw@211: bsw@212: ui.box_col{ class = "policy_name right", 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 } bsw@211: bsw@211: end } bsw@211: bsw@211: ui.box_row{ class = "head2", content = function() bsw@211: bsw@211: ui.box_col{ class = "state_name left", content = function() bsw@211: ui.tag{ content = issue.state_name } bsw@212: end } bsw@212: ui.box_col{ class = "state_time_left right", content = function() bsw@211: ui.tag{ content = issue.closed and _("since #{date}", { date = format.date(issue.closed.date) }) or _("#{time_left} left", { time_left = issue.state_time_left }) } bsw@211: end } bsw@211: end } bsw@211: bsw@212: if #trustees > 1 then bsw@211: ui.box_row{ class = "head2", content = function() bsw@212: ui.box_col{ class = "left", content = function() bsw@212: execute.view{ module = "lf2", view = "_avatars", params = { members = trustees, arrows = true, size = "small" } } bsw@212: end } bsw@212: if not issue.closed and not issue.fully_frozen then bsw@212: if trustees[1].scope_out == "issue" then bsw@212: text = _"Change or revoke issue delegation..." bsw@211: else bsw@212: text = _"Set issue delegation..." bsw@212: end bsw@212: ui.box_col{ class = "right", content = function() bsw@212: ui.link{ bsw@212: text = text, bsw@212: module = "lf2", view = "delegation", params = { issue_id = issue.id } bsw@212: } bsw@211: end } bsw@211: end bsw@211: end } bsw@211: end bsw@212: bsw@212: ui.box_row{ class = "head2", content = function() bsw@212: ui.box_col{ class = "interest left", content = function() bsw@212: if interest then bsw@212: ui.image{ static = "lf2/icon_star.png" } bsw@213: if issue.close then bsw@212: slot.put(" ", _"You were interested in this issue") bsw@212: else bsw@212: slot.put(" ", _"You are interested in this issue") bsw@212: end bsw@212: elseif delegating_interest then bsw@212: ui.image{ static = "lf2/icon_delegated_star.png" } bsw@212: if issue.closed then bsw@212: slot.put(" ", _"You were interested in this issue by delegation") bsw@212: else bsw@212: slot.put(" ", _"You are interested in this issue by delegation") bsw@212: end bsw@212: else bsw@212: slot.put(_"You are not interested in this issue") bsw@212: end bsw@212: end } bsw@212: bsw@212: if not issue.closed and not issue.fully_frozen then bsw@212: ui.box_col{ class = "right", content = function() bsw@212: if interest then bsw@212: ui.link{ bsw@212: text = _"Remove interest", bsw@212: module = "interest", action = "update", params = { issue_id = issue.id, delete = true }, bsw@212: routing = { default = { mode = "redirect", module = "lf2", view = "issue", id = issue.id } } bsw@212: } bsw@212: else bsw@212: ui.link{ bsw@212: text = _"Add my interest", bsw@212: module = "interest", action = "update", params = { issue_id = issue.id }, bsw@212: routing = { default = { mode = "redirect", module = "lf2", view = "issue", id = issue.id } } bsw@212: } bsw@212: end bsw@212: if #trustees == 1 then bsw@212: slot.put(" · ") bsw@212: ui.link{ bsw@212: text = _"Set issue delegation...", bsw@212: module = "lf2", view = "delegation", params = { issue_id = issue.id } bsw@212: } bsw@212: end bsw@212: end } bsw@212: end bsw@212: bsw@212: end } bsw@211: bsw@211: for i, initiative in ipairs(issue.initiatives) do bsw@211: ui.box_row{ class = "initiative", content = function() ui.box_col { content = function() bsw@211: execute.view{ module = "lf2", view = "_initiative", params = { initiative = initiative } } bsw@211: end } end } bsw@211: end bsw@211: bsw@211: end } bsw@211: end