liquid_feedback_frontend

view app/main/initiative/new.lua @ 907:319161d5a904

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

Impressum / About Us