rev |
line source |
bsw/jbe@0
|
1 local issue
|
bsw/jbe@0
|
2 local area
|
bsw/jbe@0
|
3
|
bsw/jbe@0
|
4 local issue_id = param.get("issue_id", atom.integer)
|
bsw/jbe@0
|
5 if issue_id then
|
bsw/jbe@0
|
6 issue = Issue:new_selector():add_where{"id=?",issue_id}:single_object_mode():exec()
|
bsw@1045
|
7 issue:load_everything_for_member_id(app.session.member_id)
|
bsw/jbe@0
|
8 area = issue.area
|
bsw/jbe@0
|
9
|
bsw/jbe@0
|
10 else
|
bsw/jbe@0
|
11 local area_id = param.get("area_id", atom.integer)
|
bsw/jbe@0
|
12 area = Area:new_selector():add_where{"id=?",area_id}:single_object_mode():exec()
|
bsw@1045
|
13 area:load_delegation_info_once_for_member_id(app.session.member_id)
|
bsw/jbe@0
|
14 end
|
bsw/jbe@0
|
15
|
bsw@904
|
16 local polling = param.get("polling", atom.boolean)
|
bsw@904
|
17
|
bsw@901
|
18 local policy_id = param.get("policy_id", atom.integer)
|
bsw@901
|
19 local policy
|
bsw@901
|
20
|
bsw@1045
|
21 local preview = param.get("preview")
|
bsw@1045
|
22
|
bsw@1045
|
23 if #(slot.get_content("error")) > 0 then
|
bsw@1045
|
24 preview = false
|
bsw@1045
|
25 end
|
bsw@1045
|
26
|
bsw@901
|
27 if policy_id then
|
bsw@901
|
28 policy = Policy:by_id(policy_id)
|
bsw@901
|
29 end
|
bsw@901
|
30
|
bsw/jbe@0
|
31 if issue_id then
|
bsw@1045
|
32 execute.view {
|
bsw@1045
|
33 module = "issue", view = "_head",
|
bsw@1045
|
34 params = { issue = issue, member = app.session.member }
|
bsw@1045
|
35 }
|
bsw/jbe@0
|
36 else
|
bsw/jbe@1309
|
37 --[[
|
bsw@1045
|
38 execute.view {
|
bsw@1045
|
39 module = "area", view = "_head",
|
bsw@1045
|
40 params = { area = area, member = app.session.member }
|
bsw@1045
|
41 }
|
bsw/jbe@1309
|
42 --]]
|
bsw/jbe@1309
|
43 --[[
|
bsw@1045
|
44 execute.view {
|
bsw@1045
|
45 module = "initiative", view = "_sidebar_policies",
|
bsw@1045
|
46 params = {
|
bsw@1045
|
47 area = area,
|
bsw@1045
|
48 }
|
bsw@1045
|
49 }
|
bsw/jbe@1309
|
50 --]]
|
bsw/jbe@0
|
51 end
|
bsw/jbe@0
|
52
|
bsw/jbe@0
|
53 ui.form{
|
bsw/jbe@0
|
54 module = "initiative",
|
bsw/jbe@0
|
55 action = "create",
|
bsw/jbe@0
|
56 params = {
|
bsw/jbe@0
|
57 area_id = area.id,
|
bsw/jbe@0
|
58 issue_id = issue and issue.id or nil
|
bsw/jbe@0
|
59 },
|
bsw/jbe@0
|
60 attr = { class = "vertical" },
|
bsw/jbe@0
|
61 content = function()
|
bsw/jbe@1309
|
62 ui.grid{ content = function()
|
bsw/jbe@1309
|
63 ui.cell_main{ content = function()
|
bsw/jbe@1309
|
64 ui.container{ attr = { class = "mdl-card mdl-shadow--2dp mdl-card__fullwidth" }, content = function()
|
bsw/jbe@1309
|
65 ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
|
bsw/jbe@1309
|
66 if preview then
|
bsw/jbe@1309
|
67 ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = _"Preview" }
|
bsw/jbe@1309
|
68 elseif issue_id then
|
bsw/jbe@1309
|
69 ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = _"New competing initiative" }
|
bsw/jbe@1309
|
70 else
|
bsw/jbe@1309
|
71 ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = _"Create a new issue" }
|
bsw@1045
|
72 end
|
bsw/jbe@1309
|
73 end }
|
bsw/jbe@1309
|
74
|
bsw/jbe@1309
|
75 ui.container{ attr = { class = "mdl-card__content mdl-card--border" }, content = function()
|
bsw@1045
|
76
|
bsw@1045
|
77
|
bsw/jbe@1309
|
78 if preview then
|
bsw/jbe@1309
|
79
|
bsw/jbe@1309
|
80 ui.section( function()
|
bsw/jbe@1309
|
81 ui.sectionHead( function()
|
bsw/jbe@1309
|
82 ui.heading{ level = 1, content = encode.html(param.get("name")) }
|
bsw/jbe@1309
|
83 if not issue then
|
bsw/jbe@1309
|
84 ui.container { content = policy.name }
|
bsw/jbe@1309
|
85 end
|
bsw/jbe@1309
|
86 if param.get("free_timing") then
|
bsw/jbe@1309
|
87 ui.container { content = param.get("free_timing") }
|
bsw/jbe@1309
|
88 end
|
bsw/jbe@1309
|
89 slot.put("<br />")
|
bsw/jbe@1309
|
90
|
bsw/jbe@1309
|
91 local draft_text = param.get("draft")
|
bsw/jbe@1309
|
92 local draft_text = util.wysihtml_preproc(draft_text)
|
bsw@1045
|
93
|
bsw/jbe@1309
|
94 ui.field.hidden{ name = "policy_id", value = param.get("policy_id") }
|
bsw/jbe@1309
|
95 ui.field.hidden{ name = "name", value = param.get("name") }
|
bsw/jbe@1309
|
96 if config.initiative_abstract then
|
bsw/jbe@1309
|
97 ui.field.hidden{ name = "abstract", value = param.get("abstract") }
|
bsw/jbe@1309
|
98 ui.container{
|
bsw/jbe@1309
|
99 attr = { class = "abstract" },
|
bsw/jbe@1309
|
100 content = param.get("abstract")
|
bsw/jbe@1309
|
101 }
|
bsw/jbe@1309
|
102 slot.put("<br />")
|
bsw/jbe@1309
|
103 end
|
bsw/jbe@1309
|
104 ui.field.hidden{ name = "draft", value = draft_text }
|
bsw/jbe@1309
|
105 ui.field.hidden{ name = "free_timing", value = param.get("free_timing") }
|
bsw/jbe@1309
|
106 ui.field.hidden{ name = "polling", value = param.get("polling", atom.boolean) }
|
bsw/jbe@1309
|
107 ui.field.hidden{ name = "location", value = param.get("location") }
|
bsw/jbe@1309
|
108 local formatting_engine
|
bsw/jbe@1309
|
109 if config.enforce_formatting_engine then
|
bsw/jbe@1309
|
110 formatting_engine = config.enforce_formatting_engine
|
bsw/jbe@1309
|
111 else
|
bsw/jbe@1309
|
112 formatting_engine = param.get("formatting_engine")
|
bsw/jbe@1309
|
113 end
|
bsw/jbe@1309
|
114 ui.container{
|
bsw/jbe@1309
|
115 attr = { class = "draft" },
|
bsw/jbe@1309
|
116 content = function()
|
bsw/jbe@1309
|
117 slot.put(draft_text)
|
bsw/jbe@1309
|
118 end
|
bsw/jbe@1309
|
119 }
|
bsw/jbe@1309
|
120 slot.put("<br />")
|
bsw@1045
|
121
|
bsw/jbe@1309
|
122 ui.tag{
|
bsw/jbe@1309
|
123 tag = "input",
|
bsw/jbe@1309
|
124 attr = {
|
bsw/jbe@1309
|
125 type = "submit",
|
bsw/jbe@1309
|
126 class = "mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--colored",
|
bsw/jbe@1309
|
127 value = _'Publish now'
|
bsw/jbe@1309
|
128 },
|
bsw/jbe@1309
|
129 content = ""
|
bsw/jbe@1309
|
130 }
|
bsw/jbe@1309
|
131 slot.put(" ")
|
bsw/jbe@1309
|
132 ui.tag{
|
bsw/jbe@1309
|
133 tag = "input",
|
bsw/jbe@1309
|
134 attr = {
|
bsw/jbe@1309
|
135 type = "submit",
|
bsw/jbe@1309
|
136 name = "edit",
|
bsw/jbe@1309
|
137 class = "mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect",
|
bsw/jbe@1309
|
138 value = _'Edit again'
|
bsw/jbe@1309
|
139 },
|
bsw/jbe@1309
|
140 content = ""
|
bsw/jbe@1309
|
141 }
|
bsw/jbe@1309
|
142 slot.put(" ")
|
bsw/jbe@1309
|
143 local class = "mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect"
|
bsw/jbe@1309
|
144 if issue then
|
bsw/jbe@1309
|
145 ui.link{ content = _"Cancel", module = "issue", view = "show", id = issue.id, attr = { class = class } }
|
bsw/jbe@1309
|
146 else
|
bsw/jbe@1309
|
147 ui.link{ content = _"Cancel", module = "index", view = "index", params = { unit = area.unit_id, area = area.id }, attr = { class = class } }
|
bsw/jbe@1309
|
148 end
|
bsw/jbe@1309
|
149 end )
|
bsw/jbe@1309
|
150 end )
|
bsw/jbe@1309
|
151 else
|
bsw/jbe@1309
|
152
|
bsw/jbe@1309
|
153 ui.sectionRow( function()
|
bsw/jbe@1309
|
154 --[[
|
bsw/jbe@1309
|
155 if not preview and not issue_id then
|
bsw/jbe@1309
|
156 ui.container { attr = { class = "section" }, content = _"Before creating a new issue, please check any existant issues before, if the topic is already in discussion." }
|
bsw/jbe@1309
|
157 slot.put("<br />")
|
bsw/jbe@1309
|
158 end
|
bsw/jbe@1309
|
159 --]]
|
bsw/jbe@1309
|
160 if not issue_id then
|
bsw/jbe@1309
|
161 local tmp = { { id = -1, name = "" } }
|
bsw/jbe@1309
|
162 for i, allowed_policy in ipairs(area.allowed_policies) do
|
bsw/jbe@1309
|
163 if not allowed_policy.polling or app.session.member:has_polling_right_for_unit_id(area.unit_id) then
|
bsw/jbe@1309
|
164 tmp[#tmp+1] = allowed_policy
|
bsw/jbe@1309
|
165 end
|
bsw/jbe@1309
|
166 end
|
bsw/jbe@1309
|
167 ui.container{ content = _"Please choose a policy for the new issue:" }
|
bsw/jbe@1309
|
168 ui.field.select{
|
bsw/jbe@1309
|
169 name = "policy_id",
|
bsw/jbe@1309
|
170 foreign_records = tmp,
|
bsw/jbe@1309
|
171 foreign_id = "id",
|
bsw/jbe@1309
|
172 foreign_name = "name",
|
bsw/jbe@1309
|
173 value = param.get("policy_id", atom.integer) or area.default_policy and area.default_policy.id
|
bsw/jbe@1309
|
174 }
|
bsw/jbe@1309
|
175 if policy and policy.free_timeable then
|
bsw/jbe@1309
|
176 local available_timings
|
bsw/jbe@1309
|
177 if config.free_timing and config.free_timing.available_func then
|
bsw/jbe@1309
|
178 available_timings = config.free_timing.available_func(policy)
|
bsw/jbe@1309
|
179 if available_timings == false then
|
bsw/jbe@1309
|
180 slot.put_into("error", "error in free timing config")
|
bsw/jbe@1309
|
181 return false
|
bsw/jbe@1309
|
182 end
|
bsw/jbe@1309
|
183 end
|
bsw/jbe@1309
|
184 ui.heading{ level = 4, content = _"Free timing:" }
|
bsw/jbe@1309
|
185 if available_timings then
|
bsw/jbe@1309
|
186 ui.field.select{
|
bsw/jbe@1309
|
187 name = "free_timing",
|
bsw/jbe@1309
|
188 foreign_records = available_timings,
|
bsw/jbe@1309
|
189 foreign_id = "id",
|
bsw/jbe@1309
|
190 foreign_name = "name",
|
bsw/jbe@1309
|
191 value = param.get("free_timing")
|
bsw/jbe@1309
|
192 }
|
bsw/jbe@1309
|
193 else
|
bsw/jbe@1309
|
194 ui.field.text{
|
bsw/jbe@1309
|
195 name = "free_timing",
|
bsw/jbe@1309
|
196 value = param.get("free_timing")
|
bsw/jbe@1309
|
197 }
|
bsw/jbe@1309
|
198 end
|
bsw/jbe@1309
|
199 end
|
bsw/jbe@1309
|
200 end
|
bsw@1045
|
201
|
bsw/jbe@1309
|
202 if issue and issue.policy.polling and app.session.member:has_polling_right_for_unit_id(area.unit_id) then
|
bsw/jbe@1309
|
203 slot.put("<br />")
|
bsw/jbe@1309
|
204 ui.field.boolean{ name = "polling", label = _"No admission needed", value = polling }
|
bsw/jbe@1309
|
205 end
|
bsw/jbe@1309
|
206
|
bsw/jbe@1309
|
207 ui.container{ attr = { class = "mdl-textfield mdl-js-textfield mdl-textfield--floating-label mdl-card__fullwidth" }, content = function ()
|
bsw/jbe@1309
|
208 ui.field.text{
|
bsw/jbe@1309
|
209 attr = { id = "lf-initiative__name", class = "mdl-textfield__input" },
|
bsw/jbe@1309
|
210 label_attr = { class = "mdl-textfield__label", ["for"] = "lf-initiative__name" },
|
bsw/jbe@1309
|
211 label = _"Title",
|
bsw/jbe@1309
|
212 name = "name",
|
bsw/jbe@1309
|
213 value = param.get("name")
|
bsw/jbe@1309
|
214 }
|
bsw/jbe@1309
|
215 end }
|
bsw/jbe@1309
|
216
|
bsw/jbe@1309
|
217 if config.initiative_abstract then
|
bsw/jbe@1309
|
218 ui.container { content = _"Enter abstract:" }
|
bsw/jbe@1309
|
219 ui.container{ attr = { class = "mdl-textfield mdl-js-textfield mdl-textfield--expandable mdl-textfield__fullwidth" }, content = function()
|
bsw/jbe@1309
|
220 ui.field.text{
|
bsw/jbe@1309
|
221 name = "abstract",
|
bsw/jbe@1309
|
222 multiline = true,
|
bsw/jbe@1309
|
223 attr = { id = "abstract", style = "height: 20ex; width: 100%;" },
|
bsw/jbe@1309
|
224 value = param.get("abstract")
|
bsw/jbe@1309
|
225 }
|
bsw/jbe@1309
|
226 end }
|
bsw/jbe@1309
|
227 end
|
bsw/jbe@1309
|
228
|
bsw/jbe@1309
|
229 ui.container { content = _"Enter your proposal and/or reasons:" }
|
bsw/jbe@1309
|
230 ui.container{ attr = { class = "mdl-textfield mdl-js-textfield mdl-textfield--expandable mdl-textfield__fullwidth" }, content = function()
|
bsw/jbe@1309
|
231 ui.field.wysihtml{
|
bsw/jbe@1309
|
232 name = "draft",
|
bsw/jbe@1309
|
233 multiline = true,
|
bsw/jbe@1309
|
234 attr = { id = "draft", style = "height: 50ex; width: 100%;" },
|
bsw/jbe@1309
|
235 value = param.get("draft") or config.draft_template
|
bsw/jbe@1309
|
236 }
|
bsw/jbe@1309
|
237 end }
|
bsw/jbe@1309
|
238 if not issue or issue.state == "admission" or issue.state == "discussion" then
|
bsw/jbe@1309
|
239 ui.container { content = _"You can change your text again anytime during admission and discussion phase" }
|
bsw/jbe@1309
|
240 else
|
bsw/jbe@1309
|
241 ui.container { content = _"You cannot change your text again later, because this issue is already in verfication phase!" }
|
bsw/jbe@1309
|
242 end
|
bsw/jbe@1309
|
243 slot.put("<br />")
|
bsw/jbe@1309
|
244
|
bsw/jbe@1309
|
245 slot.put("<br />")
|
bsw/jbe@1309
|
246 ui.tag{
|
bsw/jbe@1309
|
247 tag = "input",
|
bsw/jbe@1309
|
248 attr = {
|
bsw/jbe@1309
|
249 type = "submit",
|
bsw/jbe@1309
|
250 name = "preview",
|
bsw/jbe@1309
|
251 class = "mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--colored",
|
bsw/jbe@1309
|
252 value = _'Preview'
|
bsw/jbe@1309
|
253 },
|
bsw/jbe@1309
|
254 content = ""
|
bsw/jbe@1309
|
255 }
|
bsw/jbe@1309
|
256 slot.put(" ")
|
bsw/jbe@1309
|
257
|
bsw/jbe@1309
|
258 local class = "mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect"
|
bsw/jbe@1309
|
259 if issue then
|
bsw/jbe@1309
|
260
|
bsw/jbe@1309
|
261 ui.link{ content = _"Cancel", module = "issue", view = "show", id = issue.id, attr = { class = class } }
|
bsw/jbe@1309
|
262 else
|
bsw/jbe@1309
|
263 ui.link{ content = _"Cancel", module = "index", view = "index", params = { unit = area.unit_id, area = area.id }, attr = { class = class } }
|
bsw/jbe@1309
|
264 end
|
bsw/jbe@1309
|
265 end )
|
bsw/jbe@1309
|
266 end
|
bsw/jbe@1309
|
267 end }
|
bsw/jbe@1309
|
268 end }
|
bsw/jbe@1309
|
269 end }
|
bsw/jbe@1309
|
270 if config.map or config.firstlife then
|
bsw/jbe@1309
|
271 ui.cell_sidebar{ content = function()
|
bsw/jbe@1309
|
272 ui.container{ attr = { class = "mdl-special-card map mdl-shadow--2dp" }, content = function()
|
bsw/jbe@1309
|
273 ui.field.location{ name = "location", value = param.get("location") }
|
bsw/jbe@1309
|
274 end }
|
bsw/jbe@1309
|
275 end }
|
bsw/jbe@1309
|
276 end
|
bsw/jbe@1309
|
277 end }
|
bsw/jbe@0
|
278 end
|
bsw@907
|
279 }
|