liquid_feedback_frontend
view app/main/initiative/new.lua @ 1093:c2baf086cc8d
Fixed numbered lists in draft text
author | bsw |
---|---|
date | Mon Oct 20 12:41:40 2014 +0200 (2014-10-20) |
parents | 5b65ea5c24f5 |
children | 9604ba51624a |
line source
1 local issue
2 local area
4 local issue_id = param.get("issue_id", atom.integer)
5 if issue_id then
6 issue = Issue:new_selector():add_where{"id=?",issue_id}:single_object_mode():exec()
7 issue:load_everything_for_member_id(app.session.member_id)
8 area = issue.area
10 else
11 local area_id = param.get("area_id", atom.integer)
12 area = Area:new_selector():add_where{"id=?",area_id}:single_object_mode():exec()
13 area:load_delegation_info_once_for_member_id(app.session.member_id)
14 end
16 local polling = param.get("polling", atom.boolean)
18 local policy_id = param.get("policy_id", atom.integer)
19 local policy
21 local preview = param.get("preview")
23 if #(slot.get_content("error")) > 0 then
24 preview = false
25 end
27 if policy_id then
28 policy = Policy:by_id(policy_id)
29 end
31 if issue_id then
32 execute.view {
33 module = "issue", view = "_head",
34 params = { issue = issue, member = app.session.member }
35 }
36 execute.view {
37 module = "issue", view = "_sidebar_state",
38 params = {
39 issue = issue
40 }
41 }
42 execute.view {
43 module = "issue", view = "_sidebar_issue",
44 params = {
45 issue = issue
46 }
47 }
48 else
49 execute.view {
50 module = "area", view = "_head",
51 params = { area = area, member = app.session.member }
52 }
53 execute.view {
54 module = "initiative", view = "_sidebar_policies",
55 params = {
56 area = area,
57 }
58 }
59 end
61 ui.form{
62 module = "initiative",
63 action = "create",
64 params = {
65 area_id = area.id,
66 issue_id = issue and issue.id or nil
67 },
68 attr = { class = "vertical" },
69 content = function()
71 if preview then
72 ui.section( function()
73 ui.sectionHead( function()
74 ui.heading{ level = 1, content = encode.html(param.get("name")) }
75 if not issue then
76 ui.container { content = policy.name }
77 end
78 if param.get("free_timing") then
79 ui.container { content = param.get("free_timing") }
80 end
81 slot.put("<br />")
83 ui.field.hidden{ name = "formatting_engine", value = param.get("formatting_engine") }
84 ui.field.hidden{ name = "policy_id", value = param.get("policy_id") }
85 ui.field.hidden{ name = "name", value = param.get("name") }
86 ui.field.hidden{ name = "draft", value = param.get("draft") }
87 ui.field.hidden{ name = "free_timing", value = param.get("free_timing") }
88 local formatting_engine
89 if config.enforce_formatting_engine then
90 formatting_engine = config.enforce_formatting_engine
91 else
92 formatting_engine = param.get("formatting_engine")
93 end
94 ui.container{
95 attr = { class = "draft_content wiki" },
96 content = function()
97 slot.put(format.wiki_text(param.get("draft"), formatting_engine))
98 end
99 }
100 slot.put("<br />")
102 ui.tag{
103 tag = "input",
104 attr = {
105 type = "submit",
106 class = "btn btn-default",
107 value = _'Publish now'
108 },
109 content = ""
110 }
111 slot.put("<br />")
112 slot.put("<br />")
113 ui.tag{
114 tag = "input",
115 attr = {
116 type = "submit",
117 name = "edit",
118 class = "btn-link",
119 value = _'Edit again'
120 },
121 content = ""
122 }
123 slot.put(" | ")
124 if issue then
125 ui.link{ content = _"Cancel", module = "issue", view = "show", id = issue.id }
126 else
127 ui.link{ content = _"Cancel", module = "area", view = "show", id = area.id }
128 end
129 end )
130 end )
131 else
134 execute.view{ module = "initiative", view = "_sidebar_wikisyntax" }
136 ui.section( function()
137 if preview then
138 ui.sectionHead( function()
139 ui.heading { level = 1, content = _"Edit again" }
140 end )
141 elseif issue_id then
142 ui.sectionHead( function()
143 ui.heading { level = 1, content = _"Add a new competing initiative to issue" }
144 end )
145 else
146 ui.sectionHead( function()
147 ui.heading { level = 1, content = _"Create a new issue" }
148 end )
149 end
151 ui.sectionRow( function()
152 if not preview and not issue_id then
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." }
154 slot.put("<br />")
155 end
156 if not issue_id then
157 tmp = { { id = -1, name = "" } }
158 for i, allowed_policy in ipairs(area.allowed_policies) do
159 if not allowed_policy.polling or app.session.member:has_polling_right_for_unit_id(area.unit_id) then
160 tmp[#tmp+1] = allowed_policy
161 end
162 end
163 ui.heading{ level = 2, content = _"Please choose a policy for the new issue:" }
164 ui.field.select{
165 name = "policy_id",
166 foreign_records = tmp,
167 foreign_id = "id",
168 foreign_name = "name",
169 value = param.get("policy_id", atom.integer) or area.default_policy and area.default_policy.id
170 }
171 if policy and policy.free_timeable then
172 local available_timings
173 if config.free_timing and config.free_timing.available_func then
174 available_timings = config.free_timing.available_func(policy)
175 if available_timings == false then
176 error("error in free timing config")
177 end
178 end
179 ui.heading{ level = 4, content = _"Free timing:" }
180 if available_timings then
181 ui.field.select{
182 name = "free_timing",
183 foreign_records = available_timings,
184 foreign_id = "id",
185 foreign_name = "name",
186 value = param.get("free_timing")
187 }
188 else
189 ui.field.text{
190 name = "free_timing",
191 value = param.get("free_timing")
192 }
193 end
194 end
195 end
197 if issue and issue.policy.polling and app.session.member:has_polling_right_for_unit_id(area.unit_id) then
198 slot.put("<br />")
199 ui.field.boolean{ name = "polling", label = _"No admission needed", value = polling }
200 end
202 slot.put("<br />")
203 ui.heading { level = 2, content = _"Enter a title for your initiative (max. 140 chars):" }
204 ui.field.text{
205 attr = { style = "width: 100%;" },
206 name = "name",
207 value = param.get("name")
208 }
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!" }
211 if not config.enforce_formatting_engine then
212 slot.put("<br />")
213 ui.heading { level = 4, content = _"Choose a formatting engine:" }
214 ui.field.select{
215 name = "formatting_engine",
216 foreign_records = config.formatting_engines,
217 attr = {id = "formatting_engine"},
218 foreign_id = "id",
219 foreign_name = "name",
220 value = param.get("formatting_engine")
221 }
222 end
223 slot.put("<br />")
225 ui.heading { level = 2, content = _"Enter your proposal and/or reasons:" }
226 ui.field.text{
227 name = "draft",
228 multiline = true,
229 attr = { style = "height: 50ex; width: 100%;" },
230 value = param.get("draft") or
231 [[
232 Proposal
233 ======
235 Replace me with your proposal.
238 Reasons
239 ======
241 Argument 1
242 ------
244 Replace me with your first argument
247 Argument 2
248 ------
250 Replace me with your second argument
252 ]]
253 }
254 if not issue or issue.state == "admission" or issue.state == "discussion" then
255 ui.container { content = _"You can change your text again anytime during admission and discussion phase" }
256 else
257 ui.container { content = _"You cannot change your text again later, because this issue is already in verfication phase!" }
258 end
259 slot.put("<br />")
260 ui.tag{
261 tag = "input",
262 attr = {
263 type = "submit",
264 name = "preview",
265 class = "btn btn-default",
266 value = _'Preview'
267 },
268 content = ""
269 }
270 slot.put("<br />")
271 slot.put("<br />")
273 if issue then
274 ui.link{ content = _"Cancel", module = "issue", view = "show", id = issue.id }
275 else
276 ui.link{ content = _"Cancel", module = "area", view = "show", id = area.id }
277 end
278 end )
279 end )
280 end
281 end
282 }