liquid_feedback_frontend
view app/main/initiative/_show.lua @ 558:18e8de7a2b6a
Show notifications on start page as ulli list with links instead of tabs
author | bsw |
---|---|
date | Tue Jun 19 21:20:46 2012 +0200 (2012-06-19) |
parents | 4cee33ad5e16 |
children | e7baf2713987 |
line source
1 local initiative = param.get("initiative", "table")
3 local initiators_members_selector = initiative:get_reference_selector("initiating_members")
4 :add_field("initiator.accepted", "accepted")
5 :add_order_by("member.name")
6 if initiator and initiator.accepted then
7 initiators_members_selector:add_where("initiator.accepted ISNULL OR initiator.accepted")
8 else
9 initiators_members_selector:add_where("initiator.accepted")
10 end
12 local initiators = initiators_members_selector:exec()
15 local initiatives_selector = initiative.issue:get_reference_selector("initiatives")
16 slot.select("head", function()
17 execute.view{
18 module = "issue",
19 view = "_show",
20 params = {
21 issue = initiative.issue,
22 initiative_limit = 3
23 }
24 }
25 end)
27 ui.container{ attr = { class = "initiative_head" }, content = function()
29 ui.container{
30 attr = { class = "title" },
31 content = _("Initiative i#{id}: #{name}", { id = initiative.id, name = initiative.name })
32 }
34 ui.container{ attr = { class = "content" }, content = function()
35 if app.session.member_id or config.public_access == "pseudonym" or config.public_access == "full" then
36 ui.tag{
37 attr = { class = "initiator_names" },
38 content = function()
39 for i, initiator in ipairs(initiators) do
40 slot.put(" ")
41 if app.session.member_id or config.public_access == "full" then
42 ui.link{
43 content = function ()
44 execute.view{
45 module = "member_image",
46 view = "_show",
47 params = {
48 member = initiator,
49 image_type = "avatar",
50 show_dummy = true,
51 class = "micro_avatar",
52 popup_text = text
53 }
54 }
55 end,
56 module = "member", view = "show", id = initiator.id
57 }
58 slot.put(" ")
59 end
60 ui.link{
61 text = initiator.name,
62 module = "member", view = "show", id = initiator.id
63 }
64 if not initiator.accepted then
65 ui.tag{ attr = { title = _"Not accepted yet" }, content = "?" }
66 end
67 end
68 end
69 }
70 end
72 if initiator and initiator.accepted and not initiative.issue.fully_frozen and not initiative.issue.closed and not initiative.revoked then
73 slot.put(" · ")
74 ui.link{
75 attr = { class = "action" },
76 content = function()
77 slot.put(_"Invite initiator")
78 end,
79 module = "initiative",
80 view = "add_initiator",
81 params = { initiative_id = initiative.id }
82 }
83 if #initiators > 1 then
84 slot.put(" · ")
85 ui.link{
86 content = function()
87 slot.put(_"Remove initiator")
88 end,
89 module = "initiative",
90 view = "remove_initiator",
91 params = { initiative_id = initiative.id }
92 }
93 end
94 end
95 if initiator and initiator.accepted == false then
96 slot.put(" · ")
97 ui.link{
98 text = _"Cancel refuse of invitation",
99 module = "initiative",
100 action = "remove_initiator",
101 params = {
102 initiative_id = initiative.id,
103 member_id = app.session.member.id
104 },
105 routing = {
106 ok = {
107 mode = "redirect",
108 module = "initiative",
109 view = "show",
110 id = initiative.id
111 }
112 }
113 }
114 end
115 end }
116 ui.container{ attr = { class = "content" }, content = function()
117 if app.session.member_id then
118 execute.view{
119 module = "supporter",
120 view = "_show_box",
121 params = {
122 initiative = initiative
123 }
124 }
125 end
127 end }
129 end }
132 util.help("initiative.show")
134 --slot.select("initiative_head", function()
136 if initiative.issue.ranks_available and initiative.admitted then
137 local class = initiative.winner and "admitted_info" or "not_admitted_info"
138 ui.container{
139 attr = { class = class },
140 content = function()
141 local max_value = initiative.issue.voter_count
142 slot.put(" ")
143 local positive_votes = initiative.positive_votes
144 local negative_votes = initiative.negative_votes
145 local sum_votes = initiative.positive_votes + initiative.negative_votes
146 local function perc(votes, sum)
147 if sum > 0 and votes > 0 then return " (" .. string.format( "%.f", votes * 100 / sum ) .. "%)" end
148 return ""
149 end
150 slot.put(_"Yes" .. ": <b>" .. tostring(positive_votes) .. perc(positive_votes, sum_votes) .. "</b>")
151 slot.put(" · ")
152 slot.put(_"Abstention" .. ": <b>" .. tostring(max_value - initiative.negative_votes - initiative.positive_votes) .. "</b>")
153 slot.put(" · ")
154 slot.put(_"No" .. ": <b>" .. tostring(initiative.negative_votes) .. perc(negative_votes, sum_votes) .. "</b>")
155 slot.put(" · ")
156 slot.put("<b>")
157 if initiative.winner then
158 slot.put(_"Approved")
159 elseif initiative.rank then
160 slot.put(_("Not approved (rank #{rank})", { rank = initiative.rank }))
161 else
162 slot.put(_"Not approved")
163 end
164 slot.put("</b>")
165 end
166 }
167 end
169 if initiative.admitted == false then
170 local policy = initiative.issue.policy
171 ui.container{
172 attr = { class = "not_admitted_info" },
173 content = _("This initiative has not been admitted! It failed the quorum of #{quorum}.", { quorum = format.percentage(policy.initiative_quorum_num / policy.initiative_quorum_den) })
174 }
175 end
177 if initiative.revoked then
178 ui.container{
179 attr = { class = "revoked_info" },
180 content = function()
181 slot.put(_("This initiative has been revoked at #{revoked}", { revoked = format.timestamp(initiative.revoked) }))
182 local suggested_initiative = initiative.suggested_initiative
183 if suggested_initiative then
184 slot.put("<br /><br />")
185 slot.put(_("The initiators suggest to support the following initiative:"))
186 slot.put(" ")
187 ui.link{
188 content = _("Issue ##{id}", { id = suggested_initiative.issue.id } ) .. ": " .. encode.html(suggested_initiative.name),
189 module = "initiative",
190 view = "show",
191 id = suggested_initiative.id
192 }
193 end
194 end
195 }
196 end
198 --end)
200 if initiator and initiator.accepted == nil and not initiative.issue.half_frozen and not initiative.issue.closed then
201 ui.container{
202 attr = { class = "initiator_invite_info" },
203 content = function()
204 slot.put(_"You are invited to become initiator of this initiative.")
205 slot.put(" ")
206 ui.link{
207 image = { static = "icons/16/tick.png" },
208 text = _"Accept invitation",
209 module = "initiative",
210 action = "accept_invitation",
211 id = initiative.id,
212 routing = {
213 default = {
214 mode = "redirect",
215 module = request.get_module(),
216 view = request.get_view(),
217 id = param.get_id_cgi(),
218 params = param.get_all_cgi()
219 }
220 }
221 }
222 slot.put(" ")
223 ui.link{
224 image = { static = "icons/16/cross.png" },
225 text = _"Refuse invitation",
226 module = "initiative",
227 action = "reject_initiator_invitation",
228 params = {
229 initiative_id = initiative.id,
230 member_id = app.session.member.id
231 },
232 routing = {
233 default = {
234 mode = "redirect",
235 module = request.get_module(),
236 view = request.get_view(),
237 id = param.get_id_cgi(),
238 params = param.get_all_cgi()
239 }
240 }
241 }
242 end
243 }
244 slot.put("<br />")
245 end
248 local supporter
250 if app.session.member_id then
251 supporter = app.session.member:get_reference_selector("supporters")
252 :add_where{ "initiative_id = ?", initiative.id }
253 :optional_object_mode()
254 :exec()
255 end
257 if supporter and not initiative.issue.closed then
258 local old_draft_id = supporter.draft_id
259 local new_draft_id = initiative.current_draft.id
260 if old_draft_id ~= new_draft_id then
261 ui.container{
262 attr = { class = "draft_updated_info" },
263 content = function()
264 slot.put(_"The draft of this initiative has been updated!")
265 slot.put(" ")
266 ui.link{
267 content = _"Show diff",
268 module = "draft",
269 view = "diff",
270 params = {
271 old_draft_id = old_draft_id,
272 new_draft_id = new_draft_id
273 }
274 }
275 if not initiative.revoked then
276 slot.put(" ")
277 ui.link{
278 text = _"Refresh support to current draft",
279 module = "initiative",
280 action = "add_support",
281 id = initiative.id,
282 routing = {
283 default = {
284 mode = "redirect",
285 module = "initiative",
286 view = "show",
287 id = initiative.id
288 }
289 }
290 }
291 end
292 end
293 }
294 end
295 end
297 execute.view{
298 module = "initiative",
299 view = "show_tab",
300 params = {
301 initiative = initiative,
302 initiator = initiator
303 }
304 }
306 if initiative.issue.snapshot then
307 slot.put("<br />")
308 ui.field.timestamp{ label = _"Last snapshot:", value = initiative.issue.snapshot }
309 end