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@525
|
3 local for_listing = param.get("for_listing", atom.boolean)
|
bsw@574
|
4 local for_initiative = param.get("for_initiative", "table")
|
bsw@574
|
5 local for_initiative_id = for_initiative and for_initiative.id or nil
|
bsw@525
|
6
|
bsw@525
|
7 local direct_voter
|
bsw@525
|
8 if app.session.member_id then
|
bsw@547
|
9 direct_voter = issue.member_info.direct_voted
|
bsw@525
|
10 end
|
bsw@525
|
11
|
bsw@525
|
12 local voteable = app.session.member_id and issue.state == 'voting' and
|
bsw@525
|
13 app.session.member:has_voting_right_for_unit_id(issue.area.unit_id)
|
bsw@525
|
14
|
bsw@691
|
15 local vote_link_text = direct_voter and _"Change vote" or _"Vote now"
|
bsw@525
|
16
|
bsw@525
|
17
|
bsw@525
|
18 local class = "issue"
|
bsw@525
|
19 if issue.is_interested then
|
bsw@525
|
20 class = class .. " interested"
|
bsw@525
|
21 elseif issue.is_interested_by_delegation_to_member_id then
|
bsw@525
|
22 class = class .. " interested_by_delegation"
|
bsw@525
|
23 end
|
bsw@525
|
24
|
bsw@525
|
25 ui.container{ attr = { class = class }, content = function()
|
bsw@525
|
26
|
bsw@525
|
27 execute.view{ module = "delegation", view = "_info", params = { issue = issue } }
|
bsw@525
|
28
|
bsw@635
|
29 if for_listing then
|
bsw@635
|
30 ui.container{ attr = { class = "content" }, content = function()
|
bsw@678
|
31 ui.link{
|
bsw@678
|
32 module = "unit", view = "show", id = issue.area.unit_id,
|
bsw@678
|
33 attr = { class = "unit_link" }, text = issue.area.unit.name
|
bsw@678
|
34 }
|
bsw@678
|
35 slot.put(" ")
|
bsw@678
|
36 ui.link{
|
bsw@678
|
37 module = "area", view = "show", id = issue.area_id,
|
bsw@678
|
38 attr = { class = "area_link" }, text = issue.area.name
|
bsw@678
|
39 }
|
bsw@635
|
40 end }
|
bsw@635
|
41 end
|
bsw@635
|
42
|
bsw@525
|
43 ui.container{ attr = { class = "title" }, content = function()
|
bsw@525
|
44
|
bsw@525
|
45 ui.link{
|
bsw@525
|
46 attr = { class = "issue_id" },
|
bsw@525
|
47 text = _("#{policy_name} ##{issue_id}", {
|
bsw@525
|
48 policy_name = issue.policy.name,
|
bsw@525
|
49 issue_id = issue.id
|
bsw@525
|
50 }),
|
bsw@525
|
51 module = "issue",
|
bsw@525
|
52 view = "show",
|
bsw@525
|
53 id = issue.id
|
bsw@525
|
54 }
|
bsw@525
|
55 end }
|
bsw@525
|
56
|
bsw@525
|
57 ui.tag{
|
bsw@525
|
58 attr = { class = "content issue_policy_info" },
|
bsw@525
|
59 tag = "div",
|
bsw@525
|
60 content = function()
|
bsw@525
|
61
|
bsw@525
|
62 ui.tag{ attr = { class = "event_name" }, content = issue.state_name }
|
bsw@525
|
63
|
bsw@525
|
64 if issue.state_time_left then
|
bsw@525
|
65 slot.put(" · ")
|
bsw@525
|
66 if issue.state_time_left:sub(1,1) == "-" then
|
bsw@550
|
67 if issue.state == "accepted" then
|
bsw@525
|
68 ui.tag{ content = _("Discussion starts soon") }
|
bsw@525
|
69 elseif issue.state == "discussion" then
|
bsw@525
|
70 ui.tag{ content = _("Verification starts soon") }
|
bsw@525
|
71 elseif issue.state == "frozen" then
|
bsw@525
|
72 ui.tag{ content = _("Voting starts soon") }
|
bsw@525
|
73 elseif issue.state == "voting" then
|
bsw@525
|
74 ui.tag{ content = _("Counting starts soon") }
|
bsw@525
|
75 end
|
bsw@525
|
76 else
|
bsw@525
|
77 ui.tag{ content = _("#{time_left} left", { time_left = issue.state_time_left:gsub("days", _"days"):gsub("day", _"day") }) }
|
bsw@525
|
78 end
|
bsw@525
|
79 end
|
bsw@525
|
80
|
bsw@525
|
81 end
|
bsw@525
|
82 }
|
bsw@525
|
83
|
bsw@572
|
84 local links = {}
|
bsw@525
|
85
|
bsw@525
|
86 if voteable then
|
bsw@572
|
87 links[#links+1] ={
|
bsw@525
|
88 content = vote_link_text,
|
bsw@525
|
89 module = "vote",
|
bsw@525
|
90 view = "list",
|
bsw@525
|
91 params = { issue_id = issue.id }
|
bsw@525
|
92 }
|
bsw@525
|
93 end
|
bsw@525
|
94
|
bsw@525
|
95 if app.session.member_id then
|
bsw@572
|
96
|
bsw@572
|
97 if issue.member_info.own_participation then
|
bsw@572
|
98 if issue.closed then
|
bsw@572
|
99 links[#links+1] = { content = _"You were interested" }
|
bsw@572
|
100 else
|
bsw@572
|
101 links[#links+1] = { content = _"You are interested" }
|
bsw@572
|
102 end
|
bsw@572
|
103 end
|
bsw@572
|
104
|
bsw@572
|
105 if not issue.closed and not issue.fully_frozen then
|
bsw@572
|
106 if issue.member_info.own_participation then
|
bsw@572
|
107 links[#links+1] = {
|
bsw@572
|
108 in_brackets = true,
|
bsw@572
|
109 text = _"Withdraw",
|
bsw@572
|
110 module = "interest",
|
bsw@572
|
111 action = "update",
|
bsw@572
|
112 params = { issue_id = issue.id, delete = true },
|
bsw@572
|
113 routing = {
|
bsw@572
|
114 default = {
|
bsw@572
|
115 mode = "redirect",
|
bsw@572
|
116 module = request.get_module(),
|
bsw@572
|
117 view = request.get_view(),
|
bsw@572
|
118 id = param.get_id_cgi(),
|
bsw@572
|
119 params = param.get_all_cgi()
|
bsw@572
|
120 }
|
bsw@572
|
121 }
|
bsw@572
|
122 }
|
bsw@572
|
123 elseif app.session.member:has_voting_right_for_unit_id(issue.area.unit_id) then
|
bsw@572
|
124 links[#links+1] = {
|
bsw@572
|
125 text = _"Add my interest",
|
bsw@572
|
126 module = "interest",
|
bsw@572
|
127 action = "update",
|
bsw@572
|
128 params = { issue_id = issue.id },
|
bsw@572
|
129 routing = {
|
bsw@572
|
130 default = {
|
bsw@572
|
131 mode = "redirect",
|
bsw@572
|
132 module = request.get_module(),
|
bsw@572
|
133 view = request.get_view(),
|
bsw@572
|
134 id = param.get_id_cgi(),
|
bsw@572
|
135 params = param.get_all_cgi()
|
bsw@572
|
136 }
|
bsw@572
|
137 }
|
bsw@572
|
138 }
|
bsw@572
|
139 end
|
bsw@572
|
140 end
|
bsw@525
|
141 end
|
bsw@525
|
142
|
bsw@573
|
143 if not issue.closed and app.session.member_id and app.session.member:has_voting_right_for_unit_id(issue.area.unit_id) then
|
bsw@547
|
144 if issue.member_info.own_delegation_scope ~= "issue" then
|
bsw@574
|
145 links[#links+1] = { text = _"Delegate issue", module = "delegation", view = "show", params = { issue_id = issue.id, initiative_id = for_initiative_id } }
|
bsw@529
|
146 else
|
bsw@574
|
147 links[#links+1] = { text = _"Change issue delegation", module = "delegation", view = "show", params = { issue_id = issue.id, initiative_id = for_initiative_id } }
|
bsw@529
|
148 end
|
bsw@529
|
149 end
|
bsw@529
|
150
|
bsw@525
|
151 if config.issue_discussion_url_func then
|
bsw@525
|
152 local url = config.issue_discussion_url_func(issue)
|
bsw@572
|
153 links[#links+1] = {
|
bsw@525
|
154 attr = { target = "_blank" },
|
bsw@525
|
155 external = url,
|
bsw@525
|
156 content = _"Discussion on issue"
|
bsw@525
|
157 }
|
bsw@525
|
158 end
|
bsw@525
|
159
|
bsw@525
|
160 if config.etherpad and app.session.member then
|
bsw@572
|
161 links[#links+1] = {
|
bsw@525
|
162 attr = { target = "_blank" },
|
bsw@525
|
163 external = issue.etherpad_url,
|
bsw@525
|
164 content = _"Issue pad"
|
bsw@525
|
165 }
|
bsw@525
|
166 end
|
bsw@525
|
167
|
bsw@525
|
168
|
bsw@525
|
169 if app.session.member_id and app.session.member:has_voting_right_for_unit_id(issue.area.unit_id) then
|
bsw@525
|
170 if not issue.fully_frozen and not issue.closed then
|
bsw@572
|
171 links[#links+1] = {
|
bsw@525
|
172 attr = { class = "action" },
|
bsw@525
|
173 text = _"Create alternative initiative",
|
bsw@525
|
174 module = "initiative",
|
bsw@525
|
175 view = "new",
|
bsw@525
|
176 params = { issue_id = issue.id }
|
bsw@525
|
177 }
|
bsw@525
|
178 end
|
bsw@525
|
179 end
|
bsw@525
|
180
|
bsw@572
|
181 ui.container{ attr = { class = "content actions" }, content = function()
|
bsw@572
|
182 for i, link in ipairs(links) do
|
bsw@572
|
183 if link.in_brackets then
|
bsw@572
|
184 slot.put(" (")
|
bsw@572
|
185 elseif i > 1 then
|
bsw@572
|
186 slot.put(" · ")
|
bsw@572
|
187 end
|
bsw@582
|
188 if link.module or link.external then
|
bsw@572
|
189 ui.link(link)
|
bsw@572
|
190 else
|
bsw@572
|
191 ui.tag(link)
|
bsw@572
|
192 end
|
bsw@572
|
193 if link.in_brackets then
|
bsw@572
|
194 slot.put(")")
|
bsw@572
|
195 end
|
bsw@572
|
196 end
|
bsw@525
|
197 end }
|
bsw@525
|
198
|
bsw@525
|
199 if not for_listing then
|
bsw@527
|
200 if issue.state == "cancelled" then
|
bsw@527
|
201 local policy = issue.policy
|
bsw@527
|
202 ui.container{
|
bsw@527
|
203 attr = { class = "not_admitted_info" },
|
bsw@527
|
204 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
|
205 }
|
bsw@527
|
206 end
|
bsw@525
|
207 end
|
bsw@525
|
208
|
bsw@642
|
209 ui.container{ attr = { class = "initiative_list content" }, content = function()
|
bsw@525
|
210
|
bsw@525
|
211 local initiatives_selector = issue:get_reference_selector("initiatives")
|
bsw@525
|
212 local highlight_string = param.get("highlight_string")
|
bsw@525
|
213 if highlight_string then
|
bsw@525
|
214 initiatives_selector:add_field( {'"highlight"("initiative"."name", ?)', highlight_string }, "name_highlighted")
|
bsw@525
|
215 end
|
bsw@525
|
216 execute.view{
|
bsw@525
|
217 module = "initiative",
|
bsw@525
|
218 view = "_list",
|
bsw@525
|
219 params = {
|
bsw@525
|
220 issue = issue,
|
bsw@525
|
221 initiatives_selector = initiatives_selector,
|
bsw@715
|
222 highlight_initiative = for_initiative,
|
bsw@525
|
223 highlight_string = highlight_string,
|
bsw@525
|
224 no_sort = true,
|
bsw@715
|
225 limit = (for_listing or for_initiative) and 5 or nil,
|
bsw@525
|
226 for_member = for_member
|
bsw@525
|
227 }
|
bsw@525
|
228 }
|
bsw@525
|
229 end }
|
bsw@525
|
230 end }
|
bsw@525
|
231
|