liquid_feedback_frontend

annotate app/main/lf2/_issues.lua @ 213:acf92c2d33f4

Seperated css and fixed issue delegations for second generation frontend
author bsw
date Thu Mar 03 21:26:35 2011 +0100 (2011-03-03)
parents 3e4ad069847a
children 1dab81353eb1
rev   line source
bsw@211 1 local issues = param.get("issues", "table")
bsw@211 2
bsw@211 3 for i, issue in ipairs(issues) do
bsw@211 4 local initiatives = issue.initiatives
bsw@211 5
bsw@211 6 local interested_members = issue.interested_members
bsw@211 7
bsw@211 8 -- prepare interest of current user
bsw@211 9 local interest = issue.interest
bsw@211 10
bsw@211 11 -- prepare trustees
bsw@211 12 local trustees = Member:new_selector()
bsw@211 13 :add_field("delegation_chain.*")
bsw@211 14 :join("delegation_chain(" .. tostring(app.session.member.id) .. ", NULL, " .. tostring(issue.id or "NULL") .. ")", "delegation_chain", "member.id = delegation_chain.member_id")
bsw@211 15 :add_order_by("index")
bsw@211 16 :exec()
bsw@211 17
bsw@211 18 local global_delegation
bsw@211 19 local area_delegation
bsw@211 20 local issue_delegation
bsw@211 21
bsw@211 22 for i, delegation in ipairs(issue.outgoing_delegations) do
bsw@211 23 if delegation.scope == "global" then global_delegation = delegation
bsw@211 24 elseif delegation.scope == "area" then area_delegation = delegation
bsw@211 25 elseif delegation.scope == "issue" then issue_delegation = delegation
bsw@211 26 end
bsw@211 27 end
bsw@211 28
bsw@211 29 local delegation = issue_delegation or area_delegation or global_delegation
bsw@211 30
bsw@211 31 local delegating_interest = issue.delegating_interest
bsw@211 32
bsw@211 33 ui.box{ class = "issue", content = function()
bsw@211 34
bsw@211 35 ui.box_row{ class = "head", content = function()
bsw@211 36
bsw@212 37 ui.box_col{ class = "issue_id left head", content = function()
bsw@211 38 ui.link{
bsw@211 39 module = "lf2", view = "issue", id = issue.id,
bsw@211 40 content = _("Issue ##{id}", { id = issue.id })
bsw@211 41 }
bsw@211 42 end }
bsw@211 43
bsw@212 44 ui.box_col{ class = "policy_name right", content = function()
bsw@211 45 ui.link{
bsw@211 46 module = "lf2", view = "policy", id = issue.policy_id,
bsw@211 47 content = issue.policy.name
bsw@211 48 }
bsw@211 49 end }
bsw@211 50
bsw@211 51 end }
bsw@211 52
bsw@211 53 ui.box_row{ class = "head2", content = function()
bsw@211 54
bsw@211 55 ui.box_col{ class = "state_name left", content = function()
bsw@211 56 ui.tag{ content = issue.state_name }
bsw@212 57 end }
bsw@212 58 ui.box_col{ class = "state_time_left right", content = function()
bsw@211 59 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 60 end }
bsw@211 61 end }
bsw@211 62
bsw@212 63 if #trustees > 1 then
bsw@211 64 ui.box_row{ class = "head2", content = function()
bsw@212 65 ui.box_col{ class = "left", content = function()
bsw@212 66 execute.view{ module = "lf2", view = "_avatars", params = { members = trustees, arrows = true, size = "small" } }
bsw@212 67 end }
bsw@212 68 if not issue.closed and not issue.fully_frozen then
bsw@212 69 if trustees[1].scope_out == "issue" then
bsw@212 70 text = _"Change or revoke issue delegation..."
bsw@211 71 else
bsw@212 72 text = _"Set issue delegation..."
bsw@212 73 end
bsw@212 74 ui.box_col{ class = "right", content = function()
bsw@212 75 ui.link{
bsw@212 76 text = text,
bsw@212 77 module = "lf2", view = "delegation", params = { issue_id = issue.id }
bsw@212 78 }
bsw@211 79 end }
bsw@211 80 end
bsw@211 81 end }
bsw@211 82 end
bsw@212 83
bsw@212 84 ui.box_row{ class = "head2", content = function()
bsw@212 85 ui.box_col{ class = "interest left", content = function()
bsw@212 86 if interest then
bsw@212 87 ui.image{ static = "lf2/icon_star.png" }
bsw@213 88 if issue.close then
bsw@212 89 slot.put(" ", _"You were interested in this issue")
bsw@212 90 else
bsw@212 91 slot.put(" ", _"You are interested in this issue")
bsw@212 92 end
bsw@212 93 elseif delegating_interest then
bsw@212 94 ui.image{ static = "lf2/icon_delegated_star.png" }
bsw@212 95 if issue.closed then
bsw@212 96 slot.put(" ", _"You were interested in this issue by delegation")
bsw@212 97 else
bsw@212 98 slot.put(" ", _"You are interested in this issue by delegation")
bsw@212 99 end
bsw@212 100 else
bsw@212 101 slot.put(_"You are not interested in this issue")
bsw@212 102 end
bsw@212 103 end }
bsw@212 104
bsw@212 105 if not issue.closed and not issue.fully_frozen then
bsw@212 106 ui.box_col{ class = "right", content = function()
bsw@212 107 if interest then
bsw@212 108 ui.link{
bsw@212 109 text = _"Remove interest",
bsw@212 110 module = "interest", action = "update", params = { issue_id = issue.id, delete = true },
bsw@212 111 routing = { default = { mode = "redirect", module = "lf2", view = "issue", id = issue.id } }
bsw@212 112 }
bsw@212 113 else
bsw@212 114 ui.link{
bsw@212 115 text = _"Add my interest",
bsw@212 116 module = "interest", action = "update", params = { issue_id = issue.id },
bsw@212 117 routing = { default = { mode = "redirect", module = "lf2", view = "issue", id = issue.id } }
bsw@212 118 }
bsw@212 119 end
bsw@212 120 if #trustees == 1 then
bsw@212 121 slot.put(" · ")
bsw@212 122 ui.link{
bsw@212 123 text = _"Set issue delegation...",
bsw@212 124 module = "lf2", view = "delegation", params = { issue_id = issue.id }
bsw@212 125 }
bsw@212 126 end
bsw@212 127 end }
bsw@212 128 end
bsw@212 129
bsw@212 130 end }
bsw@211 131
bsw@211 132 for i, initiative in ipairs(issue.initiatives) do
bsw@211 133 ui.box_row{ class = "initiative", content = function() ui.box_col { content = function()
bsw@211 134 execute.view{ module = "lf2", view = "_initiative", params = { initiative = initiative } }
bsw@211 135 end } end }
bsw@211 136 end
bsw@211 137
bsw@211 138 end }
bsw@211 139 end

Impressum / About Us