rev |
line source |
bsw@1045
|
1 local initiative = Initiative:by_id ( param.get_id() )
|
bsw@1045
|
2 local member = app.session.member
|
bsw@1045
|
3
|
bsw@1045
|
4 if not initiative then
|
bsw@1045
|
5 execute.view { module = "index", view = "404" }
|
bsw@1045
|
6 request.set_status("404 Not Found")
|
bsw@1045
|
7 return
|
bsw@1045
|
8 end
|
bsw@1045
|
9
|
bsw/jbe@1309
|
10 app.current_initiative = initiative
|
bsw/jbe@1309
|
11
|
bsw@1045
|
12 local issue_info
|
bsw@1045
|
13
|
bsw@1045
|
14 if member then
|
bsw@1045
|
15 initiative:load_everything_for_member_id(member.id)
|
bsw@1045
|
16 initiative.issue:load_everything_for_member_id(member.id)
|
bsw@1045
|
17 issue_info = initiative.issue.member_info
|
bsw@1045
|
18 end
|
bsw@1045
|
19
|
bsw@1145
|
20 local direct_supporter
|
bsw@1145
|
21
|
bsw@1045
|
22 if app.session.member_id then
|
bsw@1045
|
23 direct_supporter = initiative.issue.member_info.own_participation and initiative.member_info.supported
|
bsw@1045
|
24 end
|
bsw@718
|
25
|
bsw/jbe@1309
|
26 slot.put_into("header", initiative.display_name)
|
bsw@1045
|
27
|
bsw/jbe@1309
|
28 execute.view{ module = "issue", view = "_head", params = { issue = initiative.issue, link_issue = true } }
|
bsw@1045
|
29
|
bsw/jbe@1309
|
30 ui.grid{ content = function()
|
bsw@1045
|
31
|
bsw/jbe@1309
|
32 ui.cell_main{ content = function()
|
bsw/jbe@1309
|
33 ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function()
|
bsw/jbe@1309
|
34 execute.view{
|
bsw/jbe@1309
|
35 module = "initiative", view = "_head", params = {
|
bsw/jbe@1309
|
36 initiative = initiative
|
bsw@1045
|
37 }
|
bsw/jbe@1309
|
38 }
|
bsw@1045
|
39
|
bsw@1519
|
40 if initiative.location and initiative.location.marker_link then
|
bsw@1519
|
41 ui.container {
|
bsw@1519
|
42 attr = { class = "mdl-card__content mdl-card--no-bottom-pad" },
|
bsw@1519
|
43 content = function()
|
bsw@1519
|
44 ui.tag{ content = _"This initiative references a FirstLife object." }
|
bsw@1519
|
45 slot.put(" ")
|
bsw@1519
|
46 ui.link{ external = initiative.location.marker_link, content = _"Open in FirstLife" }
|
bsw@1519
|
47 end
|
bsw@1519
|
48 }
|
bsw@1519
|
49 end
|
bsw@1519
|
50
|
bsw/jbe@1309
|
51 if direct_supporter and not initiative.issue.closed then
|
bsw/jbe@1309
|
52 local supporter = app.session.member:get_reference_selector("supporters")
|
bsw/jbe@1309
|
53 :add_where{ "initiative_id = ?", initiative.id }
|
bsw/jbe@1309
|
54 :optional_object_mode()
|
bsw/jbe@1309
|
55 :exec()
|
bsw/jbe@1309
|
56
|
bsw/jbe@1309
|
57 if supporter then
|
bsw@1045
|
58
|
bsw/jbe@1309
|
59 local old_draft_id = supporter.draft_id
|
bsw/jbe@1309
|
60 local new_draft_id = initiative.current_draft.id
|
bsw/jbe@1309
|
61
|
bsw/jbe@1309
|
62 if old_draft_id ~= new_draft_id then
|
bsw/jbe@1309
|
63 ui.container {
|
bsw/jbe@1309
|
64 attr = { class = "mdl-card__content mdl-card--no-bottom-pad mdl-card--notice" },
|
bsw/jbe@1309
|
65 content = _"The draft of this initiative has been updated!"
|
bsw/jbe@1309
|
66 }
|
bsw/jbe@1309
|
67 ui.container {
|
bsw/jbe@1309
|
68 attr = { class = "mdl-card__actions mdl-card--action-border mdl-card--notice" },
|
bsw/jbe@1309
|
69 content = function ()
|
bsw/jbe@1309
|
70 if not initiative.revoked then
|
bsw/jbe@1309
|
71 ui.link{
|
bsw/jbe@1309
|
72 attr = { class = "mdl-button mdl-js-button mdl-button--raised" },
|
bsw/jbe@1309
|
73 text = _"refresh my support",
|
bsw/jbe@1309
|
74 module = "initiative",
|
bsw/jbe@1309
|
75 action = "add_support",
|
bsw/jbe@1309
|
76 id = initiative.id,
|
bsw/jbe@1309
|
77 params = { draft_id = initiative.current_draft.id },
|
bsw/jbe@1309
|
78 routing = {
|
bsw/jbe@1309
|
79 default = {
|
bsw/jbe@1309
|
80 mode = "redirect",
|
bsw/jbe@1309
|
81 module = "initiative",
|
bsw/jbe@1309
|
82 view = "show",
|
bsw/jbe@1309
|
83 id = initiative.id
|
bsw/jbe@1309
|
84 }
|
bsw/jbe@1309
|
85 }
|
bsw/jbe@1309
|
86 }
|
bsw/jbe@1309
|
87 slot.put(" ")
|
bsw/jbe@1309
|
88 ui.link{
|
bsw/jbe@1309
|
89 attr = { class = "mdl-button mdl-js-button mdl-button--raised" },
|
bsw/jbe@1309
|
90 content = _"show differences",
|
bsw/jbe@1309
|
91 module = "draft",
|
bsw/jbe@1309
|
92 view = "diff",
|
bsw/jbe@1309
|
93 params = {
|
bsw/jbe@1309
|
94 old_draft_id = old_draft_id,
|
bsw/jbe@1309
|
95 new_draft_id = new_draft_id
|
bsw/jbe@1309
|
96 }
|
bsw/jbe@1309
|
97 }
|
bsw/jbe@1309
|
98 slot.put(" ")
|
bsw@1045
|
99 end
|
bsw/jbe@1309
|
100 ui.link{
|
bsw/jbe@1309
|
101 attr = { class = "mdl-button mdl-js-button mdl-button--raised" },
|
bsw/jbe@1309
|
102 text = _"remove my support",
|
bsw/jbe@1309
|
103 module = "initiative",
|
bsw/jbe@1309
|
104 action = "remove_support",
|
bsw/jbe@1309
|
105 id = initiative.id,
|
bsw/jbe@1309
|
106 routing = {
|
bsw/jbe@1309
|
107 default = {
|
bsw/jbe@1309
|
108 mode = "redirect",
|
bsw/jbe@1309
|
109 module = "initiative",
|
bsw/jbe@1309
|
110 view = "show",
|
bsw/jbe@1309
|
111 id = initiative.id
|
bsw@1045
|
112 }
|
bsw@1045
|
113 }
|
bsw@1061
|
114 }
|
bsw@1061
|
115
|
bsw/jbe@1309
|
116 end
|
bsw/jbe@1309
|
117 }
|
bsw/jbe@1309
|
118 end
|
bsw/jbe@1309
|
119 end
|
bsw/jbe@1309
|
120 end
|
bsw/jbe@1309
|
121
|
bsw/jbe@1309
|
122 if config.render_external_reference and config.render_external_reference.initiative then
|
bsw/jbe@1309
|
123 config.render_external_reference.initiative(initiative, function (callback)
|
bsw/jbe@1309
|
124 ui.sectionRow(callback)
|
bsw/jbe@1309
|
125 end)
|
bsw/jbe@1309
|
126 end
|
bsw/jbe@1309
|
127 local draft_content = initiative.current_draft.content
|
bsw/jbe@1309
|
128 if config.initiative_abstract then
|
bsw/jbe@1309
|
129 local abstract = string.match(draft_content, "(.+)<!%--END_OF_ABSTRACT%-->")
|
bsw/jbe@1309
|
130 if abstract then
|
bsw/jbe@1309
|
131 draft_content = string.match(draft_content, "<!%--END_OF_ABSTRACT%-->(.*)")
|
bsw/jbe@1309
|
132 end
|
bsw/jbe@1309
|
133 end
|
bsw/jbe@1309
|
134 ui.container {
|
bsw/jbe@1309
|
135 attr = { class = "draft mdl-card__content mdl-card--border" },
|
bsw/jbe@1309
|
136 content = function ()
|
bsw/jbe@1309
|
137 if initiative.current_draft.formatting_engine == "html" or not initiative.current_draft.formatting_engine then
|
bsw/jbe@1309
|
138 if config.draft_filter then
|
bsw/jbe@1309
|
139 slot.put(config.draft_filter(draft_content))
|
bsw/jbe@1309
|
140 else
|
bsw/jbe@1309
|
141 slot.put(draft_content)
|
bsw@1045
|
142 end
|
bsw/jbe@1309
|
143 else
|
bsw/jbe@1309
|
144 slot.put ( initiative.current_draft:get_content ( "html" ) )
|
bsw/jbe@1309
|
145 end
|
bsw/jbe@1309
|
146 end
|
bsw/jbe@1309
|
147 }
|
bsw@1045
|
148
|
bsw@1495
|
149 if config.attachments then
|
bsw@1495
|
150
|
bsw@1495
|
151 local files = File:new_selector()
|
bsw@1495
|
152 :left_join("draft_attachment", nil, "draft_attachment.file_id = file.id")
|
bsw@1495
|
153 :add_where{ "draft_attachment.draft_id = ?", initiative.current_draft.id }
|
bsw@1495
|
154 :reset_fields()
|
bsw@1495
|
155 :add_field("file.id")
|
bsw@1495
|
156 :add_field("draft_attachment.title")
|
bsw@1495
|
157 :add_field("draft_attachment.description")
|
bsw@1495
|
158 :add_order_by("draft_attachment.id")
|
bsw@1495
|
159 :exec()
|
bsw@1495
|
160
|
bsw@1495
|
161 if #files > 0 then
|
bsw@1495
|
162 ui.container {
|
bsw@1495
|
163 attr = { class = "mdl-card__content mdl-card--border" },
|
bsw@1495
|
164 content = function()
|
bsw@1495
|
165 for i, file in ipairs(files) do
|
bsw@1495
|
166 ui.link{ module = "file", view = "show.jpg", id = file.id, content = function()
|
bsw@1495
|
167 ui.image{ module = "file", view = "show.jpg", id = file.id, params = { preview = true } }
|
bsw@1495
|
168 end }
|
bsw@1496
|
169 ui.container{ content = function()
|
bsw@1496
|
170 ui.tag{ tag = "strong", content = file.title or "" }
|
bsw@1496
|
171 end }
|
bsw@1495
|
172 ui.container{ content = file.description or "" }
|
bsw@1495
|
173 slot.put("<br /><br />")
|
bsw@1495
|
174 end
|
bsw@1495
|
175 end
|
bsw@1495
|
176 }
|
bsw@1495
|
177 end
|
bsw@1495
|
178 end
|
bsw@1495
|
179
|
bsw/jbe@1309
|
180 local drafts_count = initiative:get_reference_selector("drafts"):count()
|
bsw@1045
|
181
|
bsw/jbe@1309
|
182 if not config.voting_only then
|
bsw/jbe@1309
|
183 ui.container {
|
bsw/jbe@1309
|
184 attr = { class = "mdl-card__actions" },
|
bsw/jbe@1309
|
185 content = function()
|
bsw/jbe@1309
|
186 ui.link{
|
bsw/jbe@1309
|
187 attr = { class = "mdl-button mdl-js-button" },
|
bsw/jbe@1309
|
188 module = "initiative", view = "history", id = initiative.id,
|
bsw/jbe@1309
|
189 content = _("draft history (#{count})", { count = drafts_count })
|
bsw/jbe@1309
|
190 }
|
bsw/jbe@1309
|
191 end
|
bsw/jbe@1309
|
192 }
|
bsw@1045
|
193 end
|
bsw/jbe@1309
|
194
|
bsw/jbe@1309
|
195 end }
|
bsw/jbe@1309
|
196
|
bsw/jbe@1309
|
197 execute.view{ module = "initiative", view = "_suggestions", params = { initiative = initiative } }
|
bsw@1045
|
198
|
bsw/jbe@1309
|
199 end }
|
bsw/jbe@1309
|
200
|
bsw/jbe@1309
|
201 ui.cell_sidebar{ content = function()
|
bsw/jbe@1309
|
202 if config.logo then
|
bsw/jbe@1309
|
203 config.logo()
|
bsw/jbe@1309
|
204 end
|
bsw@1620
|
205
|
bsw/jbe@1309
|
206 execute.view {
|
bsw/jbe@1309
|
207 module = "issue", view = "_sidebar",
|
bsw/jbe@1309
|
208 params = {
|
bsw/jbe@1309
|
209 issue = initiative.issue,
|
bsw/jbe@1309
|
210 initiative = initiative,
|
bsw/jbe@1309
|
211 member = app.session.member
|
bsw/jbe@1309
|
212 }
|
bsw/jbe@1309
|
213 }
|
bsw/jbe@1309
|
214
|
bsw/jbe@1309
|
215 execute.view {
|
bsw/jbe@1309
|
216 module = "issue", view = "_sidebar_whatcanido",
|
bsw/jbe@1309
|
217 params = {
|
bsw/jbe@1309
|
218 issue = initiative.issue,
|
bsw/jbe@1309
|
219 initiative = initiative,
|
bsw/jbe@1309
|
220 member = app.session.member
|
bsw/jbe@1309
|
221 }
|
bsw/jbe@1309
|
222 }
|
bsw/jbe@1309
|
223
|
bsw/jbe@1309
|
224 execute.view {
|
bsw/jbe@1309
|
225 module = "issue", view = "_sidebar_members", params = {
|
bsw/jbe@1309
|
226 issue = initiative.issue, initiative = initiative
|
bsw/jbe@1309
|
227 }
|
bsw/jbe@1309
|
228 }
|
bsw/jbe@1309
|
229
|
bsw/jbe@1309
|
230 end }
|
bsw/jbe@1309
|
231
|
bsw/jbe@1309
|
232 end }
|