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