liquid_feedback_frontend

view app/main/initiative/show.lua @ 2:5c601807d397

Version alpha3

Dark green part of issue supporter bargraph represents all satisfied supporters, regardless of having seen the latest draft

Wiki formatting for drafts

Showing differences between two drafts of the same initiative

Display of outgoing delegation chains

Many other improvements
author bsw
date Mon Nov 23 12:00:00 2009 +0100 (2009-11-23)
parents 3bfb2fcf7ab9
children 768faea1096d
line source
1 local initiative = Initiative:new_selector():add_where{ "id = ?", param.get_id()}:single_object_mode():exec()
3 slot.put_into("html_head", '<link rel="alternate" type="application/rss+xml" title="RSS" href="../show/' .. tostring(initiative.id) .. '.rss" />')
5 execute.view{
6 module = "supporter",
7 view = "_show_box",
8 params = { initiative = initiative }
9 }
11 execute.view{
12 module = "delegation",
13 view = "_show_box",
14 params = { issue_id = initiative.issue_id }
15 }
17 execute.view{
18 module = "issue",
19 view = "_show_box",
20 params = { issue = initiative.issue }
21 }
23 slot.select("path", function()
24 ui.link{
25 content = _"Area '#{name}'":gsub("#{name}", initiative.issue.area.name),
26 module = "area",
27 view = "show",
28 id = initiative.issue.area.id
29 }
30 ui.container{ content = "::" }
31 ui.link{
32 content = _"Issue ##{id}":gsub("#{id}", initiative.issue.id),
33 module = "issue",
34 view = "show",
35 id = initiative.issue.id
36 }
37 end)
39 slot.put_into("title", encode.html(_"Initiative: '#{name}'":gsub("#{name}", initiative.shortened_name) ))
41 slot.select("actions", function()
43 if Initiator:by_pk(initiative.id, app.session.member.id) then
44 ui.link{
45 content = function()
46 ui.image{ static = "icons/16/script_add.png" }
47 slot.put(_"Edit draft")
48 end,
49 module = "draft",
50 view = "new",
51 params = { initiative_id = initiative.id }
52 }
53 end
55 ui.twitter("http://example.com/i" .. tostring(initiative.id) .. " " .. initiative.name)
57 end)
60 ui.container{
61 attr = { id = "add_suggestion_form", class = "hidden_inline_form" },
62 content = function()
64 ui.link{
65 content = _"Close",
66 attr = {
67 onclick = "document.getElementById('add_suggestion_form').style.display='none';return(false)",
68 style = "float: right;"
69 }
70 }
72 ui.field.text{ attr = { class = "head" }, value = _"Add new suggestion" }
75 ui.form{
76 module = "suggestion",
77 action = "add",
78 params = { initiative_id = initiative.id },
79 routing = {
80 default = {
81 mode = "redirect",
82 module = "initiative",
83 view = "show",
84 id = initiative.id,
85 params = { tab = "suggestion" }
86 }
87 },
88 attr = { class = "vertical" },
89 content = function()
90 ui.field.text{ label = _"Name", name = "name" }
91 ui.field.text{ label = _"Description", name = "description", multiline = true }
92 ui.field.select{
93 label = _"Degree",
94 name = "degree",
95 foreign_records = {
96 { id = 1, name = _"should"},
97 { id = 2, name = _"must"},
98 },
99 foreign_id = "id",
100 foreign_name = "name"
101 }
102 ui.submit{ text = _"Commit suggestion" }
103 end
104 }
105 end
106 }
108 local supporter = app.session.member:get_reference_selector("supporters")
109 :add_where{ "initiative_id = ?", initiative.id }
110 :optional_object_mode()
111 :exec()
113 if supporter then
114 local old_draft_id = supporter.draft_id
115 local new_draft_id = initiative.current_draft.id
116 if old_draft_id ~= new_draft_id then
117 ui.container{
118 attr = { class = "draft_updated_info" },
119 content = function()
120 slot.put("The draft of this initiative has been updated!")
121 slot.put(" ")
122 ui.link{
123 content = _"Show diff",
124 module = "draft",
125 view = "diff",
126 params = {
127 old_draft_id = old_draft_id,
128 new_draft_id = new_draft_id
129 }
130 }
131 slot.put(" ")
132 ui.link{
133 content = _"Refresh support to current draft",
134 module = "initiative",
135 action = "add_support",
136 id = initiative.id,
137 routing = {
138 default = {
139 mode = "redirect",
140 module = "initiative",
141 view = "show",
142 id = initiative.id
143 }
144 }
145 }
146 end
147 }
148 end
149 end
151 ui.tabs{
152 {
153 name = "current_draft",
154 label = _"Current draft",
155 content = function()
156 execute.view{ module = "draft", view = "_show", params = { draft = initiative.current_draft } }
157 end
158 },
159 {
160 name = "suggestion",
161 label = _"Suggestions",
162 content = function()
163 execute.view{ module = "suggestion", view = "_list", params = { suggestions_selector = initiative:get_reference_selector("suggestions") } }
164 slot.put("<br />")
165 if not initiative.issue.frozen and not initiative.issue.closed then
166 ui.link{
167 content = function()
168 ui.image{ static = "icons/16/comment_add.png" }
169 slot.put(_"Add new suggestion")
170 end,
171 attr = { onclick = "document.getElementById('add_suggestion_form').style.display='block';return(false)" },
172 static = "#"
173 }
174 end
175 end
176 },
177 {
178 name = "supporter",
179 label = _"Supporter",
180 content = function()
181 execute.view{ module = "member", view = "_list", params = { members_selector = initiative:get_reference_selector("supporting_members") } }
182 end
183 },
184 {
185 name = "initiators",
186 label = _"Initiators",
187 content = function()
188 execute.view{ module = "member", view = "_list", params = { members_selector = initiative:get_reference_selector("initiating_members") } }
189 end
190 },
191 {
192 name = "drafts",
193 label = _"Old drafts",
194 content = function()
195 execute.view{ module = "draft", view = "_list", params = { drafts = initiative.drafts } }
196 end
197 },
198 {
199 name = "details",
200 label = _"Details",
201 content = function()
202 ui.form{
203 attr = { class = "vertical" },
204 record = initiative,
205 readonly = true,
206 content = function()
207 ui.field.text{ label = _"Issue policy", value = initiative.issue.policy.name }
208 ui.field.text{
209 label = _"Created at",
210 value = tostring(initiative.created)
211 }
212 ui.field.text{
213 label = _"Created at",
214 value = format.timestamp(initiative.created)
215 }
216 ui.field.date{ label = _"Revoked at", name = "revoked" }
217 ui.field.boolean{ label = _"Admitted", name = "admitted" }
218 end
219 }
220 end
221 },
222 }

Impressum / About Us