liquid_feedback_frontend
view app/main/initiative/show.lua @ 5:afd9f769c7ae
Version beta1
Final voting with Schulze-Method is now possible
Many bug fixes and code cleanup
Registration with invite codes
More sort and filter options
Seperated display of "supporters" and "potential supporters"
Optical changes
Flood limit / initiative contigent is now checked by frontend
Neccessary changes to access core beta11
Final voting with Schulze-Method is now possible
Many bug fixes and code cleanup
Registration with invite codes
More sort and filter options
Seperated display of "supporters" and "potential supporters"
Optical changes
Flood limit / initiative contigent is now checked by frontend
Neccessary changes to access core beta11
| author | bsw/jbe |
|---|---|
| date | Fri Dec 25 12:00:00 2009 +0100 (2009-12-25) |
| parents | 80c215dbf076 |
| children | 8d91bccab0bf |
line source
1 local initiative = Initiative:new_selector():add_where{ "id = ?", param.get_id()}:single_object_mode():exec()
3 slot.select("actions", function()
4 ui.link{
5 content = function()
6 ui.image{ static = "icons/16/script.png" }
7 slot.put(_"Show all initiatives")
8 end,
9 module = "issue",
10 view = "show",
11 id = initiative.issue.id
12 }
13 end)
15 execute.view{
16 module = "issue",
17 view = "_show_head",
18 params = { issue = initiative.issue }
19 }
21 local initiator = Initiator:by_pk(initiative.id, app.session.member.id)
23 --slot.put_into("html_head", '<link rel="alternate" type="application/rss+xml" title="RSS" href="../show/' .. tostring(initiative.id) .. '.rss" />')
25 execute.view{
26 module = "supporter",
27 view = "_show_box",
28 params = { initiative = initiative }
29 }
31 slot.put_into("sub_title", encode.html(_"Initiative: '#{name}'":gsub("#{name}", initiative.shortened_name) ))
33 slot.select("actions", function()
34 if not initiative.issue.fully_frozen and not initiative.issue.closed then
35 ui.link{
36 attr = { class = "action" },
37 content = function()
38 ui.image{ static = "icons/16/script_add.png" }
39 slot.put(_"Create alternative initiative")
40 end,
41 module = "initiative",
42 view = "new",
43 params = { issue_id = initiative.issue.id }
44 }
45 end
46 end)
49 util.help("initiative.show")
52 ui.container{
53 attr = { class = "vertical" },
54 content = function()
55 ui.container{
56 attr = { class = "ui_field_label" },
57 content = _"Discussion URL"
58 }
59 ui.tag{
60 tag = "span",
61 content = function()
62 if initiative.discussion_url and #initiative.discussion_url > 0 then
63 ui.link{
64 attr = {
65 class = "actions",
66 target = "_blank",
67 title = initiative.discussion_url
68 },
69 content = function()
70 slot.put(encode.html(initiative.discussion_url))
71 end,
72 external = initiative.discussion_url
73 }
74 end
75 slot.put(" ")
76 if initiator then
77 ui.link{
78 attr = { class = "actions" },
79 content = _"(change URL)",
80 module = "initiative",
81 view = "edit",
82 id = initiative.id
83 }
84 end
85 end
86 }
87 end
88 }
92 ui.container{
93 attr = { id = "add_suggestion_form", class = "hidden_inline_form" },
94 content = function()
96 ui.link{
97 content = _"Close",
98 attr = {
99 onclick = "document.getElementById('add_suggestion_form').style.display='none';return(false)",
100 style = "float: right;"
101 }
102 }
104 ui.field.text{ attr = { class = "head" }, value = _"Add new suggestion" }
107 ui.form{
108 module = "suggestion",
109 action = "add",
110 params = { initiative_id = initiative.id },
111 routing = {
112 default = {
113 mode = "redirect",
114 module = "initiative",
115 view = "show",
116 id = initiative.id,
117 params = { tab = "suggestion" }
118 }
119 },
120 attr = { class = "vertical" },
121 content = function()
122 local supported = Supporter:by_pk(initiative.id, app.session.member.id) and true or false
123 if not supported then
124 ui.field.text{
125 attr = { class = "warning" },
126 value = _"You are currently not supporting this initiative. By adding suggestions to this initiative you will automatically become a potential supporter."
127 }
128 end
129 ui.field.text{ label = _"Title (80 chars max)", name = "name" }
130 ui.field.text{ label = _"Description", name = "description", multiline = true }
131 ui.field.select{
132 label = _"Degree",
133 name = "degree",
134 foreign_records = {
135 { id = 1, name = _"should"},
136 { id = 2, name = _"must"},
137 },
138 foreign_id = "id",
139 foreign_name = "name"
140 }
141 ui.submit{ text = _"Commit suggestion" }
142 end
143 }
144 end
145 }
147 local supporter = app.session.member:get_reference_selector("supporters")
148 :add_where{ "initiative_id = ?", initiative.id }
149 :optional_object_mode()
150 :exec()
152 if supporter then
153 local old_draft_id = supporter.draft_id
154 local new_draft_id = initiative.current_draft.id
155 if old_draft_id ~= new_draft_id then
156 ui.container{
157 attr = { class = "draft_updated_info" },
158 content = function()
159 slot.put("The draft of this initiative has been updated!")
160 slot.put(" ")
161 ui.link{
162 content = _"Show diff",
163 module = "draft",
164 view = "diff",
165 params = {
166 old_draft_id = old_draft_id,
167 new_draft_id = new_draft_id
168 }
169 }
170 slot.put(" ")
171 ui.link{
172 content = _"Refresh support to current draft",
173 module = "initiative",
174 action = "add_support",
175 id = initiative.id,
176 routing = {
177 default = {
178 mode = "redirect",
179 module = "initiative",
180 view = "show",
181 id = initiative.id
182 }
183 }
184 }
185 end
186 }
187 end
188 end
191 ui.tabs{
192 {
193 name = "current_draft",
194 label = _"Current draft",
195 content = function()
196 if initiator then
197 ui.link{
198 content = function()
199 ui.image{ static = "icons/16/script_add.png" }
200 slot.put(_"Edit draft")
201 end,
202 module = "draft",
203 view = "new",
204 params = { initiative_id = initiative.id }
205 }
206 end
207 execute.view{ module = "draft", view = "_show", params = { draft = initiative.current_draft } }
208 end
209 },
210 {
211 name = "suggestion",
212 label = _"Suggestions",
213 content = function()
214 execute.view{
215 module = "suggestion",
216 view = "_list",
217 params = {
218 initiative = initiative,
219 suggestions_selector = initiative:get_reference_selector("suggestions")
220 }
221 }
222 slot.put("<br />")
223 if not initiative.issue.fully_frozen and not initiative.issue.closed then
224 ui.link{
225 content = function()
226 ui.image{ static = "icons/16/comment_add.png" }
227 slot.put(_"Add new suggestion")
228 end,
229 attr = { onclick = "document.getElementById('add_suggestion_form').style.display='block';return(false)" },
230 static = "#"
231 }
232 end
233 end
234 },
235 {
236 name = "satisfied_supporter",
237 label = _"Supporter",
238 content = function()
239 execute.view{
240 module = "member",
241 view = "_list",
242 params = {
243 initiative = initiative,
244 members_selector = initiative:get_reference_selector("supporting_members_snapshot")
245 :join("issue", nil, "issue.id = direct_supporter_snapshot.issue_id")
246 :join("direct_interest_snapshot", nil, "direct_interest_snapshot.event = issue.latest_snapshot_event AND direct_interest_snapshot.issue_id = issue.id AND direct_interest_snapshot.member_id = member.id")
247 :add_field("direct_interest_snapshot.weight")
248 :add_where("direct_supporter_snapshot.event = issue.latest_snapshot_event")
249 :add_where("direct_supporter_snapshot.satisfied")
250 }
251 }
252 end
253 },
254 {
255 name = "supporter",
256 label = _"Potential supporter",
257 content = function()
258 execute.view{
259 module = "member",
260 view = "_list",
261 params = {
262 initiative = initiative,
263 members_selector = initiative:get_reference_selector("supporting_members_snapshot")
264 :join("issue", nil, "issue.id = direct_supporter_snapshot.issue_id")
265 :join("direct_interest_snapshot", nil, "direct_interest_snapshot.event = issue.latest_snapshot_event AND direct_interest_snapshot.issue_id = issue.id AND direct_interest_snapshot.member_id = member.id")
266 :add_field("direct_interest_snapshot.weight")
267 :add_where("direct_supporter_snapshot.event = issue.latest_snapshot_event")
268 :add_where("NOT direct_supporter_snapshot.satisfied")
269 }
270 }
271 end
272 },
273 {
274 name = "initiators",
275 label = _"Initiators",
276 content = function()
277 execute.view{ module = "member", view = "_list", params = { members_selector = initiative:get_reference_selector("initiating_members") } }
278 end
279 },
280 {
281 name = "drafts",
282 label = _"Old drafts",
283 content = function()
284 execute.view{ module = "draft", view = "_list", params = { drafts = initiative.drafts } }
285 end
286 },
287 {
288 name = "details",
289 label = _"Details",
290 content = function()
291 ui.form{
292 attr = { class = "vertical" },
293 record = initiative,
294 readonly = true,
295 content = function()
296 ui.field.text{ label = _"Issue policy", value = initiative.issue.policy.name }
297 ui.field.text{
298 label = _"Created at",
299 value = tostring(initiative.created)
300 }
301 ui.field.text{
302 label = _"Created at",
303 value = format.timestamp(initiative.created)
304 }
305 ui.field.date{ label = _"Revoked at", name = "revoked" }
306 ui.field.boolean{ label = _"Admitted", name = "admitted" }
307 end
308 }
309 end
310 },
311 }
