rev |
line source |
bsw@525
|
1 local issue = param.get("issue", "table")
|
bsw@525
|
2 local initiative_limit = param.get("initiative_limit", atom.integer)
|
bsw@862
|
3 local for_member = param.get("for_member", "table")
|
bsw@525
|
4 local for_listing = param.get("for_listing", atom.boolean)
|
bsw@574
|
5 local for_initiative = param.get("for_initiative", "table")
|
bsw@574
|
6 local for_initiative_id = for_initiative and for_initiative.id or nil
|
bsw@525
|
7
|
bsw@525
|
8 local direct_voter
|
bsw@525
|
9 if app.session.member_id then
|
bsw@547
|
10 direct_voter = issue.member_info.direct_voted
|
bsw@525
|
11 end
|
bsw@525
|
12
|
bsw@525
|
13 local voteable = app.session.member_id and issue.state == 'voting' and
|
bsw@525
|
14 app.session.member:has_voting_right_for_unit_id(issue.area.unit_id)
|
bsw@525
|
15
|
bsw@879
|
16 local vote_comment_able = app.session.member_id and issue.closed and direct_voter
|
bsw@879
|
17
|
bsw@879
|
18 local vote_link_text
|
bsw@879
|
19 if voteable then
|
bsw@879
|
20 vote_link_text = direct_voter and _"Change vote" or _"Vote now"
|
bsw@879
|
21 elseif vote_comment_able then
|
bsw@883
|
22 vote_link_text = direct_voter and _"Update voting comment"
|
bsw@879
|
23 end
|
bsw@525
|
24
|
bsw@525
|
25
|
bsw@525
|
26 local class = "issue"
|
bsw@525
|
27 if issue.is_interested then
|
bsw@525
|
28 class = class .. " interested"
|
bsw@525
|
29 elseif issue.is_interested_by_delegation_to_member_id then
|
bsw@525
|
30 class = class .. " interested_by_delegation"
|
bsw@525
|
31 end
|
bsw@525
|
32
|
bsw@525
|
33 ui.container{ attr = { class = class }, content = function()
|
bsw@525
|
34
|
bsw@862
|
35 execute.view{ module = "delegation", view = "_info", params = { issue = issue, member = for_member } }
|
bsw@525
|
36
|
bsw@635
|
37 if for_listing then
|
bsw@635
|
38 ui.container{ attr = { class = "content" }, content = function()
|
bsw@678
|
39 ui.link{
|
bsw@678
|
40 module = "unit", view = "show", id = issue.area.unit_id,
|
bsw@678
|
41 attr = { class = "unit_link" }, text = issue.area.unit.name
|
bsw@678
|
42 }
|
bsw@678
|
43 slot.put(" ")
|
bsw@678
|
44 ui.link{
|
bsw@678
|
45 module = "area", view = "show", id = issue.area_id,
|
bsw@678
|
46 attr = { class = "area_link" }, text = issue.area.name
|
bsw@678
|
47 }
|
bsw@635
|
48 end }
|
bsw@635
|
49 end
|
bsw@635
|
50
|
bsw@525
|
51 ui.container{ attr = { class = "title" }, content = function()
|
bsw@525
|
52
|
bsw@525
|
53 ui.link{
|
bsw@525
|
54 attr = { class = "issue_id" },
|
bsw@525
|
55 text = _("#{policy_name} ##{issue_id}", {
|
bsw@525
|
56 policy_name = issue.policy.name,
|
bsw@525
|
57 issue_id = issue.id
|
bsw@525
|
58 }),
|
bsw@525
|
59 module = "issue",
|
bsw@525
|
60 view = "show",
|
bsw@525
|
61 id = issue.id
|
bsw@525
|
62 }
|
bsw@525
|
63 end }
|
bsw@525
|
64
|
bsw@525
|
65 ui.tag{
|
bsw@525
|
66 attr = { class = "content issue_policy_info" },
|
bsw@525
|
67 tag = "div",
|
bsw@525
|
68 content = function()
|
bsw@525
|
69
|
bsw@525
|
70 ui.tag{ attr = { class = "event_name" }, content = issue.state_name }
|
bsw@525
|
71
|
bsw@863
|
72 if issue.closed then
|
bsw@863
|
73 slot.put(" · ")
|
bsw@938
|
74 ui.tag{ content = format.interval_text(issue.closed_ago, { mode = "ago" }) }
|
bsw@863
|
75 elseif issue.state_time_left then
|
bsw@525
|
76 slot.put(" · ")
|
bsw@525
|
77 if issue.state_time_left:sub(1,1) == "-" then
|
bsw@896
|
78 if issue.state == "admission" then
|
bsw@525
|
79 ui.tag{ content = _("Discussion starts soon") }
|
bsw@525
|
80 elseif issue.state == "discussion" then
|
bsw@525
|
81 ui.tag{ content = _("Verification starts soon") }
|
bsw@896
|
82 elseif issue.state == "verification" then
|
bsw@525
|
83 ui.tag{ content = _("Voting starts soon") }
|
bsw@525
|
84 elseif issue.state == "voting" then
|
bsw@525
|
85 ui.tag{ content = _("Counting starts soon") }
|
bsw@525
|
86 end
|
bsw@525
|
87 else
|
bsw@938
|
88 ui.tag{ content = format.interval_text(issue.state_time_left, { mode = "time_left" }) }
|
bsw@525
|
89 end
|
bsw@525
|
90 end
|
bsw@525
|
91
|
bsw@525
|
92 end
|
bsw@525
|
93 }
|
bsw@525
|
94
|
bsw@572
|
95 local links = {}
|
bsw@525
|
96
|
bsw@879
|
97 if vote_link_text then
|
bsw@862
|
98 links[#links+1] ={
|
bsw@862
|
99 content = vote_link_text,
|
bsw@862
|
100 module = "vote",
|
bsw@862
|
101 view = "list",
|
bsw@862
|
102 params = { issue_id = issue.id }
|
bsw@862
|
103 }
|
bsw@862
|
104 end
|
bsw@886
|
105
|
bsw@886
|
106 if voteable and not direct_voter then
|
bsw@886
|
107 if not issue.member_info.non_voter then
|
bsw@886
|
108 links[#links+1] ={
|
bsw@886
|
109 content = _"Do not vote directly",
|
bsw@886
|
110 module = "vote",
|
bsw@886
|
111 action = "non_voter",
|
bsw@886
|
112 params = { issue_id = issue.id },
|
bsw@886
|
113 routing = {
|
bsw@886
|
114 default = {
|
bsw@886
|
115 mode = "redirect",
|
bsw@886
|
116 module = request.get_module(),
|
bsw@886
|
117 view = request.get_view(),
|
bsw@886
|
118 id = param.get_id_cgi(),
|
bsw@886
|
119 params = param.get_all_cgi()
|
bsw@886
|
120 }
|
bsw@886
|
121 }
|
bsw@886
|
122 }
|
bsw@886
|
123 else
|
bsw@886
|
124 links[#links+1] = { attr = { class = "action" }, content = _"Do not vote directly" }
|
bsw@886
|
125 links[#links+1] ={
|
bsw@888
|
126 in_brackets = true,
|
bsw@888
|
127 content = _"Cancel [nullify]",
|
bsw@886
|
128 module = "vote",
|
bsw@886
|
129 action = "non_voter",
|
bsw@886
|
130 params = { issue_id = issue.id, delete = true },
|
bsw@886
|
131 routing = {
|
bsw@886
|
132 default = {
|
bsw@886
|
133 mode = "redirect",
|
bsw@886
|
134 module = request.get_module(),
|
bsw@886
|
135 view = request.get_view(),
|
bsw@886
|
136 id = param.get_id_cgi(),
|
bsw@886
|
137 params = param.get_all_cgi()
|
bsw@886
|
138 }
|
bsw@886
|
139 }
|
bsw@886
|
140 }
|
bsw@886
|
141 end
|
bsw@886
|
142 end
|
bsw@525
|
143
|
bsw@862
|
144 if not for_member or for_member.id == app.session.member_id then
|
bsw@862
|
145
|
bsw@525
|
146 if app.session.member_id then
|
bsw@572
|
147
|
bsw@572
|
148 if issue.member_info.own_participation then
|
bsw@572
|
149 if issue.closed then
|
bsw@572
|
150 links[#links+1] = { content = _"You were interested" }
|
bsw@572
|
151 else
|
bsw@572
|
152 links[#links+1] = { content = _"You are interested" }
|
bsw@572
|
153 end
|
bsw@572
|
154 end
|
bsw@572
|
155
|
bsw@572
|
156 if not issue.closed and not issue.fully_frozen then
|
bsw@572
|
157 if issue.member_info.own_participation then
|
bsw@572
|
158 links[#links+1] = {
|
bsw@572
|
159 in_brackets = true,
|
bsw@572
|
160 text = _"Withdraw",
|
bsw@572
|
161 module = "interest",
|
bsw@572
|
162 action = "update",
|
bsw@572
|
163 params = { issue_id = issue.id, delete = true },
|
bsw@572
|
164 routing = {
|
bsw@572
|
165 default = {
|
bsw@572
|
166 mode = "redirect",
|
bsw@572
|
167 module = request.get_module(),
|
bsw@572
|
168 view = request.get_view(),
|
bsw@572
|
169 id = param.get_id_cgi(),
|
bsw@572
|
170 params = param.get_all_cgi()
|
bsw@572
|
171 }
|
bsw@572
|
172 }
|
bsw@572
|
173 }
|
bsw@572
|
174 elseif app.session.member:has_voting_right_for_unit_id(issue.area.unit_id) then
|
bsw@572
|
175 links[#links+1] = {
|
bsw@572
|
176 text = _"Add my interest",
|
bsw@572
|
177 module = "interest",
|
bsw@572
|
178 action = "update",
|
bsw@572
|
179 params = { issue_id = issue.id },
|
bsw@572
|
180 routing = {
|
bsw@572
|
181 default = {
|
bsw@572
|
182 mode = "redirect",
|
bsw@572
|
183 module = request.get_module(),
|
bsw@572
|
184 view = request.get_view(),
|
bsw@572
|
185 id = param.get_id_cgi(),
|
bsw@572
|
186 params = param.get_all_cgi()
|
bsw@572
|
187 }
|
bsw@572
|
188 }
|
bsw@572
|
189 }
|
bsw@572
|
190 end
|
bsw@572
|
191 end
|
bsw@525
|
192
|
bsw@862
|
193 if not issue.closed and app.session.member:has_voting_right_for_unit_id(issue.area.unit_id) then
|
bsw@862
|
194 if issue.member_info.own_delegation_scope ~= "issue" then
|
bsw@862
|
195 links[#links+1] = { text = _"Delegate issue", module = "delegation", view = "show", params = { issue_id = issue.id, initiative_id = for_initiative_id } }
|
bsw@862
|
196 else
|
bsw@862
|
197 links[#links+1] = { text = _"Change issue delegation", module = "delegation", view = "show", params = { issue_id = issue.id, initiative_id = for_initiative_id } }
|
bsw@862
|
198 end
|
bsw@529
|
199 end
|
bsw@529
|
200 end
|
bsw@529
|
201
|
bsw@525
|
202 if config.issue_discussion_url_func then
|
bsw@525
|
203 local url = config.issue_discussion_url_func(issue)
|
bsw@572
|
204 links[#links+1] = {
|
bsw@525
|
205 attr = { target = "_blank" },
|
bsw@525
|
206 external = url,
|
bsw@525
|
207 content = _"Discussion on issue"
|
bsw@525
|
208 }
|
bsw@525
|
209 end
|
bsw@525
|
210
|
bsw@525
|
211 if config.etherpad and app.session.member then
|
bsw@572
|
212 links[#links+1] = {
|
bsw@525
|
213 attr = { target = "_blank" },
|
bsw@525
|
214 external = issue.etherpad_url,
|
bsw@525
|
215 content = _"Issue pad"
|
bsw@525
|
216 }
|
bsw@525
|
217 end
|
bsw@525
|
218
|
bsw@525
|
219
|
bsw@525
|
220 if app.session.member_id and app.session.member:has_voting_right_for_unit_id(issue.area.unit_id) then
|
bsw@525
|
221 if not issue.fully_frozen and not issue.closed then
|
bsw@572
|
222 links[#links+1] = {
|
bsw@525
|
223 attr = { class = "action" },
|
bsw@525
|
224 text = _"Create alternative initiative",
|
bsw@525
|
225 module = "initiative",
|
bsw@525
|
226 view = "new",
|
bsw@525
|
227 params = { issue_id = issue.id }
|
bsw@525
|
228 }
|
bsw@525
|
229 end
|
bsw@525
|
230 end
|
bsw@525
|
231
|
bsw@862
|
232 end
|
bsw@862
|
233
|
bsw@572
|
234 ui.container{ attr = { class = "content actions" }, content = function()
|
bsw@572
|
235 for i, link in ipairs(links) do
|
bsw@572
|
236 if link.in_brackets then
|
bsw@572
|
237 slot.put(" (")
|
bsw@572
|
238 elseif i > 1 then
|
bsw@572
|
239 slot.put(" · ")
|
bsw@572
|
240 end
|
bsw@582
|
241 if link.module or link.external then
|
bsw@572
|
242 ui.link(link)
|
bsw@572
|
243 else
|
bsw@572
|
244 ui.tag(link)
|
bsw@572
|
245 end
|
bsw@572
|
246 if link.in_brackets then
|
bsw@572
|
247 slot.put(")")
|
bsw@572
|
248 end
|
bsw@572
|
249 end
|
bsw@525
|
250 end }
|
bsw@525
|
251
|
bsw@525
|
252 if not for_listing then
|
bsw@971
|
253 if issue.state == "canceled_issue_not_accepted" then
|
bsw@527
|
254 local policy = issue.policy
|
bsw@527
|
255 ui.container{
|
bsw@527
|
256 attr = { class = "not_admitted_info" },
|
bsw@973
|
257 content = _("This issue has been canceled. It failed the quorum of #{quorum}.", { quorum = format.percentage(policy.issue_quorum_num / policy.issue_quorum_den) })
|
bsw@527
|
258 }
|
bsw@971
|
259 elseif issue.state:sub(1, #("canceled_")) == "canceled_" then
|
bsw@971
|
260 ui.container{
|
bsw@971
|
261 attr = { class = "not_admitted_info" },
|
bsw@973
|
262 content = _("This issue has been canceled.")
|
bsw@971
|
263 }
|
bsw@527
|
264 end
|
bsw@525
|
265 end
|
bsw@525
|
266
|
bsw@642
|
267 ui.container{ attr = { class = "initiative_list content" }, content = function()
|
bsw@525
|
268
|
bsw@525
|
269 local initiatives_selector = issue:get_reference_selector("initiatives")
|
bsw@525
|
270 local highlight_string = param.get("highlight_string")
|
bsw@525
|
271 if highlight_string then
|
bsw@525
|
272 initiatives_selector:add_field( {'"highlight"("initiative"."name", ?)', highlight_string }, "name_highlighted")
|
bsw@525
|
273 end
|
bsw@525
|
274 execute.view{
|
bsw@525
|
275 module = "initiative",
|
bsw@525
|
276 view = "_list",
|
bsw@525
|
277 params = {
|
bsw@525
|
278 issue = issue,
|
bsw@525
|
279 initiatives_selector = initiatives_selector,
|
bsw@715
|
280 highlight_initiative = for_initiative,
|
bsw@525
|
281 highlight_string = highlight_string,
|
bsw@525
|
282 no_sort = true,
|
bsw@715
|
283 limit = (for_listing or for_initiative) and 5 or nil,
|
bsw@525
|
284 for_member = for_member
|
bsw@525
|
285 }
|
bsw@525
|
286 }
|
bsw@525
|
287 end }
|
bsw@525
|
288 end }
|
bsw@525
|
289
|