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@1045
|
36 execute.view {
|
bsw@1045
|
37 module = "issue", view = "_sidebar_state",
|
bsw@1045
|
38 params = {
|
bsw@1045
|
39 issue = issue
|
bsw@1045
|
40 }
|
bsw@1045
|
41 }
|
bsw@1045
|
42 execute.view {
|
bsw@1045
|
43 module = "issue", view = "_sidebar_issue",
|
bsw@1045
|
44 params = {
|
bsw@1045
|
45 issue = issue
|
bsw@1045
|
46 }
|
bsw@1045
|
47 }
|
bsw/jbe@0
|
48 else
|
bsw@1045
|
49 execute.view {
|
bsw@1045
|
50 module = "area", view = "_head",
|
bsw@1045
|
51 params = { area = area, member = app.session.member }
|
bsw@1045
|
52 }
|
bsw@1045
|
53 execute.view {
|
bsw@1045
|
54 module = "initiative", view = "_sidebar_policies",
|
bsw@1045
|
55 params = {
|
bsw@1045
|
56 area = area,
|
bsw@1045
|
57 }
|
bsw@1045
|
58 }
|
bsw/jbe@0
|
59 end
|
bsw/jbe@0
|
60
|
bsw/jbe@0
|
61 ui.form{
|
bsw/jbe@0
|
62 module = "initiative",
|
bsw/jbe@0
|
63 action = "create",
|
bsw/jbe@0
|
64 params = {
|
bsw/jbe@0
|
65 area_id = area.id,
|
bsw/jbe@0
|
66 issue_id = issue and issue.id or nil
|
bsw/jbe@0
|
67 },
|
bsw/jbe@0
|
68 attr = { class = "vertical" },
|
bsw/jbe@0
|
69 content = function()
|
bsw@1045
|
70
|
bsw@1045
|
71 if preview then
|
bsw@1045
|
72 ui.section( function()
|
bsw@1045
|
73 ui.sectionHead( function()
|
bsw@1045
|
74 ui.heading{ level = 1, content = encode.html(param.get("name")) }
|
bsw@1045
|
75 if not issue then
|
bsw@1045
|
76 ui.container { content = policy.name }
|
bsw@901
|
77 end
|
bsw@1092
|
78 if param.get("free_timing") then
|
bsw@1092
|
79 ui.container { content = param.get("free_timing") }
|
bsw@1092
|
80 end
|
bsw@1045
|
81 slot.put("<br />")
|
bsw@1045
|
82
|
bsw@1045
|
83 ui.field.hidden{ name = "formatting_engine", value = param.get("formatting_engine") }
|
bsw@1045
|
84 ui.field.hidden{ name = "policy_id", value = param.get("policy_id") }
|
bsw@1045
|
85 ui.field.hidden{ name = "name", value = param.get("name") }
|
bsw@1045
|
86 ui.field.hidden{ name = "draft", value = param.get("draft") }
|
bsw@1092
|
87 ui.field.hidden{ name = "free_timing", value = param.get("free_timing") }
|
bsw@1045
|
88 local formatting_engine
|
bsw@1045
|
89 if config.enforce_formatting_engine then
|
bsw@1045
|
90 formatting_engine = config.enforce_formatting_engine
|
bsw@1045
|
91 else
|
bsw@1045
|
92 formatting_engine = param.get("formatting_engine")
|
bsw@1045
|
93 end
|
bsw@1045
|
94 ui.container{
|
bsw@1045
|
95 attr = { class = "draft_content wiki" },
|
bsw@64
|
96 content = function()
|
bsw@1045
|
97 slot.put(format.wiki_text(param.get("draft"), formatting_engine))
|
bsw@64
|
98 end
|
bsw@64
|
99 }
|
bsw@1045
|
100 slot.put("<br />")
|
bsw@1045
|
101
|
bsw@1045
|
102 ui.tag{
|
bsw@1045
|
103 tag = "input",
|
bsw@1045
|
104 attr = {
|
bsw@1045
|
105 type = "submit",
|
bsw@1045
|
106 class = "btn btn-default",
|
bsw@1045
|
107 value = _'Publish now'
|
bsw@1045
|
108 },
|
bsw@1045
|
109 content = ""
|
bsw@1045
|
110 }
|
bsw@1045
|
111 slot.put("<br />")
|
bsw@1045
|
112 slot.put("<br />")
|
bsw@1045
|
113 ui.tag{
|
bsw@1045
|
114 tag = "input",
|
bsw@1045
|
115 attr = {
|
bsw@1045
|
116 type = "submit",
|
bsw@1045
|
117 name = "edit",
|
bsw@1045
|
118 class = "btn-link",
|
bsw@1045
|
119 value = _'Edit again'
|
bsw@1045
|
120 },
|
bsw@1045
|
121 content = ""
|
bsw@1045
|
122 }
|
bsw@1045
|
123 slot.put(" | ")
|
bsw@1045
|
124 if issue then
|
bsw@1045
|
125 ui.link{ content = _"Cancel", module = "issue", view = "show", id = issue.id }
|
bsw@95
|
126 else
|
bsw@1045
|
127 ui.link{ content = _"Cancel", module = "area", view = "show", id = area.id }
|
bsw@95
|
128 end
|
bsw@1045
|
129 end )
|
bsw@1045
|
130 end )
|
bsw@1045
|
131 else
|
bsw@1045
|
132
|
bsw@1045
|
133
|
bsw@1045
|
134 execute.view{ module = "initiative", view = "_sidebar_wikisyntax" }
|
bsw@95
|
135
|
bsw@1045
|
136 ui.section( function()
|
bsw@1045
|
137 if preview then
|
bsw@1045
|
138 ui.sectionHead( function()
|
bsw@1045
|
139 ui.heading { level = 1, content = _"Edit again" }
|
bsw@1045
|
140 end )
|
bsw@1045
|
141 elseif issue_id then
|
bsw@1045
|
142 ui.sectionHead( function()
|
bsw@1045
|
143 ui.heading { level = 1, content = _"Add a new competing initiative to issue" }
|
bsw@1045
|
144 end )
|
bsw@1045
|
145 else
|
bsw@1045
|
146 ui.sectionHead( function()
|
bsw@1045
|
147 ui.heading { level = 1, content = _"Create a new issue" }
|
bsw@1045
|
148 end )
|
bsw@1045
|
149 end
|
bsw@1045
|
150
|
bsw@1045
|
151 ui.sectionRow( function()
|
bsw@1045
|
152 if not preview and not issue_id then
|
bsw@1045
|
153 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@1045
|
154 slot.put("<br />")
|
bsw@1045
|
155 end
|
bsw@1045
|
156 if not issue_id then
|
bsw@1045
|
157 tmp = { { id = -1, name = "" } }
|
bsw@1045
|
158 for i, allowed_policy in ipairs(area.allowed_policies) do
|
bsw@1091
|
159 if not allowed_policy.polling or app.session.member:has_polling_right_for_unit_id(area.unit_id) then
|
bsw@1045
|
160 tmp[#tmp+1] = allowed_policy
|
bsw@1045
|
161 end
|
bsw@1045
|
162 end
|
bsw@1045
|
163 ui.heading{ level = 2, content = _"Please choose a policy for the new issue:" }
|
bsw@1045
|
164 ui.field.select{
|
bsw@1045
|
165 name = "policy_id",
|
bsw@1045
|
166 foreign_records = tmp,
|
bsw@1045
|
167 foreign_id = "id",
|
bsw@1045
|
168 foreign_name = "name",
|
bsw@1045
|
169 value = param.get("policy_id", atom.integer) or area.default_policy and area.default_policy.id
|
bsw@1045
|
170 }
|
bsw@1045
|
171 if policy and policy.free_timeable then
|
bsw@1092
|
172 local available_timings
|
bsw@1092
|
173 if config.free_timing and config.free_timing.available_func then
|
bsw@1092
|
174 available_timings = config.free_timing.available_func(policy)
|
bsw@1092
|
175 if available_timings == false then
|
bsw@1092
|
176 error("error in free timing config")
|
bsw@1092
|
177 end
|
bsw@1092
|
178 end
|
bsw@1092
|
179 ui.heading{ level = 4, content = _"Free timing:" }
|
bsw@1092
|
180 if available_timings then
|
bsw@1092
|
181 ui.field.select{
|
bsw@1092
|
182 name = "free_timing",
|
bsw@1092
|
183 foreign_records = available_timings,
|
bsw@1092
|
184 foreign_id = "id",
|
bsw@1092
|
185 foreign_name = "name",
|
bsw@1092
|
186 value = param.get("free_timing")
|
bsw@1092
|
187 }
|
bsw@1092
|
188 else
|
bsw@1092
|
189 ui.field.text{
|
bsw@1092
|
190 name = "free_timing",
|
bsw@1092
|
191 value = param.get("free_timing")
|
bsw@1092
|
192 }
|
bsw@1092
|
193 end
|
bsw@1045
|
194 end
|
bsw@1045
|
195 end
|
bsw@1045
|
196
|
bsw@1045
|
197 if issue and issue.policy.polling and app.session.member:has_polling_right_for_unit_id(area.unit_id) then
|
bsw@1045
|
198 slot.put("<br />")
|
bsw@1045
|
199 ui.field.boolean{ name = "polling", label = _"No admission needed", value = polling }
|
bsw@1045
|
200 end
|
bsw@1045
|
201
|
bsw@1045
|
202 slot.put("<br />")
|
bsw@1045
|
203 ui.heading { level = 2, content = _"Enter a title for your initiative (max. 140 chars):" }
|
bsw@1045
|
204 ui.field.text{
|
bsw@1045
|
205 attr = { style = "width: 100%;" },
|
bsw@1045
|
206 name = "name",
|
bsw@1045
|
207 value = param.get("name")
|
poelzi@133
|
208 }
|
bsw@1045
|
209 ui.container { content = _"The title is the figurehead of your iniative. It should be short but meaningful! As others identifies your initiative by this title, you cannot change it later!" }
|
bsw@1045
|
210
|
bsw@1045
|
211 if not config.enforce_formatting_engine then
|
bsw@1045
|
212 slot.put("<br />")
|
bsw@1045
|
213 ui.heading { level = 4, content = _"Choose a formatting engine:" }
|
bsw@1045
|
214 ui.field.select{
|
bsw@1045
|
215 name = "formatting_engine",
|
bsw@1045
|
216 foreign_records = config.formatting_engines,
|
bsw@1045
|
217 attr = {id = "formatting_engine"},
|
bsw@1045
|
218 foreign_id = "id",
|
bsw@1045
|
219 foreign_name = "name",
|
bsw@1045
|
220 value = param.get("formatting_engine")
|
bsw@1045
|
221 }
|
bsw@1045
|
222 end
|
bsw@1045
|
223 slot.put("<br />")
|
bsw@1045
|
224
|
bsw@1045
|
225 ui.heading { level = 2, content = _"Enter your proposal and/or reasons:" }
|
bsw@1045
|
226 ui.field.text{
|
bsw@1045
|
227 name = "draft",
|
bsw@1045
|
228 multiline = true,
|
bsw@1045
|
229 attr = { style = "height: 50ex; width: 100%;" },
|
bsw@1045
|
230 value = param.get("draft") or
|
bsw@1045
|
231 [[
|
bsw@1045
|
232 Proposal
|
bsw@1045
|
233 ======
|
bsw@1045
|
234
|
bsw@1045
|
235 Replace me with your proposal.
|
bsw@1045
|
236
|
bsw@1045
|
237
|
bsw@1045
|
238 Reasons
|
bsw@1045
|
239 ======
|
bsw@1045
|
240
|
bsw@1045
|
241 Argument 1
|
bsw@1045
|
242 ------
|
bsw@1045
|
243
|
bsw@1045
|
244 Replace me with your first argument
|
bsw@1045
|
245
|
bsw@1045
|
246
|
bsw@1045
|
247 Argument 2
|
bsw@1045
|
248 ------
|
bsw@1045
|
249
|
bsw@1045
|
250 Replace me with your second argument
|
bsw@1045
|
251
|
bsw@1045
|
252 ]]
|
bsw@1045
|
253 }
|
bsw@1045
|
254 if not issue or issue.state == "admission" or issue.state == "discussion" then
|
bsw@1045
|
255 ui.container { content = _"You can change your text again anytime during admission and discussion phase" }
|
bsw@1045
|
256 else
|
bsw@1045
|
257 ui.container { content = _"You cannot change your text again later, because this issue is already in verfication phase!" }
|
bsw@1045
|
258 end
|
bsw@1045
|
259 slot.put("<br />")
|
poelzi@133
|
260 ui.tag{
|
bsw@1045
|
261 tag = "input",
|
bsw@1045
|
262 attr = {
|
bsw@1045
|
263 type = "submit",
|
bsw@1045
|
264 name = "preview",
|
bsw@1045
|
265 class = "btn btn-default",
|
bsw@1045
|
266 value = _'Preview'
|
bsw@1045
|
267 },
|
bsw@1045
|
268 content = ""
|
poelzi@133
|
269 }
|
bsw@1045
|
270 slot.put("<br />")
|
bsw@1045
|
271 slot.put("<br />")
|
bsw@1045
|
272
|
bsw@1045
|
273 if issue then
|
bsw@1045
|
274 ui.link{ content = _"Cancel", module = "issue", view = "show", id = issue.id }
|
bsw@1045
|
275 else
|
bsw@1045
|
276 ui.link{ content = _"Cancel", module = "area", view = "show", id = area.id }
|
bsw@1045
|
277 end
|
bsw@1045
|
278 end )
|
bsw@1045
|
279 end )
|
bsw@1045
|
280 end
|
bsw/jbe@0
|
281 end
|
bsw@907
|
282 }
|