liquid_feedback_frontend

annotate app/main/lf2/_issue.lua @ 291:71eed60f6a41

Closed branch of experimental frontend
author jbe
date Sat Feb 25 15:56:55 2012 +0100 (2012-02-25)
parents 7ea52c710503
children
rev   line source
bsw@217 1 local issue = param.get("issue", "table")
bsw@217 2 local for_list = param.get("for_list", atom.boolean)
bsw@217 3
bsw@217 4 local initiatives = issue.initiatives
bsw@217 5
bsw@217 6 local interested_members = issue.interested_members
bsw@217 7
bsw@217 8 -- prepare interest of current user
bsw@217 9 local interest = issue.interest
bsw@217 10
bsw@217 11 -- prepare trustees
bsw@217 12 local trustees = Member:new_selector()
bsw@217 13 :add_field("delegation_chain.*")
bsw@217 14 :join({ "delegation_chain(?, null, null, " .. tostring(issue.id or "NULL") .. ")", app.session.member.id }, "delegation_chain", "member.id = delegation_chain.member_id")
bsw@217 15 :add_order_by("index")
bsw@217 16 :exec()
bsw@217 17
bsw@217 18 local global_delegation
bsw@217 19 local area_delegation
bsw@217 20 local issue_delegation
bsw@217 21
bsw@217 22 for i, delegation in ipairs(issue.outgoing_delegations) do
bsw@217 23 if delegation.scope == "global" then global_delegation = delegation
bsw@217 24 elseif delegation.scope == "area" then area_delegation = delegation
bsw@217 25 elseif delegation.scope == "issue" then issue_delegation = delegation
bsw@217 26 end
bsw@217 27 end
bsw@217 28
bsw@217 29 local delegation = issue_delegation or area_delegation or global_delegation
bsw@217 30
bsw@217 31 local delegating_interest = issue.delegating_interest
bsw@217 32 --[[
bsw@217 33 local current_delegating_interest = false
bsw@217 34
bsw@217 35 for i, trustee in ipairs(trustees) do
bsw@217 36 if i > 1 and trustee.participation then
bsw@217 37 delegating_interest = true
bsw@217 38 end
bsw@217 39 end
bsw@217 40 --]]
bsw@217 41 local row_count = #initiatives + 3
bsw@217 42 if #trustees > 1 then
bsw@217 43 row_count = row_count + 1
bsw@217 44 end
bsw@217 45
bsw@217 46 ui.box{ class = "issue", content = function()
bsw@217 47 ui.box_row{ class = "head", content = function()
bsw@217 48
bsw@217 49 ui.box_col{ class = "issue_id left head", content = function()
bsw@217 50 if interest then
bsw@217 51 local text
bsw@217 52 if issue.close then
bsw@217 53 text = _"You were interested in this issue"
bsw@217 54 else
bsw@217 55 text = _"You are interested in this issue"
bsw@217 56 end
bsw@217 57 ui.image{ attr = { title = text, alt = text}, static = "lf2/icon_star.png" }
bsw@217 58 elseif delegating_interest then
bsw@217 59 local text
bsw@217 60 if issue.closed then
bsw@217 61 text = _"Someone in your delegation chain was interested"
bsw@217 62 else
bsw@217 63 text = _"Someone in your delegation chain is interested"
bsw@217 64 end
bsw@217 65 ui.image{ attr = { title = text, alt = text}, static = "lf2/icon_delegated_star.png" }
bsw@217 66 end
bsw@217 67 slot.put(" ")
bsw@217 68 ui.link{
bsw@217 69 module = "lf2", view = "issue", id = issue.id,
bsw@217 70 content = _("Issue ##{id}", { id = issue.id })
bsw@217 71 }
bsw@217 72 end }
bsw@217 73
bsw@217 74 end }
bsw@217 75
bsw@217 76 if #trustees > 1 then
bsw@218 77 ui.box_row{ class = "", content = function()
bsw@218 78 ui.box_col{ class = "left", content = function()
bsw@217 79 execute.view{ module = "lf2", view = "_avatars", params = { members = trustees, arrows = true, size = "small", issue_id = issue.id } }
bsw@217 80 end }
bsw@217 81 end }
bsw@217 82 end
bsw@217 83
bsw@217 84 if not issue.closed and not issue.fully_frozen then
bsw@217 85 ui.box_row{ content = function()
bsw@217 86 ui.box_col{ class = "head", content = function()
bsw@217 87 if interest then
bsw@217 88 ui.link{
bsw@217 89 text = _"Remove interest",
bsw@217 90 module = "interest", action = "update", params = { issue_id = issue.id, delete = true },
bsw@217 91 routing = { default = { mode = "redirect", module = "lf2", view = "issue", id = issue.id } }
bsw@217 92 }
bsw@217 93 elseif not issue.closed and not issue.fully_frozen then
bsw@217 94 ui.link{
bsw@217 95 text = _"Add my interest",
bsw@217 96 module = "interest", action = "update", params = { issue_id = issue.id },
bsw@217 97 routing = { default = { mode = "redirect", module = "lf2", view = "issue", id = issue.id } }
bsw@217 98 }
bsw@217 99 end
bsw@217 100 slot.put(" · ")
bsw@218 101 if trustees[1].scope_out == "issue" then
bsw@218 102 text = _"Change or revoke issue delegation"
bsw@218 103 else
bsw@218 104 text = _"Set issue delegation"
bsw@218 105 end
bsw@218 106 ui.link{
bsw@218 107 text = text,
bsw@218 108 module = "lf2", view = "delegation", params = { issue_id = issue.id }
bsw@218 109 }
bsw@217 110 end }
bsw@217 111
bsw@217 112 end }
bsw@217 113 end
bsw@217 114
bsw@217 115 ui.box_row{ content = function()
bsw@217 116 ui.box_col{ class = "unit_name left", content = function()
bsw@217 117 ui.link{
bsw@217 118 module = "lf2", view = "index", id = issue.area.unit_id,
bsw@217 119 params = { phase = issue.phase },
bsw@218 120 text = issue.area.unit.name_with_path
bsw@217 121 }
bsw@217 122 end }
bsw@217 123 ui.box_col{ class = "policy_name right", content = function()
bsw@217 124 ui.link{
bsw@217 125 module = "lf2", view = "policy", id = issue.policy_id,
bsw@217 126 content = issue.policy.name
bsw@217 127 }
bsw@217 128 end }
bsw@217 129 end }
bsw@217 130
bsw@217 131 ui.box_row{ content = function()
bsw@217 132 ui.box_col{ class = "area_name left", content = function()
bsw@217 133 ui.link{
bsw@217 134 module = "lf2", view = "area", id = issue.area_id,
bsw@217 135 params = { phase = issue.phase },
bsw@217 136 text = issue.area.name
bsw@217 137 }
bsw@217 138 end }
bsw@217 139 ui.box_col{ class = "state_time_left right", content = function()
bsw@217 140 ui.tag{ content = issue.state_name }
bsw@217 141 slot.put(" · ")
bsw@217 142 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@217 143 end }
bsw@217 144 end }
bsw@217 145
bsw@217 146
bsw@217 147 ui.box_row{ class = "subhead", content = function()
bsw@217 148 ui.box_col{ class = "head", content = _"Initiatives" }
bsw@217 149 end }
bsw@217 150
bsw@217 151 for i, initiative in ipairs(issue.initiatives) do
bsw@217 152 ui.box_row{ class = "initiative", content = function() ui.box_col { content = function()
bsw@217 153 execute.view{ module = "lf2", view = "_initiative", params = { initiative = initiative } }
bsw@217 154 end } end }
bsw@217 155 end
bsw@217 156 if not for_list then
bsw@217 157 -- TODO bugfix for not working reference loader
bsw@217 158 interested_members = issue:get_reference_selector("interested_members_snapshot"):exec()
bsw@217 159
bsw@217 160 ui.box_row{ class = "subhead", content = function()
bsw@217 161 ui.box_col{ class = "head left", content = _"Members, interested in this issue" }
bsw@217 162 ui.box_col{ class = "right", content = _("#{count} members", { count = #interested_members }) }
bsw@217 163 end }
bsw@217 164 ui.box_row{ class = "interested", content = function()
bsw@217 165 ui.box_col{ class = "", content = function()
bsw@217 166 execute.view{ module = "lf2", view = "_avatars", params = { members = interested_members, issue_id = issue.id } }
bsw@217 167 end }
bsw@217 168 end }
bsw@217 169 end
bsw@217 170 end }

Impressum / About Us