liquid_feedback_frontend
view app/main/issue/_show.lua @ 572:1b799fcdae31
Fixed middots at issue actions
author | bsw |
---|---|
date | Tue Jun 19 23:35:10 2012 +0200 (2012-06-19) |
parents | 565bcc56ea30 |
children | b8e72db6dd0d |
line source
1 local issue = param.get("issue", "table")
2 local initiative_limit = param.get("initiative_limit", atom.integer)
3 local for_listing = param.get("for_listing", atom.boolean)
5 local direct_voter
6 if app.session.member_id then
7 direct_voter = issue.member_info.direct_voted
8 end
10 local voteable = app.session.member_id and issue.state == 'voting' and
11 app.session.member:has_voting_right_for_unit_id(issue.area.unit_id)
13 local vote_link_text = direct_voter and _"Change vote" or "Vote now"
16 local class = "issue"
17 if issue.is_interested then
18 class = class .. " interested"
19 elseif issue.is_interested_by_delegation_to_member_id then
20 class = class .. " interested_by_delegation"
21 end
23 ui.container{ attr = { class = class }, content = function()
25 execute.view{ module = "delegation", view = "_info", params = { issue = issue } }
27 ui.container{ attr = { class = "title" }, content = function()
29 ui.link{
30 attr = { class = "issue_id" },
31 text = _("#{policy_name} ##{issue_id}", {
32 policy_name = issue.policy.name,
33 issue_id = issue.id
34 }),
35 module = "issue",
36 view = "show",
37 id = issue.id
38 }
39 end }
40 if for_listing then
41 ui.container{ attr = { class = "content" }, content = function()
42 ui.tag{ content = issue.area.unit.name }
43 slot.put(" · ")
44 ui.tag{ content = issue.area.name }
45 end }
46 end
48 ui.tag{
49 attr = { class = "content issue_policy_info" },
50 tag = "div",
51 content = function()
53 ui.tag{ attr = { class = "event_name" }, content = issue.state_name }
55 if issue.state_time_left then
56 slot.put(" · ")
57 if issue.state_time_left:sub(1,1) == "-" then
58 if issue.state == "accepted" then
59 ui.tag{ content = _("Discussion starts soon") }
60 elseif issue.state == "discussion" then
61 ui.tag{ content = _("Verification starts soon") }
62 elseif issue.state == "frozen" then
63 ui.tag{ content = _("Voting starts soon") }
64 elseif issue.state == "voting" then
65 ui.tag{ content = _("Counting starts soon") }
66 end
67 else
68 ui.tag{ content = _("#{time_left} left", { time_left = issue.state_time_left:gsub("days", _"days"):gsub("day", _"day") }) }
69 end
70 end
72 end
73 }
75 local links = {}
77 if voteable then
78 links[#links+1] ={
79 content = vote_link_text,
80 module = "vote",
81 view = "list",
82 params = { issue_id = issue.id }
83 }
84 end
86 if app.session.member_id then
88 if issue.member_info.own_participation then
89 if issue.closed then
90 links[#links+1] = { content = _"You were interested" }
91 else
92 links[#links+1] = { content = _"You are interested" }
93 end
94 end
96 if not issue.closed and not issue.fully_frozen then
97 if issue.member_info.own_participation then
98 links[#links+1] = {
99 in_brackets = true,
100 text = _"Withdraw",
101 module = "interest",
102 action = "update",
103 params = { issue_id = issue.id, delete = true },
104 routing = {
105 default = {
106 mode = "redirect",
107 module = request.get_module(),
108 view = request.get_view(),
109 id = param.get_id_cgi(),
110 params = param.get_all_cgi()
111 }
112 }
113 }
114 elseif app.session.member:has_voting_right_for_unit_id(issue.area.unit_id) then
115 links[#links+1] = {
116 text = _"Add my interest",
117 module = "interest",
118 action = "update",
119 params = { issue_id = issue.id },
120 routing = {
121 default = {
122 mode = "redirect",
123 module = request.get_module(),
124 view = request.get_view(),
125 id = param.get_id_cgi(),
126 params = param.get_all_cgi()
127 }
128 }
129 }
130 end
131 end
132 end
134 if not issue.closed and app.session.member_id and app.session.member:has_voting_right_for_unit_id(issue.area.unit) then
135 if issue.member_info.own_delegation_scope ~= "issue" then
136 links[#links+1] = { text = _"Delegate issue", module = "delegation", view = "show", params = { issue_id = issue.id } }
137 else
138 links[#links+1] = { text = _"Change issue delegation", module = "delegation", view = "show", params = { issue_id = issue.id } }
139 end
140 end
142 if config.issue_discussion_url_func then
143 local url = config.issue_discussion_url_func(issue)
144 links[#links+1] = {
145 attr = { target = "_blank" },
146 external = url,
147 content = _"Discussion on issue"
148 }
149 end
151 if config.etherpad and app.session.member then
152 links[#links+1] = {
153 attr = { target = "_blank" },
154 external = issue.etherpad_url,
155 content = _"Issue pad"
156 }
157 end
160 if app.session.member_id and app.session.member:has_voting_right_for_unit_id(issue.area.unit_id) then
161 if not issue.fully_frozen and not issue.closed then
162 links[#links+1] = {
163 attr = { class = "action" },
164 text = _"Create alternative initiative",
165 module = "initiative",
166 view = "new",
167 params = { issue_id = issue.id }
168 }
169 end
170 end
172 ui.container{ attr = { class = "content actions" }, content = function()
173 for i, link in ipairs(links) do
174 if link.in_brackets then
175 slot.put(" (")
176 elseif i > 1 then
177 slot.put(" · ")
178 end
179 if link.module then
180 ui.link(link)
181 else
182 ui.tag(link)
183 end
184 if link.in_brackets then
185 slot.put(")")
186 end
187 end
188 end }
190 if not for_listing then
192 if voteable then
193 ui.container{
194 attr = { class = "voting_active_info" },
195 content = function()
196 slot.put(_"Voting for this issue is currently running!")
197 slot.put(" ")
198 if app.session.member_id then
199 ui.link{
200 content = vote_link_text,
201 module = "vote",
202 view = "list",
203 params = { issue_id = issue.id }
204 }
205 end
206 end
207 }
208 end
210 if issue.state == "cancelled" then
211 local policy = issue.policy
212 ui.container{
213 attr = { class = "not_admitted_info" },
214 content = _("This issue has been cancelled. It failed the quorum of #{quorum}.", { quorum = format.percentage(policy.issue_quorum_num / policy.issue_quorum_den) })
215 }
216 end
218 end
220 ui.container{ attr = { class = "initiative_list" }, content = function()
222 local initiatives_selector = issue:get_reference_selector("initiatives")
223 local highlight_string = param.get("highlight_string")
224 if highlight_string then
225 initiatives_selector:add_field( {'"highlight"("initiative"."name", ?)', highlight_string }, "name_highlighted")
226 end
227 execute.view{
228 module = "initiative",
229 view = "_list",
230 params = {
231 issue = issue,
232 initiatives_selector = initiatives_selector,
233 highlight_string = highlight_string,
234 no_sort = true,
235 limit = 5,
236 for_member = for_member
237 }
238 }
239 end }
240 end }