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