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/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/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/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@10: tmp[#tmp+1] = allowed_policy
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@95: if param.get("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/jbe@0: }