rev |
line source |
bsw@1496
|
1 local issue
|
bsw@1496
|
2 local area
|
bsw@1496
|
3 local area_id
|
bsw/jbe@0
|
4
|
bsw@1496
|
5 local issue_id = param.get("issue_id", atom.integer)
|
bsw@1496
|
6 if issue_id then
|
bsw@1496
|
7 issue = Issue:new_selector():add_where{"id=?",issue_id}:single_object_mode():exec()
|
bsw@1496
|
8 issue:load_everything_for_member_id(app.session.member_id)
|
bsw@1496
|
9 area = issue.area
|
bsw@1496
|
10 else
|
bsw@1496
|
11 area_id = param.get("area_id", atom.integer)
|
bsw@1496
|
12 if area_id then
|
bsw@1496
|
13 area = Area:new_selector():add_where{"id=?",area_id}:single_object_mode():exec()
|
bsw@1496
|
14 area:load_delegation_info_once_for_member_id(app.session.member_id)
|
bsw@1534
|
15 else
|
bsw@1534
|
16 local firstlife_id = param.get("firstlife_id")
|
bsw@1534
|
17 if firstlife_id then
|
bsw@1534
|
18 area = Area:new_selector():join("unit", nil, "unit.id = area.unit_id"):add_where{"attr->>'firstlife_id'=?",firstlife_id}:single_object_mode():exec()
|
bsw@1534
|
19 area:load_delegation_info_once_for_member_id(app.session.member_id)
|
bsw@1534
|
20 area_id = area.id
|
bsw@1534
|
21 end
|
bsw@1496
|
22 end
|
bsw@1496
|
23 end
|
bsw@1496
|
24
|
bsw@1824
|
25 if #(area.allowed_policies) < 1 then
|
bsw@1824
|
26 slot.put_into("error", _"Subject area configuration invalid. Please contact the administrator.")
|
bsw@1824
|
27 return false
|
bsw@1824
|
28 end
|
bsw@1824
|
29
|
bsw@1496
|
30 local polling = param.get("polling", atom.boolean)
|
bsw@1496
|
31
|
bsw@1496
|
32 local policy_id = param.get("policy_id", atom.integer)
|
bsw@1496
|
33 local policy
|
bsw@1496
|
34
|
bsw@1496
|
35 local preview = param.get("preview")
|
bsw@1496
|
36
|
bsw@1496
|
37 if #(slot.get_content("error")) > 0 then
|
bsw@1496
|
38 preview = false
|
bsw@1496
|
39 end
|
bsw@1496
|
40
|
bsw@1496
|
41 if policy_id then
|
bsw@1496
|
42 policy = Policy:by_id(policy_id)
|
bsw@1135
|
43 end
|
bsw@1135
|
44
|
bsw@1535
|
45 local callback = param.get("callback")
|
bsw@1496
|
46
|
bsw@1496
|
47
|
bsw@1496
|
48 local initiative_id = param.get("initiative_id")
|
bsw@1496
|
49 local initiative = Initiative:by_id(initiative_id)
|
bsw@1496
|
50 local draft
|
bsw@1496
|
51 if initiative then
|
bsw@1496
|
52 initiative:load_everything_for_member_id(app.session.member_id)
|
bsw@1496
|
53 initiative.issue:load_everything_for_member_id(app.session.member_id)
|
bsw@1496
|
54
|
bsw@1496
|
55 if initiative.issue.closed then
|
bsw@1496
|
56 slot.put_into("error", _"This issue is already closed.")
|
bsw@1496
|
57 return
|
bsw@1496
|
58 elseif initiative.issue.half_frozen then
|
bsw@1496
|
59 slot.put_into("error", _"This issue is already frozen.")
|
bsw@1496
|
60 return
|
bsw@1496
|
61 elseif initiative.issue.phase_finished then
|
bsw@1496
|
62 slot.put_into("error", _"Current phase is already closed.")
|
bsw@1496
|
63 return
|
bsw/jbe@1309
|
64 end
|
bsw@1496
|
65
|
bsw@1496
|
66 draft = initiative.current_draft
|
bsw@1496
|
67 if config.initiative_abstract then
|
bsw@1496
|
68 draft.abstract = string.match(draft.content, "(.+)<!%--END_OF_ABSTRACT%-->")
|
bsw@1496
|
69 if draft.abstract then
|
bsw@1496
|
70 draft.content = string.match(draft.content, "<!%--END_OF_ABSTRACT%-->(.*)")
|
bsw@1496
|
71 end
|
bsw@1496
|
72 end
|
bsw@1496
|
73 end
|
bsw@1496
|
74
|
bsw@1496
|
75 if not initiative and not issue and not area then
|
bsw@1496
|
76 ui.heading{ content = _"Missing parameter" }
|
bsw@1496
|
77 return false
|
bsw/jbe@1309
|
78 end
|
bsw@95
|
79
|
bsw/jbe@0
|
80 ui.form{
|
bsw/jbe@1309
|
81 record = draft,
|
bsw@1495
|
82 attr = { class = "vertical section", enctype = 'multipart/form-data' },
|
bsw/jbe@0
|
83 module = "draft",
|
bsw/jbe@0
|
84 action = "add",
|
bsw@1496
|
85 params = {
|
bsw@1496
|
86 area_id = area and area.id,
|
bsw@1496
|
87 issue_id = issue and issue.id or nil,
|
bsw@1535
|
88 initiative_id = initiative_id,
|
bsw@1535
|
89 callback = callback
|
bsw@1496
|
90 },
|
bsw/jbe@0
|
91 routing = {
|
bsw@95
|
92 ok = {
|
bsw/jbe@0
|
93 mode = "redirect",
|
bsw/jbe@0
|
94 module = "initiative",
|
bsw/jbe@0
|
95 view = "show",
|
bsw@1496
|
96 id = initiative_id
|
bsw/jbe@0
|
97 }
|
bsw/jbe@0
|
98 },
|
bsw/jbe@0
|
99 content = function()
|
bsw@1045
|
100
|
bsw@1560
|
101 if issue or initiative then
|
bsw@1560
|
102 execute.view {
|
bsw@1560
|
103 module = "issue", view = "_head", params = {
|
bsw@1560
|
104 issue = issue or initiative.issue,
|
bsw@1560
|
105 member = app.session.member
|
bsw@1560
|
106 }
|
bsw@1560
|
107 }
|
bsw@1560
|
108 else
|
bsw@1560
|
109 execute.view {
|
bsw@1560
|
110 module = "area", view = "_head", params = {
|
bsw@1560
|
111 area = area,
|
bsw@1560
|
112 member = app.session.member
|
bsw@1560
|
113 }
|
bsw@1560
|
114 }
|
bsw@1560
|
115 end
|
bsw@1560
|
116
|
bsw/jbe@1309
|
117 ui.grid{ content = function()
|
bsw/jbe@1309
|
118 ui.cell_main{ content = function()
|
bsw/jbe@1309
|
119 ui.container{ attr = { class = "mdl-card mdl-shadow--2dp mdl-card__fullwidth" }, content = function()
|
bsw/jbe@1309
|
120 ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
|
bsw@1496
|
121 if initiative then
|
bsw@1496
|
122 ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = initiative.display_name }
|
bsw@1496
|
123 elseif param.get("name") then
|
bsw@1496
|
124 ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = param.get("name") }
|
bsw@1496
|
125 elseif issue then
|
bsw@1496
|
126 ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = _("New competing initiative in issue '#{issue}'", { issue = issue.name }) }
|
bsw@1496
|
127 elseif area then
|
bsw@1560
|
128 ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = _"New issue" }
|
bsw@1496
|
129 end
|
bsw/jbe@1309
|
130 end }
|
bsw/jbe@1309
|
131 ui.container{ attr = { class = "mdl-card__content mdl-card--border" }, content = function()
|
bsw@1496
|
132
|
bsw@1496
|
133 -- -------- PREVIEW
|
bsw@1662
|
134 if param.get("preview") and slot.get_content("error") == "" then
|
bsw/jbe@1309
|
135 ui.sectionRow( function()
|
bsw@1720
|
136 if not issue and not initiative and #area.allowed_policies > 1 then
|
bsw@1662
|
137 ui.container { content = policy and policy.name or "" }
|
bsw@1721
|
138 slot.put("<br />")
|
bsw@1496
|
139 end
|
bsw@1496
|
140 if param.get("free_timing") then
|
bsw@1496
|
141 ui.container { content = param.get("free_timing") }
|
bsw@1721
|
142 slot.put("<br />")
|
bsw@1496
|
143 end
|
bsw@1496
|
144 ui.field.hidden{ name = "policy_id", value = param.get("policy_id") }
|
bsw@1496
|
145 ui.field.hidden{ name = "name", value = param.get("name") }
|
bsw/jbe@1309
|
146 if config.initiative_abstract then
|
bsw/jbe@1309
|
147 ui.field.hidden{ name = "abstract", value = param.get("abstract") }
|
bsw/jbe@1309
|
148 ui.container{
|
bsw/jbe@1309
|
149 attr = { class = "abstract" },
|
bsw/jbe@1309
|
150 content = param.get("abstract")
|
bsw/jbe@1309
|
151 }
|
bsw/jbe@1309
|
152 slot.put("<br />")
|
bsw/jbe@1309
|
153 end
|
bsw/jbe@1309
|
154 local draft_text = param.get("content")
|
bsw/jbe@1309
|
155 local draft_text = util.wysihtml_preproc(draft_text)
|
bsw/jbe@1309
|
156 ui.field.hidden{ name = "content", value = draft_text }
|
bsw/jbe@1309
|
157 ui.container{
|
bsw/jbe@1309
|
158 attr = { class = "draft" },
|
bsw/jbe@1309
|
159 content = function()
|
bsw/jbe@1309
|
160 slot.put(draft_text)
|
bsw/jbe@1309
|
161 end
|
bsw/jbe@1309
|
162 }
|
bsw/jbe@1309
|
163 slot.put("<br />")
|
bsw@95
|
164
|
bsw@1495
|
165 if config.attachments then
|
bsw@1495
|
166 local file_upload_session = param.get("file_upload_session") or multirand.string(
|
bsw@1495
|
167 32,
|
bsw@1495
|
168 '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
|
bsw@1495
|
169 )
|
bsw@1495
|
170 file_upload_session = string.gsub(file_upload_session, "[^A-Za-z0-9]", "")
|
bsw@1495
|
171 ui.field.hidden{ name = "file_upload_session", value = file_upload_session }
|
bsw@1496
|
172 if initiative then
|
bsw@1496
|
173 local files = File:new_selector()
|
bsw@1496
|
174 :left_join("draft_attachment", nil, "draft_attachment.file_id = file.id")
|
bsw@1496
|
175 :add_where{ "draft_attachment.draft_id = ?", initiative.current_draft.id }
|
bsw@1496
|
176 :reset_fields()
|
bsw@1496
|
177 :add_field("file.id")
|
bsw@1496
|
178 :add_field("draft_attachment.title")
|
bsw@1496
|
179 :add_field("draft_attachment.description")
|
bsw@1496
|
180 :add_order_by("draft_attachment.id")
|
bsw@1496
|
181 :exec()
|
bsw@1495
|
182
|
bsw@1496
|
183 if #files > 0 then
|
bsw@1496
|
184 ui.container {
|
bsw@1496
|
185 content = function()
|
bsw@1496
|
186 for i, file in ipairs(files) do
|
bsw@1496
|
187 if param.get("file_delete_" .. file.id, atom.boolean) then
|
bsw@1496
|
188 ui.field.hidden{ name = "file_delete_" .. file.id, value = "1" }
|
bsw@1496
|
189 else
|
bsw@1496
|
190 ui.image{ module = "file", view = "show.jpg", id = file.id, params = { preview = true } }
|
bsw@1496
|
191 ui.container{ content = function()
|
bsw@1496
|
192 ui.tag{ tag = "strong", content = file.title or "" }
|
bsw@1496
|
193 end }
|
bsw@1496
|
194 ui.container{ content = file.description or "" }
|
bsw@1496
|
195 slot.put("<br /><br />")
|
bsw@1496
|
196 end
|
bsw@1495
|
197 end
|
bsw@1495
|
198 end
|
bsw@1496
|
199 }
|
bsw@1496
|
200 end
|
bsw@1495
|
201 end
|
bsw@1495
|
202 local filename = encode.file_path(WEBMCP_BASE_PATH, 'tmp', "file_upload-" .. file_upload_session .. ".json")
|
bsw@1495
|
203 local fh = io.open(filename, "r")
|
bsw@1495
|
204 if fh then
|
bsw@1495
|
205 local file_uploads = json.import(fh:read("*a"))
|
bsw@1495
|
206 for i, file_upload in ipairs(file_uploads) do
|
bsw@1495
|
207 ui.image{ module = "draft", view = "show_file_upload", params = {
|
bsw@1495
|
208 file_upload_session = file_upload_session, file_id = file_upload.id, preview = true
|
bsw@1495
|
209 } }
|
bsw@1496
|
210 ui.container{ content = function()
|
bsw@1496
|
211 ui.tag{ tag = "strong", content = file_upload.title or "" }
|
bsw@1496
|
212 end }
|
bsw@1495
|
213 ui.container{ content = file_upload.description or "" }
|
bsw@1495
|
214 slot.put("<br />")
|
bsw@1495
|
215 end
|
bsw@1495
|
216 end
|
bsw@1495
|
217 end
|
bsw@1495
|
218
|
bsw/jbe@1309
|
219 ui.tag{
|
bsw/jbe@1309
|
220 tag = "input",
|
bsw/jbe@1309
|
221 attr = {
|
bsw/jbe@1309
|
222 type = "submit",
|
bsw/jbe@1309
|
223 class = "mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--colored",
|
bsw/jbe@1309
|
224 value = _'Publish now'
|
bsw/jbe@1309
|
225 },
|
bsw/jbe@1309
|
226 content = ""
|
bsw/jbe@1309
|
227 }
|
bsw/jbe@1309
|
228 slot.put(" ")
|
bsw/jbe@1309
|
229
|
bsw/jbe@1309
|
230 ui.tag{
|
bsw/jbe@1309
|
231 tag = "input",
|
bsw/jbe@1309
|
232 attr = {
|
bsw/jbe@1309
|
233 type = "submit",
|
bsw/jbe@1309
|
234 name = "edit",
|
bsw/jbe@1309
|
235 class = "mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect",
|
bsw/jbe@1309
|
236 value = _'Edit again'
|
bsw/jbe@1309
|
237 },
|
bsw/jbe@1309
|
238 content = ""
|
bsw/jbe@1309
|
239 }
|
bsw/jbe@1309
|
240 slot.put(" ")
|
bsw@95
|
241
|
bsw/jbe@1309
|
242 ui.link{
|
bsw/jbe@1309
|
243 attr = { class = "mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect" },
|
bsw/jbe@1309
|
244 content = _"Cancel",
|
bsw@1663
|
245 module = initiative and "initiative" or "index",
|
bsw@1663
|
246 view = initiative and "show" or "index",
|
bsw@1663
|
247 id = initiative_id,
|
bsw@1663
|
248 params = { unit = area and area.unit_id or nil, area = area_id }
|
bsw/jbe@1309
|
249 }
|
bsw/jbe@1309
|
250 end )
|
bsw@1045
|
251
|
bsw@1496
|
252 -- -------- EDIT
|
bsw/jbe@1309
|
253 else
|
bsw@1496
|
254
|
bsw@1496
|
255 if not issue_id and not initiative_id then
|
bsw@1496
|
256 local tmp = { { id = -1, name = "" } }
|
bsw@1496
|
257 for i, allowed_policy in ipairs(area.allowed_policies) do
|
bsw@1496
|
258 if not allowed_policy.polling or app.session.member:has_polling_right_for_unit_id(area.unit_id) then
|
bsw@1496
|
259 tmp[#tmp+1] = allowed_policy
|
bsw@1496
|
260 end
|
bsw@1496
|
261 end
|
bsw@1719
|
262 if #area.allowed_policies > 1 then
|
bsw@1719
|
263 ui.container{ content = _"Please choose a policy for the new issue:" }
|
bsw@1719
|
264 ui.field.select{
|
bsw@1719
|
265 name = "policy_id",
|
bsw@1719
|
266 foreign_records = tmp,
|
bsw@1719
|
267 foreign_id = "id",
|
bsw@1719
|
268 foreign_name = "name",
|
bsw@1719
|
269 value = param.get("policy_id", atom.integer) or area.default_policy and area.default_policy.id
|
bsw@1719
|
270 }
|
bsw@1719
|
271 else
|
bsw@1719
|
272 ui.field.hidden{
|
bsw@1719
|
273 name = "policy_id",
|
bsw@1719
|
274 value = area.allowed_policies[1].id
|
bsw@1719
|
275 }
|
bsw@1719
|
276 end
|
bsw@1496
|
277 if policy and policy.free_timeable then
|
bsw@1496
|
278 local available_timings
|
bsw@1496
|
279 if config.free_timing and config.free_timing.available_func then
|
bsw@1496
|
280 available_timings = config.free_timing.available_func(policy)
|
bsw@1496
|
281 if available_timings == false then
|
bsw@1496
|
282 slot.put_into("error", "error in free timing config")
|
bsw@1496
|
283 return false
|
bsw@1496
|
284 end
|
bsw@1496
|
285 end
|
bsw@1496
|
286 ui.heading{ level = 4, content = _"Free timing:" }
|
bsw@1496
|
287 if available_timings then
|
bsw@1496
|
288 ui.field.select{
|
bsw@1496
|
289 name = "free_timing",
|
bsw@1496
|
290 foreign_records = available_timings,
|
bsw@1496
|
291 foreign_id = "id",
|
bsw@1496
|
292 foreign_name = "name",
|
bsw@1496
|
293 value = param.get("free_timing")
|
bsw@1496
|
294 }
|
bsw@1496
|
295 else
|
bsw/jbe@1309
|
296 ui.field.text{
|
bsw@1496
|
297 name = "free_timing",
|
bsw@1496
|
298 value = param.get("free_timing")
|
bsw/jbe@1309
|
299 }
|
bsw@1496
|
300 end
|
bsw/jbe@1309
|
301 end
|
bsw@1496
|
302 end
|
bsw@1496
|
303
|
bsw@1496
|
304 if issue and issue.policy.polling and app.session.member:has_polling_right_for_unit_id(area.unit_id) then
|
bsw@1496
|
305 slot.put("<br />")
|
bsw@1496
|
306 ui.field.boolean{ name = "polling", label = _"No admission needed", value = polling }
|
bsw@1496
|
307 end
|
bsw@1496
|
308
|
bsw@1496
|
309 if not initiative then
|
bsw@1496
|
310 ui.container{ attr = { class = "mdl-textfield mdl-js-textfield mdl-textfield--floating-label mdl-card__fullwidth" }, content = function ()
|
bsw@1496
|
311 ui.field.text{
|
bsw@1496
|
312 attr = { id = "lf-initiative__name", class = "mdl-textfield__input" },
|
bsw@1496
|
313 label_attr = { class = "mdl-textfield__label", ["for"] = "lf-initiative__name" },
|
bsw@1496
|
314 label = _"Title",
|
bsw@1496
|
315 name = "name",
|
bsw@1496
|
316 value = param.get("name")
|
bsw@1496
|
317 }
|
bsw@1496
|
318 end }
|
bsw@1496
|
319 end
|
bsw@1495
|
320
|
bsw@1496
|
321 if config.initiative_abstract then
|
bsw@1496
|
322 ui.container { content = _"Enter abstract:" }
|
bsw@1496
|
323 ui.container{ attr = { class = "mdl-textfield mdl-js-textfield mdl-textfield--expandable mdl-textfield__fullwidth" }, content = function()
|
bsw@1496
|
324 ui.field.text{
|
bsw@1496
|
325 name = "abstract",
|
bsw@1496
|
326 multiline = true,
|
bsw@1496
|
327 attr = { id = "abstract", style = "height: 20ex; width: 100%;" },
|
bsw@1496
|
328 value = param.get("abstract")
|
bsw@1496
|
329 }
|
bsw@1496
|
330 end }
|
bsw@1496
|
331 end
|
bsw@1496
|
332
|
bsw@1496
|
333 ui.container { content = _"Enter your proposal and/or reasons:" }
|
bsw@1496
|
334 ui.field.wysihtml{
|
bsw@1496
|
335 name = "content",
|
bsw@1496
|
336 multiline = true,
|
bsw@1496
|
337 attr = { id = "draft", style = "height: 50ex; width: 100%;" },
|
bsw@1496
|
338 value = param.get("content")
|
bsw@1496
|
339 }
|
bsw@1496
|
340 if not issue or issue.state == "admission" or issue.state == "discussion" then
|
bsw@1496
|
341 ui.container { content = _"You can change your text again anytime during admission and discussion phase" }
|
bsw@1496
|
342 else
|
bsw@1496
|
343 ui.container { content = _"You cannot change your text again later, because this issue is already in verfication phase!" }
|
bsw@1496
|
344 end
|
bsw@1496
|
345
|
bsw@1496
|
346 slot.put("<br />")
|
bsw@1496
|
347 if config.attachments then
|
bsw@1496
|
348 local file_upload_session = param.get("file_upload_session") or multirand.string(
|
bsw@1496
|
349 32,
|
bsw@1496
|
350 '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
|
bsw@1496
|
351 )
|
bsw@1496
|
352 file_upload_session = string.gsub(file_upload_session, "[^A-Za-z0-9]", "")
|
bsw@1496
|
353 ui.field.hidden{ name = "file_upload_session", value = file_upload_session }
|
bsw@1496
|
354 if initiative then
|
bsw@1495
|
355 local files = File:new_selector()
|
bsw@1495
|
356 :left_join("draft_attachment", nil, "draft_attachment.file_id = file.id")
|
bsw@1495
|
357 :add_where{ "draft_attachment.draft_id = ?", initiative.current_draft.id }
|
bsw@1495
|
358 :reset_fields()
|
bsw@1495
|
359 :add_field("file.id")
|
bsw@1495
|
360 :add_field("draft_attachment.title")
|
bsw@1495
|
361 :add_field("draft_attachment.description")
|
bsw@1495
|
362 :add_order_by("draft_attachment.id")
|
bsw@1495
|
363 :exec()
|
bsw@1495
|
364
|
bsw@1495
|
365 if #files > 0 then
|
bsw@1495
|
366 ui.container {
|
bsw@1495
|
367 content = function()
|
bsw@1495
|
368 for i, file in ipairs(files) do
|
bsw@1495
|
369 ui.image{ module = "file", view = "show.jpg", id = file.id, params = { preview = true } }
|
bsw@1496
|
370 ui.container{ content = function()
|
bsw@1496
|
371 ui.tag{ tag = "strong", content = file.title or "" }
|
bsw@1496
|
372 end }
|
bsw@1495
|
373 ui.container{ content = file.description or "" }
|
bsw@1495
|
374 ui.field.boolean{ label = _"delete", name = "file_delete_" .. file.id, value = param.get("file_delete_" .. file.id) and true or false }
|
bsw@1495
|
375 slot.put("<br /><br />")
|
bsw@1495
|
376 end
|
bsw@1495
|
377 end
|
bsw@1495
|
378 }
|
bsw@1495
|
379 end
|
bsw@1496
|
380 end
|
bsw@1496
|
381 local filename = encode.file_path(WEBMCP_BASE_PATH, 'tmp', "file_upload-" .. file_upload_session .. ".json")
|
bsw@1496
|
382 local fh = io.open(filename, "r")
|
bsw@1496
|
383 if fh then
|
bsw@1496
|
384 local file_uploads = json.import(fh:read("*a"))
|
bsw@1496
|
385 for i, file_upload in ipairs(file_uploads) do
|
bsw@1496
|
386 ui.image{ module = "draft", view = "show_file_upload", params = {
|
bsw@1496
|
387 file_upload_session = file_upload_session, file_id = file_upload.id, preview = true
|
bsw@1496
|
388 } }
|
bsw@1496
|
389 ui.container{ content = function()
|
bsw@1496
|
390 ui.tag{ tag = "strong", content = file_upload.title or "" }
|
bsw@1496
|
391 end }
|
bsw@1496
|
392 ui.container{ content = file_upload.description or "" }
|
bsw@1496
|
393 ui.field.boolean{ label = _"delete", name = "file_upload_delete_" .. file_upload.id }
|
bsw@1496
|
394 slot.put("<br />")
|
bsw@1495
|
395 end
|
bsw@1496
|
396 end
|
bsw@1496
|
397 ui.container{ attr = { id = "file_upload_template", style = "display: none;" }, content = function()
|
bsw@1496
|
398 ui.field.text{ label = _"Title", name = "__ID_title__" }
|
bsw@1496
|
399 ui.field.text{ label = _"Description", name = "__ID_description__" }
|
bsw@1496
|
400 ui.field.image{ field_name = "__ID_file__" }
|
bsw@1496
|
401 end }
|
bsw@1496
|
402 ui.container{ attr = { id = "file_upload" }, content = function()
|
bsw@1496
|
403 end }
|
bsw@1496
|
404 ui.field.hidden{ attr = { id = "file_upload_last_id" }, name = "file_upload_last_id" }
|
bsw@1496
|
405 ui.script{ script = [[ var file_upload_id = 1; ]] }
|
bsw@1496
|
406 ui.tag{ tag = "a", content = _"Attach image", attr = {
|
bsw@1496
|
407 href = "#",
|
bsw@1496
|
408 onclick = "var html = document.getElementById('file_upload_template').innerHTML; html = html.replace('__ID_file__', 'file_' + file_upload_id); html = html.replace('__ID_title__', 'title_' + file_upload_id); html = html.replace('__ID_description__', 'description_' + file_upload_id); var el = document.createElement('div'); el.innerHTML = html; document.getElementById('file_upload').appendChild(el); document.getElementById('file_upload_last_id').value = file_upload_id; file_upload_id++; return false;"
|
bsw@1496
|
409 } }
|
bsw@1496
|
410 slot.put("<br />")
|
bsw@1496
|
411
|
bsw@1496
|
412 slot.put("<br />")
|
bsw@1495
|
413
|
bsw@1496
|
414 end
|
bsw@1045
|
415
|
bsw@1496
|
416 ui.tag{
|
bsw@1496
|
417 tag = "input",
|
bsw@1496
|
418 attr = {
|
bsw@1496
|
419 type = "submit",
|
bsw@1496
|
420 name = "preview",
|
bsw@1496
|
421 class = "mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--colored",
|
bsw@1496
|
422 value = _'Preview'
|
bsw@1496
|
423 },
|
bsw@1496
|
424 content = ""
|
bsw@1496
|
425 }
|
bsw@1496
|
426 slot.put(" ")
|
bsw@1496
|
427
|
bsw@1496
|
428 ui.link{
|
bsw@1496
|
429 content = _"Cancel",
|
bsw@1496
|
430 module = initiative and "initiative" or issue and "issue" or "index",
|
bsw@1497
|
431 view = area and not issue and "index" or "show",
|
bsw@1496
|
432 id = initiative_id or issue_id,
|
bsw@1496
|
433 params = { area = area_id, unit = area and area.unit_id or nil },
|
bsw@1496
|
434 attr = { class = "mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect" }
|
bsw@1496
|
435 }
|
bsw@1496
|
436
|
bsw/jbe@1309
|
437 end
|
bsw/jbe@1309
|
438 end }
|
bsw/jbe@1309
|
439 end }
|
bsw/jbe@1309
|
440 end }
|
bsw@1520
|
441
|
bsw@1520
|
442 if config.map or config.firstlife then
|
bsw@1520
|
443 ui.cell_sidebar{ content = function()
|
bsw@1520
|
444 ui.container{ attr = { class = "mdl-special-card map mdl-shadow--2dp" }, content = function()
|
bsw@1575
|
445 local location = param.get("location")
|
bsw@1578
|
446 local lat = param.get("lat", atom.number)
|
bsw@1578
|
447 local lon = param.get("lon", atom.number)
|
bsw@1575
|
448 if lat and lon then
|
bsw@1577
|
449 location = json.export(json.object{
|
bsw@1575
|
450 type = "Point",
|
bsw@1576
|
451 coordinates = json.array{ lon, lat }
|
bsw@1575
|
452 })
|
bsw@1575
|
453 end
|
bsw@1575
|
454 ui.field.location{ name = "location", value = location }
|
bsw@1520
|
455 end }
|
bsw@1520
|
456 end }
|
bsw@1520
|
457 end
|
bsw@1520
|
458
|
bsw@1550
|
459 if config.firstlife then
|
bsw@1550
|
460 ui.field.hidden{ name = "external_reference", value = param.get("external_reference") }
|
bsw@1550
|
461 end
|
bsw@1550
|
462
|
bsw/jbe@1309
|
463 end }
|
bsw/jbe@0
|
464 end
|
bsw/jbe@0
|
465 }
|