liquid_feedback_frontend
diff app/main/initiative/new.lua @ 1045:701a5cf6b067
Imported LiquidFeedback Frontend 3.0 branch
| author | bsw |
|---|---|
| date | Thu Jul 10 01:19:48 2014 +0200 (2014-07-10) |
| parents | 319161d5a904 |
| children | 20680a81c3e1 |
line diff
1.1 --- a/app/main/initiative/new.lua Thu Jul 10 01:02:43 2014 +0200 1.2 +++ b/app/main/initiative/new.lua Thu Jul 10 01:19:48 2014 +0200 1.3 @@ -4,11 +4,13 @@ 1.4 local issue_id = param.get("issue_id", atom.integer) 1.5 if issue_id then 1.6 issue = Issue:new_selector():add_where{"id=?",issue_id}:single_object_mode():exec() 1.7 + issue:load_everything_for_member_id(app.session.member_id) 1.8 area = issue.area 1.9 1.10 else 1.11 local area_id = param.get("area_id", atom.integer) 1.12 area = Area:new_selector():add_where{"id=?",area_id}:single_object_mode():exec() 1.13 + area:load_delegation_info_once_for_member_id(app.session.member_id) 1.14 end 1.15 1.16 local polling = param.get("polling", atom.boolean) 1.17 @@ -16,17 +18,49 @@ 1.18 local policy_id = param.get("policy_id", atom.integer) 1.19 local policy 1.20 1.21 +local preview = param.get("preview") 1.22 + 1.23 +if #(slot.get_content("error")) > 0 then 1.24 + preview = false 1.25 +end 1.26 + 1.27 if policy_id then 1.28 policy = Policy:by_id(policy_id) 1.29 end 1.30 1.31 if issue_id then 1.32 - ui.title(_"Add alternative initiative to issue") 1.33 + execute.view { 1.34 + module = "issue", view = "_head", 1.35 + params = { issue = issue, member = app.session.member } 1.36 + } 1.37 + execute.view { 1.38 + module = "issue", view = "_sidebar_state", 1.39 + params = { 1.40 + issue = issue 1.41 + } 1.42 + } 1.43 + execute.view { 1.44 + module = "issue", view = "_sidebar_issue", 1.45 + params = { 1.46 + issue = issue 1.47 + } 1.48 + } 1.49 else 1.50 - ui.title(_"Create new issue") 1.51 + execute.view { 1.52 + module = "area", view = "_head", 1.53 + params = { area = area, member = app.session.member } 1.54 + } 1.55 + execute.view { 1.56 + module = "initiative", view = "_sidebar_policies", 1.57 + params = { 1.58 + area = area, 1.59 + } 1.60 + } 1.61 end 1.62 1.63 -local preview = param.get("preview") 1.64 + 1.65 + 1.66 + 1.67 1.68 if not preview and not issue_id and app.session.member:has_polling_right_for_unit_id(area.unit_id) then 1.69 ui.actions(function() 1.70 @@ -59,181 +93,214 @@ 1.71 }, 1.72 attr = { class = "vertical" }, 1.73 content = function() 1.74 - ui.field.text{ label = _"Unit", value = area.unit.name } 1.75 - ui.field.text{ label = _"Area", value = area.name } 1.76 - slot.put("<br />") 1.77 - if issue_id then 1.78 - ui.field.text{ label = _"Issue", value = issue_id } 1.79 - elseif policy then 1.80 - ui.field.hidden{ name = "policy_id", value = policy.id } 1.81 - ui.field.text{ label = _"Policy", value = policy.name } 1.82 - if policy.free_timeable then 1.83 - local available_timings 1.84 - if config.free_timing and config.free_timing.available_func then 1.85 - available_timings = config.free_timing.available_func(policy) 1.86 - if available_timings == false then 1.87 - error("error in free timing config") 1.88 + 1.89 + if preview then 1.90 + ui.section( function() 1.91 + ui.sectionHead( function() 1.92 + ui.heading{ level = 1, content = encode.html(param.get("name")) } 1.93 + if not issue then 1.94 + ui.container { content = policy.name } 1.95 end 1.96 - end 1.97 - if available_timings then 1.98 - ui.field.select{ 1.99 - label = _"Free timing", 1.100 - name = "free_timing", 1.101 - foreign_records = available_timings, 1.102 - foreign_id = "id", 1.103 - foreign_name = "name", 1.104 - value = param.get("free_timing") 1.105 - } 1.106 - else 1.107 - ui.field.text{ label = _"Free timing", name = "free_timing", value = param.get("free_timing") } 1.108 - end 1.109 - end 1.110 - else 1.111 - tmp = { { id = -1, name = _"Please choose a policy" } } 1.112 - for i, allowed_policy in ipairs(area.allowed_policies) do 1.113 - if not allowed_policy.polling then 1.114 - tmp[#tmp+1] = allowed_policy 1.115 - end 1.116 - end 1.117 - ui.field.select{ 1.118 - label = _"Policy", 1.119 - name = "policy_id", 1.120 - foreign_records = tmp, 1.121 - foreign_id = "id", 1.122 - foreign_name = "name", 1.123 - value = param.get("policy_id", atom.integer) or area.default_policy and area.default_policy.id 1.124 - } 1.125 - ui.tag{ 1.126 - tag = "div", 1.127 - content = function() 1.128 - ui.tag{ 1.129 - tag = "label", 1.130 - attr = { class = "ui_field_label" }, 1.131 - content = function() slot.put(" ") end, 1.132 - } 1.133 - ui.tag{ 1.134 + slot.put("<br />") 1.135 + 1.136 + ui.field.hidden{ name = "formatting_engine", value = param.get("formatting_engine") } 1.137 + ui.field.hidden{ name = "policy_id", value = param.get("policy_id") } 1.138 + ui.field.hidden{ name = "name", value = param.get("name") } 1.139 + ui.field.hidden{ name = "draft", value = param.get("draft") } 1.140 + local formatting_engine 1.141 + if config.enforce_formatting_engine then 1.142 + formatting_engine = config.enforce_formatting_engine 1.143 + else 1.144 + formatting_engine = param.get("formatting_engine") 1.145 + end 1.146 + ui.container{ 1.147 + attr = { class = "draft_content wiki" }, 1.148 content = function() 1.149 - ui.link{ 1.150 - text = _"Information about the available policies", 1.151 - module = "policy", 1.152 - view = "list" 1.153 - } 1.154 - slot.put(" ") 1.155 - ui.link{ 1.156 - attr = { target = "_blank" }, 1.157 - text = _"(new window)", 1.158 - module = "policy", 1.159 - view = "list" 1.160 - } 1.161 + slot.put(format.wiki_text(param.get("draft"), formatting_engine)) 1.162 end 1.163 } 1.164 - end 1.165 - } 1.166 - end 1.167 - 1.168 - if issue and issue.policy.polling and app.session.member:has_polling_right_for_unit_id(area.unit_id) then 1.169 - ui.field.boolean{ name = "polling", label = _"No admission needed", value = polling } 1.170 - end 1.171 - 1.172 - if preview then 1.173 - ui.heading{ level = 1, content = encode.html(param.get("name")) } 1.174 - local discussion_url = param.get("discussion_url") 1.175 - ui.container{ 1.176 - attr = { class = "ui_field_label" }, 1.177 - content = _"Discussion with initiators" 1.178 - } 1.179 - ui.tag{ 1.180 - tag = "span", 1.181 - content = function() 1.182 - if discussion_url:find("^https?://") then 1.183 - if discussion_url and #discussion_url > 0 then 1.184 - ui.link{ 1.185 - attr = { 1.186 - class = "actions", 1.187 - target = "_blank", 1.188 - title = discussion_url 1.189 - }, 1.190 - content = discussion_url, 1.191 - external = discussion_url 1.192 - } 1.193 - end 1.194 + slot.put("<br />") 1.195 + 1.196 + ui.tag{ 1.197 + tag = "input", 1.198 + attr = { 1.199 + type = "submit", 1.200 + class = "btn btn-default", 1.201 + value = _'Publish now' 1.202 + }, 1.203 + content = "" 1.204 + } 1.205 + slot.put("<br />") 1.206 + slot.put("<br />") 1.207 + ui.tag{ 1.208 + tag = "input", 1.209 + attr = { 1.210 + type = "submit", 1.211 + name = "edit", 1.212 + class = "btn-link", 1.213 + value = _'Edit again' 1.214 + }, 1.215 + content = "" 1.216 + } 1.217 + slot.put(" | ") 1.218 + if issue then 1.219 + ui.link{ content = _"Cancel", module = "issue", view = "show", id = issue.id } 1.220 else 1.221 - slot.put(encode.html(discussion_url)) 1.222 + ui.link{ content = _"Cancel", module = "area", view = "show", id = area.id } 1.223 end 1.224 - end 1.225 - } 1.226 - ui.container{ 1.227 - attr = { class = "draft_content wiki" }, 1.228 - content = function() 1.229 - slot.put(format.wiki_text(param.get("draft"), param.get("formatting_engine"))) 1.230 - end 1.231 - } 1.232 - slot.put("<br />") 1.233 - ui.submit{ text = _"Save" } 1.234 - slot.put("<br />") 1.235 - slot.put("<br />") 1.236 - end 1.237 - slot.put("<br />") 1.238 + end ) 1.239 + end ) 1.240 + else 1.241 + 1.242 + 1.243 + execute.view{ module = "initiative", view = "_sidebar_wikisyntax" } 1.244 1.245 - ui.field.text{ 1.246 - label = _"Title of initiative", 1.247 - name = "name", 1.248 - value = param.get("name") 1.249 - } 1.250 - ui.field.text{ 1.251 - label = _"Discussion URL", 1.252 - name = "discussion_url", 1.253 - value = param.get("discussion_url") 1.254 - } 1.255 - ui.field.select{ 1.256 - label = _"Wiki engine", 1.257 - name = "formatting_engine", 1.258 - foreign_records = { 1.259 - { id = "rocketwiki", name = "RocketWiki" }, 1.260 - { id = "compat", name = _"Traditional wiki syntax" } 1.261 - }, 1.262 - attr = {id = "formatting_engine"}, 1.263 - foreign_id = "id", 1.264 - foreign_name = "name", 1.265 - value = param.get("formatting_engine") 1.266 - } 1.267 - ui.tag{ 1.268 - tag = "div", 1.269 - content = function() 1.270 - ui.tag{ 1.271 - tag = "label", 1.272 - attr = { class = "ui_field_label" }, 1.273 - content = function() slot.put(" ") end, 1.274 + ui.section( function() 1.275 + if preview then 1.276 + ui.sectionHead( function() 1.277 + ui.heading { level = 1, content = _"Edit again" } 1.278 + end ) 1.279 + elseif issue_id then 1.280 + ui.sectionHead( function() 1.281 + ui.heading { level = 1, content = _"Add a new competing initiative to issue" } 1.282 + end ) 1.283 + else 1.284 + ui.sectionHead( function() 1.285 + ui.heading { level = 1, content = _"Create a new issue" } 1.286 + end ) 1.287 + end 1.288 + 1.289 + ui.sectionRow( function() 1.290 + if not preview and not issue_id then 1.291 + ui.container { attr = { class = "section" }, content = _"Before creating a new issue, please check any existant issues before, if the topic is already in discussion." } 1.292 + slot.put("<br />") 1.293 + end 1.294 + if not issue_id then 1.295 + tmp = { { id = -1, name = "" } } 1.296 + for i, allowed_policy in ipairs(area.allowed_policies) do 1.297 + if not allowed_policy.polling then 1.298 + tmp[#tmp+1] = allowed_policy 1.299 + end 1.300 + end 1.301 + ui.heading{ level = 2, content = _"Please choose a policy for the new issue:" } 1.302 + ui.field.select{ 1.303 + name = "policy_id", 1.304 + foreign_records = tmp, 1.305 + foreign_id = "id", 1.306 + foreign_name = "name", 1.307 + value = param.get("policy_id", atom.integer) or area.default_policy and area.default_policy.id 1.308 + } 1.309 + if policy and policy.free_timeable then 1.310 + ui.sectionRow( function() 1.311 + local available_timings 1.312 + if config.free_timing and config.free_timing.available_func then 1.313 + available_timings = config.free_timing.available_func(policy) 1.314 + if available_timings == false then 1.315 + error("error in free timing config") 1.316 + end 1.317 + end 1.318 + ui.heading{ level = 4, content = _"Free timing:" } 1.319 + if available_timings then 1.320 + ui.field.select{ 1.321 + name = "free_timing", 1.322 + foreign_records = available_timings, 1.323 + foreign_id = "id", 1.324 + foreign_name = "name", 1.325 + value = param.get("free_timing") 1.326 + } 1.327 + else 1.328 + ui.field.text{ 1.329 + name = "free_timing", 1.330 + value = param.get("free_timing") 1.331 + } 1.332 + end 1.333 + end ) 1.334 + end 1.335 + end 1.336 + 1.337 + if issue and issue.policy.polling and app.session.member:has_polling_right_for_unit_id(area.unit_id) then 1.338 + slot.put("<br />") 1.339 + ui.field.boolean{ name = "polling", label = _"No admission needed", value = polling } 1.340 + end 1.341 + 1.342 + slot.put("<br />") 1.343 + ui.heading { level = 2, content = _"Enter a title for your initiative (max. 140 chars):" } 1.344 + ui.field.text{ 1.345 + attr = { style = "width: 100%;" }, 1.346 + name = "name", 1.347 + value = param.get("name") 1.348 } 1.349 + 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!" } 1.350 + 1.351 + if not config.enforce_formatting_engine then 1.352 + slot.put("<br />") 1.353 + ui.heading { level = 4, content = _"Choose a formatting engine:" } 1.354 + ui.field.select{ 1.355 + name = "formatting_engine", 1.356 + foreign_records = config.formatting_engines, 1.357 + attr = {id = "formatting_engine"}, 1.358 + foreign_id = "id", 1.359 + foreign_name = "name", 1.360 + value = param.get("formatting_engine") 1.361 + } 1.362 + end 1.363 + slot.put("<br />") 1.364 + 1.365 + ui.heading { level = 2, content = _"Enter your proposal and/or reasons:" } 1.366 + ui.field.text{ 1.367 + name = "draft", 1.368 + multiline = true, 1.369 + attr = { style = "height: 50ex; width: 100%;" }, 1.370 + value = param.get("draft") or 1.371 + [[ 1.372 +Proposal 1.373 +====== 1.374 + 1.375 +Replace me with your proposal. 1.376 + 1.377 + 1.378 +Reasons 1.379 +====== 1.380 + 1.381 +Argument 1 1.382 +------ 1.383 + 1.384 +Replace me with your first argument 1.385 + 1.386 + 1.387 +Argument 2 1.388 +------ 1.389 + 1.390 +Replace me with your second argument 1.391 + 1.392 +]] 1.393 + } 1.394 + if not issue or issue.state == "admission" or issue.state == "discussion" then 1.395 + ui.container { content = _"You can change your text again anytime during admission and discussion phase" } 1.396 + else 1.397 + ui.container { content = _"You cannot change your text again later, because this issue is already in verfication phase!" } 1.398 + end 1.399 + slot.put("<br />") 1.400 ui.tag{ 1.401 - content = function() 1.402 - ui.link{ 1.403 - text = _"Syntax help", 1.404 - module = "help", 1.405 - view = "show", 1.406 - id = "wikisyntax", 1.407 - attr = {onClick="this.href=this.href.replace(/wikisyntax[^.]*/g, 'wikisyntax_'+getElementById('formatting_engine').value)"} 1.408 - } 1.409 - slot.put(" ") 1.410 - ui.link{ 1.411 - text = _"(new window)", 1.412 - module = "help", 1.413 - view = "show", 1.414 - id = "wikisyntax", 1.415 - attr = {target = "_blank", onClick="this.href=this.href.replace(/wikisyntax[^.]*/g, 'wikisyntax_'+getElementById('formatting_engine').value)"} 1.416 - } 1.417 - end 1.418 + tag = "input", 1.419 + attr = { 1.420 + type = "submit", 1.421 + name = "preview", 1.422 + class = "btn btn-default", 1.423 + value = _'Preview' 1.424 + }, 1.425 + content = "" 1.426 } 1.427 - end 1.428 - } 1.429 - ui.field.text{ 1.430 - label = _"Draft", 1.431 - name = "draft", 1.432 - multiline = true, 1.433 - attr = { style = "height: 50ex;" }, 1.434 - value = param.get("draft") 1.435 - } 1.436 - ui.submit{ name = "preview", text = _"Preview" } 1.437 - ui.submit{ text = _"Save" } 1.438 + slot.put("<br />") 1.439 + slot.put("<br />") 1.440 + 1.441 + if issue then 1.442 + ui.link{ content = _"Cancel", module = "issue", view = "show", id = issue.id } 1.443 + else 1.444 + ui.link{ content = _"Cancel", module = "area", view = "show", id = area.id } 1.445 + end 1.446 + end ) 1.447 + end ) 1.448 + end 1.449 end 1.450 }