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/jbe@0
|
7 area = issue.area
|
bsw/jbe@0
|
8
|
bsw/jbe@0
|
9 else
|
bsw/jbe@0
|
10 local area_id = param.get("area_id", atom.integer)
|
bsw/jbe@0
|
11 area = Area:new_selector():add_where{"id=?",area_id}:single_object_mode():exec()
|
bsw/jbe@0
|
12 end
|
bsw/jbe@0
|
13
|
bsw@901
|
14 local policy_id = param.get("policy_id", atom.integer)
|
bsw@901
|
15 local policy
|
bsw@901
|
16
|
bsw@901
|
17 if policy_id then
|
bsw@901
|
18 policy = Policy:by_id(policy_id)
|
bsw@901
|
19 end
|
bsw@901
|
20
|
bsw/jbe@0
|
21 if issue_id then
|
bsw@564
|
22 ui.title(_"Add alternative initiative to issue")
|
bsw/jbe@0
|
23 else
|
bsw@564
|
24 ui.title(_"Create new issue")
|
bsw/jbe@0
|
25 end
|
bsw/jbe@0
|
26
|
bsw@903
|
27 local preview = param.get("preview")
|
bsw@903
|
28
|
bsw@903
|
29 if not preview and not issue_id and app.session.member:has_polling_right_for_unit_id(area.unit_id) then
|
bsw@901
|
30 ui.actions(function()
|
bsw@903
|
31 ui.link{
|
bsw@903
|
32 text = _"Standard policies",
|
bsw@903
|
33 module = "initiative", view = "new", params = {
|
bsw@903
|
34 area_id = area.id
|
bsw@903
|
35 }
|
bsw@903
|
36 }
|
bsw@901
|
37 for i, policy in ipairs(area.allowed_policies) do
|
bsw@901
|
38 if policy.polling then
|
bsw@903
|
39 slot.put(" · ")
|
bsw@901
|
40 ui.link{
|
bsw@901
|
41 text = policy.name,
|
bsw@901
|
42 module = "initiative", view = "new", params = {
|
bsw@901
|
43 area_id = area.id, policy_id = policy.id
|
bsw@901
|
44 }
|
bsw@901
|
45 }
|
bsw@901
|
46 end
|
bsw@901
|
47 end
|
bsw@901
|
48 end)
|
bsw@901
|
49 end
|
bsw@901
|
50
|
bsw/jbe@0
|
51 ui.form{
|
bsw/jbe@0
|
52 module = "initiative",
|
bsw/jbe@0
|
53 action = "create",
|
bsw/jbe@0
|
54 params = {
|
bsw/jbe@0
|
55 area_id = area.id,
|
bsw/jbe@0
|
56 issue_id = issue and issue.id or nil
|
bsw/jbe@0
|
57 },
|
bsw/jbe@0
|
58 attr = { class = "vertical" },
|
bsw/jbe@0
|
59 content = function()
|
bsw@278
|
60 ui.field.text{ label = _"Unit", value = area.unit.name }
|
bsw/jbe@0
|
61 ui.field.text{ label = _"Area", value = area.name }
|
bsw/jbe@52
|
62 slot.put("<br />")
|
bsw/jbe@0
|
63 if issue_id then
|
bsw/jbe@0
|
64 ui.field.text{ label = _"Issue", value = issue_id }
|
bsw@901
|
65 elseif policy_id then
|
bsw@901
|
66 ui.field.hidden{ name = "policy_id", value = policy.id }
|
bsw@901
|
67 ui.field.text{ label = _"Policy", value = policy.name }
|
bsw@901
|
68 if policy.free_timeable then
|
bsw@901
|
69 local available_timings
|
bsw@901
|
70 if config.free_timing and config.free_timing.available_func then
|
bsw@901
|
71 available_timings = config.free_timing.available_func(policy)
|
bsw@901
|
72 if available_timings == false then
|
bsw@901
|
73 error("error in free timing config")
|
bsw@901
|
74 end
|
bsw@901
|
75 end
|
bsw@901
|
76 if available_timings then
|
bsw@901
|
77 ui.field.select{
|
bsw@901
|
78 label = _"Free timing",
|
bsw@901
|
79 name = _"free_timing",
|
bsw@901
|
80 foreign_records = available_timings,
|
bsw@901
|
81 foreign_id = "id",
|
bsw@903
|
82 foreign_name = "name",
|
bsw@903
|
83 value = param.get("free_timing")
|
bsw@901
|
84 }
|
bsw@901
|
85 else
|
bsw@903
|
86 ui.field.text{ label = _"Free timing", name = "free_timing", value = param.get("free_timing") }
|
bsw@901
|
87 end
|
bsw@901
|
88 end
|
bsw/jbe@0
|
89 else
|
bsw@10
|
90 tmp = { { id = -1, name = _"Please choose a policy" } }
|
bsw@10
|
91 for i, allowed_policy in ipairs(area.allowed_policies) do
|
bsw@898
|
92 if not allowed_policy.polling or app.session.member:has_polling_right_for_unit_id(area.unit_id) then
|
bsw@898
|
93 tmp[#tmp+1] = allowed_policy
|
bsw@898
|
94 end
|
bsw@10
|
95 end
|
bsw/jbe@0
|
96 ui.field.select{
|
bsw/jbe@0
|
97 label = _"Policy",
|
bsw/jbe@0
|
98 name = "policy_id",
|
bsw@10
|
99 foreign_records = tmp,
|
bsw/jbe@0
|
100 foreign_id = "id",
|
bsw@7
|
101 foreign_name = "name",
|
bsw@578
|
102 value = param.get("policy_id", atom.integer) or area.default_policy and area.default_policy.id
|
bsw/jbe@0
|
103 }
|
bsw@64
|
104 ui.tag{
|
bsw@64
|
105 tag = "div",
|
bsw@64
|
106 content = function()
|
bsw@64
|
107 ui.tag{
|
bsw@64
|
108 tag = "label",
|
bsw@64
|
109 attr = { class = "ui_field_label" },
|
bsw@64
|
110 content = function() slot.put(" ") end,
|
bsw@64
|
111 }
|
bsw@64
|
112 ui.tag{
|
bsw@64
|
113 content = function()
|
bsw@64
|
114 ui.link{
|
bsw@64
|
115 text = _"Information about the available policies",
|
bsw@64
|
116 module = "policy",
|
bsw@64
|
117 view = "list"
|
bsw@64
|
118 }
|
bsw@64
|
119 slot.put(" ")
|
bsw@64
|
120 ui.link{
|
bsw@64
|
121 attr = { target = "_blank" },
|
bsw@64
|
122 text = _"(new window)",
|
bsw@64
|
123 module = "policy",
|
bsw@64
|
124 view = "list"
|
bsw@64
|
125 }
|
bsw@64
|
126 end
|
bsw@64
|
127 }
|
bsw@64
|
128 end
|
bsw@64
|
129 }
|
bsw/jbe@0
|
130 end
|
bsw@95
|
131
|
bsw@898
|
132 if issue and issue.policy.polling and app.session.member:has_polling_right_for_unit_id(area.unit_id) then
|
bsw@898
|
133 ui.field.boolean{ name = "polling", label = _"Poll" }
|
bsw@898
|
134 end
|
bsw@898
|
135
|
bsw@903
|
136 if preview then
|
bsw@95
|
137 ui.heading{ level = 1, content = encode.html(param.get("name")) }
|
bsw@95
|
138 local discussion_url = param.get("discussion_url")
|
bsw@95
|
139 ui.container{
|
bsw@95
|
140 attr = { class = "ui_field_label" },
|
bsw@95
|
141 content = _"Discussion with initiators"
|
bsw@95
|
142 }
|
bsw@95
|
143 ui.tag{
|
bsw@95
|
144 tag = "span",
|
bsw@95
|
145 content = function()
|
bsw@95
|
146 if discussion_url:find("^https?://") then
|
bsw@95
|
147 if discussion_url and #discussion_url > 0 then
|
bsw@95
|
148 ui.link{
|
bsw@95
|
149 attr = {
|
bsw@95
|
150 class = "actions",
|
bsw@95
|
151 target = "_blank",
|
bsw@95
|
152 title = discussion_url
|
bsw@95
|
153 },
|
bsw@95
|
154 content = discussion_url,
|
bsw@95
|
155 external = discussion_url
|
bsw@95
|
156 }
|
bsw@95
|
157 end
|
bsw@95
|
158 else
|
bsw@95
|
159 slot.put(encode.html(discussion_url))
|
bsw@95
|
160 end
|
bsw@95
|
161 end
|
bsw@95
|
162 }
|
bsw@95
|
163 ui.container{
|
bsw@95
|
164 attr = { class = "draft_content wiki" },
|
bsw@95
|
165 content = function()
|
bsw@95
|
166 slot.put(format.wiki_text(param.get("draft"), param.get("formatting_engine")))
|
bsw@95
|
167 end
|
bsw@95
|
168 }
|
bsw@95
|
169 slot.put("<br />")
|
bsw@95
|
170 ui.submit{ text = _"Save" }
|
bsw@95
|
171 slot.put("<br />")
|
bsw@95
|
172 slot.put("<br />")
|
bsw@95
|
173 end
|
bsw/jbe@52
|
174 slot.put("<br />")
|
bsw@95
|
175
|
bsw@95
|
176 ui.field.text{
|
bsw@95
|
177 label = _"Title of initiative",
|
bsw@95
|
178 name = "name",
|
bsw@95
|
179 value = param.get("name")
|
bsw@95
|
180 }
|
bsw@95
|
181 ui.field.text{
|
bsw@95
|
182 label = _"Discussion URL",
|
bsw@95
|
183 name = "discussion_url",
|
bsw@95
|
184 value = param.get("discussion_url")
|
bsw@95
|
185 }
|
bsw/jbe@4
|
186 ui.field.select{
|
bsw/jbe@4
|
187 label = _"Wiki engine",
|
bsw/jbe@4
|
188 name = "formatting_engine",
|
bsw/jbe@4
|
189 foreign_records = {
|
bsw/jbe@4
|
190 { id = "rocketwiki", name = "RocketWiki" },
|
bsw/jbe@4
|
191 { id = "compat", name = _"Traditional wiki syntax" }
|
bsw/jbe@4
|
192 },
|
poelzi@133
|
193 attr = {id = "formatting_engine"},
|
bsw/jbe@4
|
194 foreign_id = "id",
|
bsw@95
|
195 foreign_name = "name",
|
bsw@95
|
196 value = param.get("formatting_engine")
|
bsw/jbe@4
|
197 }
|
poelzi@133
|
198 ui.tag{
|
poelzi@133
|
199 tag = "div",
|
poelzi@133
|
200 content = function()
|
poelzi@133
|
201 ui.tag{
|
poelzi@133
|
202 tag = "label",
|
poelzi@133
|
203 attr = { class = "ui_field_label" },
|
poelzi@133
|
204 content = function() slot.put(" ") end,
|
poelzi@133
|
205 }
|
poelzi@133
|
206 ui.tag{
|
poelzi@133
|
207 content = function()
|
poelzi@133
|
208 ui.link{
|
poelzi@133
|
209 text = _"Syntax help",
|
poelzi@133
|
210 module = "help",
|
poelzi@133
|
211 view = "show",
|
poelzi@133
|
212 id = "wikisyntax",
|
poelzi@133
|
213 attr = {onClick="this.href=this.href.replace(/wikisyntax[^.]*/g, 'wikisyntax_'+getElementById('formatting_engine').value)"}
|
poelzi@133
|
214 }
|
poelzi@133
|
215 slot.put(" ")
|
poelzi@133
|
216 ui.link{
|
poelzi@133
|
217 text = _"(new window)",
|
poelzi@133
|
218 module = "help",
|
poelzi@133
|
219 view = "show",
|
poelzi@133
|
220 id = "wikisyntax",
|
poelzi@133
|
221 attr = {target = "_blank", onClick="this.href=this.href.replace(/wikisyntax[^.]*/g, 'wikisyntax_'+getElementById('formatting_engine').value)"}
|
poelzi@133
|
222 }
|
poelzi@133
|
223 end
|
poelzi@133
|
224 }
|
poelzi@133
|
225 end
|
poelzi@133
|
226 }
|
bsw@95
|
227 ui.field.text{
|
bsw@95
|
228 label = _"Draft",
|
bsw@95
|
229 name = "draft",
|
bsw@95
|
230 multiline = true,
|
bsw@95
|
231 attr = { style = "height: 50ex;" },
|
bsw@95
|
232 value = param.get("draft")
|
bsw@95
|
233 }
|
bsw@95
|
234 ui.submit{ name = "preview", text = _"Preview" }
|
bsw/jbe@0
|
235 ui.submit{ text = _"Save" }
|
bsw/jbe@0
|
236 end
|
bsw/jbe@0
|
237 } |