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