rev |
line source |
bsw@1045
|
1 local initiative = Initiative:by_id(param.get("initiative_id"))
|
bsw@1045
|
2 initiative:load_everything_for_member_id(app.session.member_id)
|
bsw@1045
|
3 initiative.issue:load_everything_for_member_id(app.session.member_id)
|
bsw/jbe@0
|
4
|
bsw@1136
|
5 if initiative.issue.closed then
|
bsw@1135
|
6 slot.put_into("error", _"This issue is already closed.")
|
bsw@1135
|
7 return
|
bsw@1136
|
8 elseif initiative.issue.half_frozen then
|
bsw@1135
|
9 slot.put_into("error", _"This issue is already frozen.")
|
bsw@1135
|
10 return
|
bsw@1136
|
11 elseif initiative.issue.phase_finished then
|
bsw@1135
|
12 slot.put_into("error", _"Current phase is already closed.")
|
bsw@1135
|
13 return
|
bsw@1135
|
14 end
|
bsw@1135
|
15
|
bsw/jbe@1309
|
16 local draft = initiative.current_draft
|
bsw/jbe@1309
|
17 if config.initiative_abstract then
|
bsw/jbe@1309
|
18 draft.abstract = string.match(draft.content, "(.+)<!%--END_OF_ABSTRACT%-->")
|
bsw/jbe@1309
|
19 if draft.abstract then
|
bsw/jbe@1309
|
20 draft.content = string.match(draft.content, "<!%--END_OF_ABSTRACT%-->(.*)")
|
bsw/jbe@1309
|
21 end
|
bsw/jbe@1309
|
22 end
|
bsw@95
|
23
|
bsw/jbe@0
|
24 ui.form{
|
bsw/jbe@1309
|
25 record = draft,
|
bsw@1495
|
26 attr = { class = "vertical section", enctype = 'multipart/form-data' },
|
bsw/jbe@0
|
27 module = "draft",
|
bsw/jbe@0
|
28 action = "add",
|
bsw@2
|
29 params = { initiative_id = initiative.id },
|
bsw/jbe@0
|
30 routing = {
|
bsw@95
|
31 ok = {
|
bsw/jbe@0
|
32 mode = "redirect",
|
bsw/jbe@0
|
33 module = "initiative",
|
bsw/jbe@0
|
34 view = "show",
|
bsw@2
|
35 id = initiative.id
|
bsw/jbe@0
|
36 }
|
bsw/jbe@0
|
37 },
|
bsw/jbe@0
|
38 content = function()
|
bsw@1045
|
39
|
bsw/jbe@1309
|
40 ui.grid{ content = function()
|
bsw/jbe@1309
|
41 ui.cell_main{ content = function()
|
bsw/jbe@1309
|
42 ui.container{ attr = { class = "mdl-card mdl-shadow--2dp mdl-card__fullwidth" }, content = function()
|
bsw/jbe@1309
|
43 ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
|
bsw/jbe@1309
|
44 ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = initiative.display_name }
|
bsw/jbe@1309
|
45 end }
|
bsw/jbe@1309
|
46 ui.container{ attr = { class = "mdl-card__content mdl-card--border" }, content = function()
|
bsw/jbe@1309
|
47 if param.get("preview") then
|
bsw/jbe@1309
|
48 ui.sectionRow( function()
|
bsw/jbe@1309
|
49 if config.initiative_abstract then
|
bsw/jbe@1309
|
50 ui.field.hidden{ name = "abstract", value = param.get("abstract") }
|
bsw/jbe@1309
|
51 ui.container{
|
bsw/jbe@1309
|
52 attr = { class = "abstract" },
|
bsw/jbe@1309
|
53 content = param.get("abstract")
|
bsw/jbe@1309
|
54 }
|
bsw/jbe@1309
|
55 slot.put("<br />")
|
bsw/jbe@1309
|
56 end
|
bsw/jbe@1309
|
57 local draft_text = param.get("content")
|
bsw/jbe@1309
|
58 local draft_text = util.wysihtml_preproc(draft_text)
|
bsw/jbe@1309
|
59 ui.field.hidden{ name = "content", value = draft_text }
|
bsw/jbe@1309
|
60 ui.container{
|
bsw/jbe@1309
|
61 attr = { class = "draft" },
|
bsw/jbe@1309
|
62 content = function()
|
bsw/jbe@1309
|
63 slot.put(draft_text)
|
bsw/jbe@1309
|
64 end
|
bsw/jbe@1309
|
65 }
|
bsw/jbe@1309
|
66 slot.put("<br />")
|
bsw@95
|
67
|
bsw@1495
|
68 if config.attachments then
|
bsw@1495
|
69 local file_upload_session = param.get("file_upload_session") or multirand.string(
|
bsw@1495
|
70 32,
|
bsw@1495
|
71 '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
|
bsw@1495
|
72 )
|
bsw@1495
|
73 file_upload_session = string.gsub(file_upload_session, "[^A-Za-z0-9]", "")
|
bsw@1495
|
74 ui.field.hidden{ name = "file_upload_session", value = file_upload_session }
|
bsw@1495
|
75 local files = File:new_selector()
|
bsw@1495
|
76 :left_join("draft_attachment", nil, "draft_attachment.file_id = file.id")
|
bsw@1495
|
77 :add_where{ "draft_attachment.draft_id = ?", initiative.current_draft.id }
|
bsw@1495
|
78 :reset_fields()
|
bsw@1495
|
79 :add_field("file.id")
|
bsw@1495
|
80 :add_field("draft_attachment.title")
|
bsw@1495
|
81 :add_field("draft_attachment.description")
|
bsw@1495
|
82 :add_order_by("draft_attachment.id")
|
bsw@1495
|
83 :exec()
|
bsw@1495
|
84
|
bsw@1495
|
85 if #files > 0 then
|
bsw@1495
|
86 ui.container {
|
bsw@1495
|
87 content = function()
|
bsw@1495
|
88 for i, file in ipairs(files) do
|
bsw@1495
|
89 if param.get("file_delete_" .. file.id, atom.boolean) then
|
bsw@1495
|
90 ui.field.hidden{ name = "file_delete_" .. file.id, value = "1" }
|
bsw@1495
|
91 else
|
bsw@1495
|
92 ui.image{ module = "file", view = "show.jpg", id = file.id, params = { preview = true } }
|
bsw@1495
|
93 ui.container{ content = file.title or "" }
|
bsw@1495
|
94 ui.container{ content = file.description or "" }
|
bsw@1495
|
95 slot.put("<br /><br />")
|
bsw@1495
|
96 end
|
bsw@1495
|
97 end
|
bsw@1495
|
98 end
|
bsw@1495
|
99 }
|
bsw@1495
|
100 end
|
bsw@1495
|
101 local filename = encode.file_path(WEBMCP_BASE_PATH, 'tmp', "file_upload-" .. file_upload_session .. ".json")
|
bsw@1495
|
102 local fh = io.open(filename, "r")
|
bsw@1495
|
103 if fh then
|
bsw@1495
|
104 local file_uploads = json.import(fh:read("*a"))
|
bsw@1495
|
105 for i, file_upload in ipairs(file_uploads) do
|
bsw@1495
|
106 ui.image{ module = "draft", view = "show_file_upload", params = {
|
bsw@1495
|
107 file_upload_session = file_upload_session, file_id = file_upload.id, preview = true
|
bsw@1495
|
108 } }
|
bsw@1495
|
109 ui.container{ content = file_upload.title or "" }
|
bsw@1495
|
110 ui.container{ content = file_upload.description or "" }
|
bsw@1495
|
111 slot.put("<br />")
|
bsw@1495
|
112 end
|
bsw@1495
|
113 end
|
bsw@1495
|
114 end
|
bsw@1495
|
115
|
bsw/jbe@1309
|
116 ui.tag{
|
bsw/jbe@1309
|
117 tag = "input",
|
bsw/jbe@1309
|
118 attr = {
|
bsw/jbe@1309
|
119 type = "submit",
|
bsw/jbe@1309
|
120 class = "mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--colored",
|
bsw/jbe@1309
|
121 value = _'Publish now'
|
bsw/jbe@1309
|
122 },
|
bsw/jbe@1309
|
123 content = ""
|
bsw/jbe@1309
|
124 }
|
bsw/jbe@1309
|
125 slot.put(" ")
|
bsw/jbe@1309
|
126
|
bsw/jbe@1309
|
127 ui.tag{
|
bsw/jbe@1309
|
128 tag = "input",
|
bsw/jbe@1309
|
129 attr = {
|
bsw/jbe@1309
|
130 type = "submit",
|
bsw/jbe@1309
|
131 name = "edit",
|
bsw/jbe@1309
|
132 class = "mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect",
|
bsw/jbe@1309
|
133 value = _'Edit again'
|
bsw/jbe@1309
|
134 },
|
bsw/jbe@1309
|
135 content = ""
|
bsw/jbe@1309
|
136 }
|
bsw/jbe@1309
|
137 slot.put(" ")
|
bsw@95
|
138
|
bsw/jbe@1309
|
139 ui.link{
|
bsw/jbe@1309
|
140 attr = { class = "mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect" },
|
bsw/jbe@1309
|
141 content = _"Cancel",
|
bsw/jbe@1309
|
142 module = "initiative",
|
bsw/jbe@1309
|
143 view = "show",
|
bsw/jbe@1309
|
144 id = initiative.id
|
bsw/jbe@1309
|
145 }
|
bsw/jbe@1309
|
146 end )
|
bsw@1045
|
147
|
bsw/jbe@1309
|
148 else
|
bsw/jbe@1309
|
149 ui.sectionRow( function()
|
bsw/jbe@1309
|
150 if config.initiative_abstract then
|
bsw/jbe@1309
|
151 ui.container { content = _"Enter abstract:" }
|
bsw/jbe@1309
|
152 ui.container{ attr = { class = "mdl-textfield mdl-js-textfield mdl-textfield--expandable mdl-textfield__fullwidth" }, content = function()
|
bsw/jbe@1309
|
153 ui.field.text{
|
bsw/jbe@1309
|
154 name = "abstract",
|
bsw/jbe@1309
|
155 multiline = true,
|
bsw/jbe@1309
|
156 attr = { id = "abstract", style = "height: 20ex; width: 100%;" },
|
bsw/jbe@1309
|
157 value = param.get("abstract")
|
bsw/jbe@1309
|
158 }
|
bsw/jbe@1309
|
159 end }
|
bsw/jbe@1309
|
160 end
|
bsw/jbe@1309
|
161
|
bsw/jbe@1309
|
162 ui.container { content = _"Enter your proposal and/or reasons:" }
|
bsw/jbe@1309
|
163 ui.field.wysihtml{
|
bsw/jbe@1309
|
164 name = "content",
|
bsw/jbe@1309
|
165 multiline = true,
|
bsw/jbe@1309
|
166 attr = { id = "draft", style = "height: 50ex; width: 100%;" },
|
bsw/jbe@1309
|
167 value = param.get("content")
|
bsw/jbe@1309
|
168 }
|
bsw/jbe@1309
|
169 if not issue or issue.state == "admission" or issue.state == "discussion" then
|
bsw/jbe@1309
|
170 ui.container { content = _"You can change your text again anytime during admission and discussion phase" }
|
bsw/jbe@1309
|
171 else
|
bsw/jbe@1309
|
172 ui.container { content = _"You cannot change your text again later, because this issue is already in verfication phase!" }
|
bsw/jbe@1309
|
173 end
|
bsw@1495
|
174
|
bsw/jbe@1309
|
175 slot.put("<br />")
|
bsw@1495
|
176 if config.attachments then
|
bsw@1495
|
177 local file_upload_session = param.get("file_upload_session") or multirand.string(
|
bsw@1495
|
178 32,
|
bsw@1495
|
179 '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
|
bsw@1495
|
180 )
|
bsw@1495
|
181 file_upload_session = string.gsub(file_upload_session, "[^A-Za-z0-9]", "")
|
bsw@1495
|
182 ui.field.hidden{ name = "file_upload_session", value = file_upload_session }
|
bsw@1495
|
183 local files = File:new_selector()
|
bsw@1495
|
184 :left_join("draft_attachment", nil, "draft_attachment.file_id = file.id")
|
bsw@1495
|
185 :add_where{ "draft_attachment.draft_id = ?", initiative.current_draft.id }
|
bsw@1495
|
186 :reset_fields()
|
bsw@1495
|
187 :add_field("file.id")
|
bsw@1495
|
188 :add_field("draft_attachment.title")
|
bsw@1495
|
189 :add_field("draft_attachment.description")
|
bsw@1495
|
190 :add_order_by("draft_attachment.id")
|
bsw@1495
|
191 :exec()
|
bsw@1495
|
192
|
bsw@1495
|
193 if #files > 0 then
|
bsw@1495
|
194 ui.container {
|
bsw@1495
|
195 content = function()
|
bsw@1495
|
196 for i, file in ipairs(files) do
|
bsw@1495
|
197 ui.image{ module = "file", view = "show.jpg", id = file.id, params = { preview = true } }
|
bsw@1495
|
198 ui.container{ content = file.title or "" }
|
bsw@1495
|
199 ui.container{ content = file.description or "" }
|
bsw@1495
|
200 ui.field.boolean{ label = _"delete", name = "file_delete_" .. file.id, value = param.get("file_delete_" .. file.id) and true or false }
|
bsw@1495
|
201 slot.put("<br /><br />")
|
bsw@1495
|
202 end
|
bsw@1495
|
203 end
|
bsw@1495
|
204 }
|
bsw@1495
|
205 end
|
bsw@1495
|
206
|
bsw@1495
|
207 local filename = encode.file_path(WEBMCP_BASE_PATH, 'tmp', "file_upload-" .. file_upload_session .. ".json")
|
bsw@1495
|
208 local fh = io.open(filename, "r")
|
bsw@1495
|
209 if fh then
|
bsw@1495
|
210 local file_uploads = json.import(fh:read("*a"))
|
bsw@1495
|
211 for i, file_upload in ipairs(file_uploads) do
|
bsw@1495
|
212 ui.image{ module = "draft", view = "show_file_upload", params = {
|
bsw@1495
|
213 file_upload_session = file_upload_session, file_id = file_upload.id, preview = true
|
bsw@1495
|
214 } }
|
bsw@1495
|
215 ui.container{ content = file_upload.title or "" }
|
bsw@1495
|
216 ui.container{ content = file_upload.description or "" }
|
bsw@1495
|
217 ui.field.boolean{ label = _"delete", name = "file_upload_delete_" .. file_upload.id }
|
bsw@1495
|
218 slot.put("<br />")
|
bsw@1495
|
219 end
|
bsw@1495
|
220 end
|
bsw@1495
|
221 ui.container{ attr = { id = "file_upload_template", style = "display: none;" }, content = function()
|
bsw@1495
|
222 ui.field.text{ label = _"Title", name = "__ID_title__" }
|
bsw@1495
|
223 ui.field.text{ label = _"Description", name = "__ID_description__" }
|
bsw@1495
|
224 ui.field.image{ field_name = "__ID_file__" }
|
bsw@1495
|
225 end }
|
bsw@1495
|
226 ui.container{ attr = { id = "file_upload" }, content = function()
|
bsw@1495
|
227 end }
|
bsw@1495
|
228 ui.field.hidden{ attr = { id = "file_upload_last_id" }, name = "file_upload_last_id" }
|
bsw@1495
|
229 ui.script{ script = [[ var file_upload_id = 1; ]] }
|
bsw@1495
|
230 ui.tag{ tag = "a", content = _"Attach image", attr = {
|
bsw@1495
|
231 href = "#",
|
bsw@1495
|
232 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@1495
|
233 } }
|
bsw@1495
|
234 slot.put("<br />")
|
bsw@1495
|
235
|
bsw@1495
|
236 slot.put("<br />")
|
bsw@1495
|
237
|
bsw@1495
|
238 end
|
bsw@1045
|
239
|
bsw/jbe@1309
|
240 ui.tag{
|
bsw/jbe@1309
|
241 tag = "input",
|
bsw/jbe@1309
|
242 attr = {
|
bsw/jbe@1309
|
243 type = "submit",
|
bsw/jbe@1309
|
244 name = "preview",
|
bsw/jbe@1309
|
245 class = "mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--colored",
|
bsw/jbe@1309
|
246 value = _'Preview'
|
bsw/jbe@1309
|
247 },
|
bsw/jbe@1309
|
248 content = ""
|
bsw/jbe@1309
|
249 }
|
bsw/jbe@1309
|
250 slot.put(" ")
|
bsw/jbe@1309
|
251
|
bsw/jbe@1309
|
252 ui.link{
|
bsw/jbe@1309
|
253 content = _"Cancel",
|
bsw/jbe@1309
|
254 module = "initiative",
|
bsw/jbe@1309
|
255 view = "show",
|
bsw/jbe@1309
|
256 id = initiative.id,
|
bsw/jbe@1309
|
257 attr = { class = "mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect" }
|
bsw/jbe@1309
|
258 }
|
bsw/jbe@1309
|
259
|
bsw/jbe@1309
|
260 end )
|
bsw/jbe@1309
|
261 end
|
bsw/jbe@1309
|
262 end }
|
bsw/jbe@1309
|
263 end }
|
bsw/jbe@1309
|
264 end }
|
bsw/jbe@1309
|
265 end }
|
bsw/jbe@0
|
266 end
|
bsw/jbe@0
|
267 }
|