bsw/jbe@0: local issue bsw/jbe@0: local area bsw/jbe@0: bsw/jbe@0: local issue_id = param.get("issue_id", atom.integer) bsw/jbe@0: if issue_id then bsw/jbe@0: issue = Issue:new_selector():add_where{"id=?",issue_id}:single_object_mode():exec() bsw/jbe@0: area = issue.area bsw/jbe@0: bsw/jbe@0: else bsw/jbe@0: local area_id = param.get("area_id", atom.integer) bsw/jbe@0: area = Area:new_selector():add_where{"id=?",area_id}:single_object_mode():exec() bsw/jbe@0: end bsw/jbe@0: bsw@904: local polling = param.get("polling", atom.boolean) bsw@904: bsw@901: local policy_id = param.get("policy_id", atom.integer) bsw@901: local policy bsw@901: bsw@901: if policy_id then bsw@901: policy = Policy:by_id(policy_id) bsw@901: end bsw@901: bsw/jbe@0: if issue_id then bsw@564: ui.title(_"Add alternative initiative to issue") bsw/jbe@0: else bsw@564: ui.title(_"Create new issue") bsw/jbe@0: end bsw/jbe@0: bsw@903: local preview = param.get("preview") bsw@903: bsw@903: if not preview and not issue_id and app.session.member:has_polling_right_for_unit_id(area.unit_id) then bsw@901: ui.actions(function() bsw@903: ui.link{ bsw@903: text = _"Standard policies", bsw@903: module = "initiative", view = "new", params = { bsw@903: area_id = area.id bsw@903: } bsw@903: } bsw@901: for i, policy in ipairs(area.allowed_policies) do bsw@901: if policy.polling then bsw@903: slot.put(" · ") bsw@901: ui.link{ bsw@901: text = policy.name, bsw@901: module = "initiative", view = "new", params = { bsw@901: area_id = area.id, policy_id = policy.id bsw@901: } bsw@901: } bsw@901: end bsw@901: end bsw@901: end) bsw@901: end bsw@901: bsw/jbe@0: ui.form{ bsw/jbe@0: module = "initiative", bsw/jbe@0: action = "create", bsw/jbe@0: params = { bsw/jbe@0: area_id = area.id, bsw/jbe@0: issue_id = issue and issue.id or nil bsw/jbe@0: }, bsw/jbe@0: attr = { class = "vertical" }, bsw/jbe@0: content = function() bsw@278: ui.field.text{ label = _"Unit", value = area.unit.name } bsw/jbe@0: ui.field.text{ label = _"Area", value = area.name } bsw/jbe@52: slot.put("
") bsw/jbe@0: if issue_id then bsw/jbe@0: ui.field.text{ label = _"Issue", value = issue_id } bsw@904: elseif policy then bsw@901: ui.field.hidden{ name = "policy_id", value = policy.id } bsw@901: ui.field.text{ label = _"Policy", value = policy.name } bsw@901: if policy.free_timeable then bsw@901: local available_timings bsw@901: if config.free_timing and config.free_timing.available_func then bsw@901: available_timings = config.free_timing.available_func(policy) bsw@901: if available_timings == false then bsw@901: error("error in free timing config") bsw@901: end bsw@901: end bsw@901: if available_timings then bsw@901: ui.field.select{ bsw@901: label = _"Free timing", bsw@907: name = "free_timing", bsw@901: foreign_records = available_timings, bsw@901: foreign_id = "id", bsw@903: foreign_name = "name", bsw@903: value = param.get("free_timing") bsw@901: } bsw@901: else bsw@903: ui.field.text{ label = _"Free timing", name = "free_timing", value = param.get("free_timing") } bsw@901: end bsw@901: end bsw/jbe@0: else bsw@10: tmp = { { id = -1, name = _"Please choose a policy" } } bsw@10: for i, allowed_policy in ipairs(area.allowed_policies) do bsw@904: if not allowed_policy.polling then bsw@898: tmp[#tmp+1] = allowed_policy bsw@898: end bsw@10: end bsw/jbe@0: ui.field.select{ bsw/jbe@0: label = _"Policy", bsw/jbe@0: name = "policy_id", bsw@10: foreign_records = tmp, bsw/jbe@0: foreign_id = "id", bsw@7: foreign_name = "name", bsw@578: value = param.get("policy_id", atom.integer) or area.default_policy and area.default_policy.id bsw/jbe@0: } bsw@64: ui.tag{ bsw@64: tag = "div", bsw@64: content = function() bsw@64: ui.tag{ bsw@64: tag = "label", bsw@64: attr = { class = "ui_field_label" }, bsw@64: content = function() slot.put(" ") end, bsw@64: } bsw@64: ui.tag{ bsw@64: content = function() bsw@64: ui.link{ bsw@64: text = _"Information about the available policies", bsw@64: module = "policy", bsw@64: view = "list" bsw@64: } bsw@64: slot.put(" ") bsw@64: ui.link{ bsw@64: attr = { target = "_blank" }, bsw@64: text = _"(new window)", bsw@64: module = "policy", bsw@64: view = "list" bsw@64: } bsw@64: end bsw@64: } bsw@64: end bsw@64: } bsw/jbe@0: end bsw@95: bsw@898: if issue and issue.policy.polling and app.session.member:has_polling_right_for_unit_id(area.unit_id) then bsw@907: ui.field.boolean{ name = "polling", label = _"No admission needed", value = polling } bsw@898: end bsw@898: bsw@903: if preview then bsw@95: ui.heading{ level = 1, content = encode.html(param.get("name")) } bsw@95: local discussion_url = param.get("discussion_url") bsw@95: ui.container{ bsw@95: attr = { class = "ui_field_label" }, bsw@95: content = _"Discussion with initiators" bsw@95: } bsw@95: ui.tag{ bsw@95: tag = "span", bsw@95: content = function() bsw@95: if discussion_url:find("^https?://") then bsw@95: if discussion_url and #discussion_url > 0 then bsw@95: ui.link{ bsw@95: attr = { bsw@95: class = "actions", bsw@95: target = "_blank", bsw@95: title = discussion_url bsw@95: }, bsw@95: content = discussion_url, bsw@95: external = discussion_url bsw@95: } bsw@95: end bsw@95: else bsw@95: slot.put(encode.html(discussion_url)) bsw@95: end bsw@95: end bsw@95: } bsw@95: ui.container{ bsw@95: attr = { class = "draft_content wiki" }, bsw@95: content = function() bsw@95: slot.put(format.wiki_text(param.get("draft"), param.get("formatting_engine"))) bsw@95: end bsw@95: } bsw@95: slot.put("
") bsw@95: ui.submit{ text = _"Save" } bsw@95: slot.put("
") bsw@95: slot.put("
") bsw@95: end bsw/jbe@52: slot.put("
") bsw@95: bsw@95: ui.field.text{ bsw@95: label = _"Title of initiative", bsw@95: name = "name", bsw@95: value = param.get("name") bsw@95: } bsw@95: ui.field.text{ bsw@95: label = _"Discussion URL", bsw@95: name = "discussion_url", bsw@95: value = param.get("discussion_url") bsw@95: } bsw/jbe@4: ui.field.select{ bsw/jbe@4: label = _"Wiki engine", bsw/jbe@4: name = "formatting_engine", bsw/jbe@4: foreign_records = { bsw/jbe@4: { id = "rocketwiki", name = "RocketWiki" }, bsw/jbe@4: { id = "compat", name = _"Traditional wiki syntax" } bsw/jbe@4: }, poelzi@133: attr = {id = "formatting_engine"}, bsw/jbe@4: foreign_id = "id", bsw@95: foreign_name = "name", bsw@95: value = param.get("formatting_engine") bsw/jbe@4: } poelzi@133: ui.tag{ poelzi@133: tag = "div", poelzi@133: content = function() poelzi@133: ui.tag{ poelzi@133: tag = "label", poelzi@133: attr = { class = "ui_field_label" }, poelzi@133: content = function() slot.put(" ") end, poelzi@133: } poelzi@133: ui.tag{ poelzi@133: content = function() poelzi@133: ui.link{ poelzi@133: text = _"Syntax help", poelzi@133: module = "help", poelzi@133: view = "show", poelzi@133: id = "wikisyntax", poelzi@133: attr = {onClick="this.href=this.href.replace(/wikisyntax[^.]*/g, 'wikisyntax_'+getElementById('formatting_engine').value)"} poelzi@133: } poelzi@133: slot.put(" ") poelzi@133: ui.link{ poelzi@133: text = _"(new window)", poelzi@133: module = "help", poelzi@133: view = "show", poelzi@133: id = "wikisyntax", poelzi@133: attr = {target = "_blank", onClick="this.href=this.href.replace(/wikisyntax[^.]*/g, 'wikisyntax_'+getElementById('formatting_engine').value)"} poelzi@133: } poelzi@133: end poelzi@133: } poelzi@133: end poelzi@133: } bsw@95: ui.field.text{ bsw@95: label = _"Draft", bsw@95: name = "draft", bsw@95: multiline = true, bsw@95: attr = { style = "height: 50ex;" }, bsw@95: value = param.get("draft") bsw@95: } bsw@95: ui.submit{ name = "preview", text = _"Preview" } bsw/jbe@0: ui.submit{ text = _"Save" } bsw/jbe@0: end bsw@907: }