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@863
|
74 ui.tag{ content = _("#{closed_ago} ago", { closed_ago = issue.closed_ago:gsub("%..*", ""):gsub("days", _"days"):gsub("day", _"day") }) }
|
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@550
|
78 if issue.state == "accepted" 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@525
|
82 elseif issue.state == "frozen" 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@723
|
88 ui.tag{ content = _("#{time_left} left", { time_left = issue.state_time_left:gsub("%..*", ""):gsub("days", _"days"):gsub("day", _"day") }) }
|
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@525
|
105
|
bsw@862
|
106 if not for_member or for_member.id == app.session.member_id then
|
bsw@862
|
107
|
bsw@525
|
108 if app.session.member_id then
|
bsw@572
|
109
|
bsw@572
|
110 if issue.member_info.own_participation then
|
bsw@572
|
111 if issue.closed then
|
bsw@572
|
112 links[#links+1] = { content = _"You were interested" }
|
bsw@572
|
113 else
|
bsw@572
|
114 links[#links+1] = { content = _"You are interested" }
|
bsw@572
|
115 end
|
bsw@572
|
116 end
|
bsw@572
|
117
|
bsw@572
|
118 if not issue.closed and not issue.fully_frozen then
|
bsw@572
|
119 if issue.member_info.own_participation then
|
bsw@572
|
120 links[#links+1] = {
|
bsw@572
|
121 in_brackets = true,
|
bsw@572
|
122 text = _"Withdraw",
|
bsw@572
|
123 module = "interest",
|
bsw@572
|
124 action = "update",
|
bsw@572
|
125 params = { issue_id = issue.id, delete = true },
|
bsw@572
|
126 routing = {
|
bsw@572
|
127 default = {
|
bsw@572
|
128 mode = "redirect",
|
bsw@572
|
129 module = request.get_module(),
|
bsw@572
|
130 view = request.get_view(),
|
bsw@572
|
131 id = param.get_id_cgi(),
|
bsw@572
|
132 params = param.get_all_cgi()
|
bsw@572
|
133 }
|
bsw@572
|
134 }
|
bsw@572
|
135 }
|
bsw@572
|
136 elseif app.session.member:has_voting_right_for_unit_id(issue.area.unit_id) then
|
bsw@572
|
137 links[#links+1] = {
|
bsw@572
|
138 text = _"Add my interest",
|
bsw@572
|
139 module = "interest",
|
bsw@572
|
140 action = "update",
|
bsw@572
|
141 params = { issue_id = issue.id },
|
bsw@572
|
142 routing = {
|
bsw@572
|
143 default = {
|
bsw@572
|
144 mode = "redirect",
|
bsw@572
|
145 module = request.get_module(),
|
bsw@572
|
146 view = request.get_view(),
|
bsw@572
|
147 id = param.get_id_cgi(),
|
bsw@572
|
148 params = param.get_all_cgi()
|
bsw@572
|
149 }
|
bsw@572
|
150 }
|
bsw@572
|
151 }
|
bsw@572
|
152 end
|
bsw@572
|
153 end
|
bsw@525
|
154
|
bsw@862
|
155 if not issue.closed and app.session.member:has_voting_right_for_unit_id(issue.area.unit_id) then
|
bsw@862
|
156 if issue.member_info.own_delegation_scope ~= "issue" then
|
bsw@862
|
157 links[#links+1] = { text = _"Delegate issue", module = "delegation", view = "show", params = { issue_id = issue.id, initiative_id = for_initiative_id } }
|
bsw@862
|
158 else
|
bsw@862
|
159 links[#links+1] = { text = _"Change issue delegation", module = "delegation", view = "show", params = { issue_id = issue.id, initiative_id = for_initiative_id } }
|
bsw@862
|
160 end
|
bsw@529
|
161 end
|
bsw@529
|
162 end
|
bsw@529
|
163
|
bsw@525
|
164 if config.issue_discussion_url_func then
|
bsw@525
|
165 local url = config.issue_discussion_url_func(issue)
|
bsw@572
|
166 links[#links+1] = {
|
bsw@525
|
167 attr = { target = "_blank" },
|
bsw@525
|
168 external = url,
|
bsw@525
|
169 content = _"Discussion on issue"
|
bsw@525
|
170 }
|
bsw@525
|
171 end
|
bsw@525
|
172
|
bsw@525
|
173 if config.etherpad and app.session.member then
|
bsw@572
|
174 links[#links+1] = {
|
bsw@525
|
175 attr = { target = "_blank" },
|
bsw@525
|
176 external = issue.etherpad_url,
|
bsw@525
|
177 content = _"Issue pad"
|
bsw@525
|
178 }
|
bsw@525
|
179 end
|
bsw@525
|
180
|
bsw@525
|
181
|
bsw@525
|
182 if app.session.member_id and app.session.member:has_voting_right_for_unit_id(issue.area.unit_id) then
|
bsw@525
|
183 if not issue.fully_frozen and not issue.closed then
|
bsw@572
|
184 links[#links+1] = {
|
bsw@525
|
185 attr = { class = "action" },
|
bsw@525
|
186 text = _"Create alternative initiative",
|
bsw@525
|
187 module = "initiative",
|
bsw@525
|
188 view = "new",
|
bsw@525
|
189 params = { issue_id = issue.id }
|
bsw@525
|
190 }
|
bsw@525
|
191 end
|
bsw@525
|
192 end
|
bsw@525
|
193
|
bsw@862
|
194 end
|
bsw@862
|
195
|
bsw@572
|
196 ui.container{ attr = { class = "content actions" }, content = function()
|
bsw@572
|
197 for i, link in ipairs(links) do
|
bsw@572
|
198 if link.in_brackets then
|
bsw@572
|
199 slot.put(" (")
|
bsw@572
|
200 elseif i > 1 then
|
bsw@572
|
201 slot.put(" · ")
|
bsw@572
|
202 end
|
bsw@582
|
203 if link.module or link.external then
|
bsw@572
|
204 ui.link(link)
|
bsw@572
|
205 else
|
bsw@572
|
206 ui.tag(link)
|
bsw@572
|
207 end
|
bsw@572
|
208 if link.in_brackets then
|
bsw@572
|
209 slot.put(")")
|
bsw@572
|
210 end
|
bsw@572
|
211 end
|
bsw@525
|
212 end }
|
bsw@525
|
213
|
bsw@525
|
214 if not for_listing then
|
bsw@527
|
215 if issue.state == "cancelled" then
|
bsw@527
|
216 local policy = issue.policy
|
bsw@527
|
217 ui.container{
|
bsw@527
|
218 attr = { class = "not_admitted_info" },
|
bsw@527
|
219 content = _("This issue has been cancelled. It failed the quorum of #{quorum}.", { quorum = format.percentage(policy.issue_quorum_num / policy.issue_quorum_den) })
|
bsw@527
|
220 }
|
bsw@527
|
221 end
|
bsw@525
|
222 end
|
bsw@525
|
223
|
bsw@642
|
224 ui.container{ attr = { class = "initiative_list content" }, content = function()
|
bsw@525
|
225
|
bsw@525
|
226 local initiatives_selector = issue:get_reference_selector("initiatives")
|
bsw@525
|
227 local highlight_string = param.get("highlight_string")
|
bsw@525
|
228 if highlight_string then
|
bsw@525
|
229 initiatives_selector:add_field( {'"highlight"("initiative"."name", ?)', highlight_string }, "name_highlighted")
|
bsw@525
|
230 end
|
bsw@525
|
231 execute.view{
|
bsw@525
|
232 module = "initiative",
|
bsw@525
|
233 view = "_list",
|
bsw@525
|
234 params = {
|
bsw@525
|
235 issue = issue,
|
bsw@525
|
236 initiatives_selector = initiatives_selector,
|
bsw@715
|
237 highlight_initiative = for_initiative,
|
bsw@525
|
238 highlight_string = highlight_string,
|
bsw@525
|
239 no_sort = true,
|
bsw@715
|
240 limit = (for_listing or for_initiative) and 5 or nil,
|
bsw@525
|
241 for_member = for_member
|
bsw@525
|
242 }
|
bsw@525
|
243 }
|
bsw@525
|
244 end }
|
bsw@525
|
245 end }
|
bsw@525
|
246
|