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@1045: issue:load_everything_for_member_id(app.session.member_id)
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@1045: area:load_delegation_info_once_for_member_id(app.session.member_id)
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@1045: local preview = param.get("preview")
bsw@1045:
bsw@1045: if #(slot.get_content("error")) > 0 then
bsw@1045: preview = false
bsw@1045: end
bsw@1045:
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@1045: execute.view {
bsw@1045: module = "issue", view = "_head",
bsw@1045: params = { issue = issue, member = app.session.member }
bsw@1045: }
bsw@1045: execute.view {
bsw@1045: module = "issue", view = "_sidebar_state",
bsw@1045: params = {
bsw@1045: issue = issue
bsw@1045: }
bsw@1045: }
bsw@1045: execute.view {
bsw@1045: module = "issue", view = "_sidebar_issue",
bsw@1045: params = {
bsw@1045: issue = issue
bsw@1045: }
bsw@1045: }
bsw/jbe@0: else
bsw@1045: execute.view {
bsw@1045: module = "area", view = "_head",
bsw@1045: params = { area = area, member = app.session.member }
bsw@1045: }
bsw@1045: execute.view {
bsw@1045: module = "initiative", view = "_sidebar_policies",
bsw@1045: params = {
bsw@1045: area = area,
bsw@1045: }
bsw@1045: }
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@1045:
bsw@1045: if preview then
bsw@1045: ui.section( function()
bsw@1045: ui.sectionHead( function()
bsw@1045: ui.heading{ level = 1, content = encode.html(param.get("name")) }
bsw@1045: if not issue then
bsw@1045: ui.container { content = policy.name }
bsw@901: end
bsw@1092: if param.get("free_timing") then
bsw@1092: ui.container { content = param.get("free_timing") }
bsw@1092: end
bsw@1045: slot.put("
")
bsw@1045:
bsw@1045: ui.field.hidden{ name = "formatting_engine", value = param.get("formatting_engine") }
bsw@1045: ui.field.hidden{ name = "policy_id", value = param.get("policy_id") }
bsw@1045: ui.field.hidden{ name = "name", value = param.get("name") }
bsw@1045: ui.field.hidden{ name = "draft", value = param.get("draft") }
bsw@1092: ui.field.hidden{ name = "free_timing", value = param.get("free_timing") }
bsw@1096: ui.field.hidden{ name = "polling", value = param.get("polling", atom.boolean) }
bsw@1045: local formatting_engine
bsw@1045: if config.enforce_formatting_engine then
bsw@1045: formatting_engine = config.enforce_formatting_engine
bsw@1045: else
bsw@1045: formatting_engine = param.get("formatting_engine")
bsw@1045: end
bsw@1045: ui.container{
bsw@1102: attr = { class = "draft" },
bsw@64: content = function()
bsw@1045: slot.put(format.wiki_text(param.get("draft"), formatting_engine))
bsw@64: end
bsw@64: }
bsw@1045: slot.put("
")
bsw@1045:
bsw@1045: ui.tag{
bsw@1045: tag = "input",
bsw@1045: attr = {
bsw@1045: type = "submit",
bsw@1045: class = "btn btn-default",
bsw@1045: value = _'Publish now'
bsw@1045: },
bsw@1045: content = ""
bsw@1045: }
bsw@1045: slot.put("
")
bsw@1045: slot.put("
")
bsw@1045: ui.tag{
bsw@1045: tag = "input",
bsw@1045: attr = {
bsw@1045: type = "submit",
bsw@1045: name = "edit",
bsw@1045: class = "btn-link",
bsw@1045: value = _'Edit again'
bsw@1045: },
bsw@1045: content = ""
bsw@1045: }
bsw@1045: slot.put(" | ")
bsw@1045: if issue then
bsw@1045: ui.link{ content = _"Cancel", module = "issue", view = "show", id = issue.id }
bsw@95: else
bsw@1045: ui.link{ content = _"Cancel", module = "area", view = "show", id = area.id }
bsw@95: end
bsw@1045: end )
bsw@1045: end )
bsw@1045: else
bsw@1045:
bsw@1045:
bsw@1045: execute.view{ module = "initiative", view = "_sidebar_wikisyntax" }
bsw@95:
bsw@1045: ui.section( function()
bsw@1045: if preview then
bsw@1045: ui.sectionHead( function()
bsw@1045: ui.heading { level = 1, content = _"Edit again" }
bsw@1045: end )
bsw@1045: elseif issue_id then
bsw@1045: ui.sectionHead( function()
bsw@1045: ui.heading { level = 1, content = _"Add a new competing initiative to issue" }
bsw@1045: end )
bsw@1045: else
bsw@1045: ui.sectionHead( function()
bsw@1045: ui.heading { level = 1, content = _"Create a new issue" }
bsw@1045: end )
bsw@1045: end
bsw@1045:
bsw@1045: ui.sectionRow( function()
bsw@1045: if not preview and not issue_id then
bsw@1045: ui.container { attr = { class = "section" }, content = _"Before creating a new issue, please check any existant issues before, if the topic is already in discussion." }
bsw@1045: slot.put("
")
bsw@1045: end
bsw@1045: if not issue_id then
bsw@1045: tmp = { { id = -1, name = "" } }
bsw@1045: for i, allowed_policy in ipairs(area.allowed_policies) do
bsw@1091: if not allowed_policy.polling or app.session.member:has_polling_right_for_unit_id(area.unit_id) then
bsw@1045: tmp[#tmp+1] = allowed_policy
bsw@1045: end
bsw@1045: end
bsw@1045: ui.heading{ level = 2, content = _"Please choose a policy for the new issue:" }
bsw@1045: ui.field.select{
bsw@1045: name = "policy_id",
bsw@1045: foreign_records = tmp,
bsw@1045: foreign_id = "id",
bsw@1045: foreign_name = "name",
bsw@1045: value = param.get("policy_id", atom.integer) or area.default_policy and area.default_policy.id
bsw@1045: }
bsw@1045: if policy and policy.free_timeable then
bsw@1092: local available_timings
bsw@1092: if config.free_timing and config.free_timing.available_func then
bsw@1092: available_timings = config.free_timing.available_func(policy)
bsw@1092: if available_timings == false then
bsw@1092: error("error in free timing config")
bsw@1092: end
bsw@1092: end
bsw@1092: ui.heading{ level = 4, content = _"Free timing:" }
bsw@1092: if available_timings then
bsw@1092: ui.field.select{
bsw@1092: name = "free_timing",
bsw@1092: foreign_records = available_timings,
bsw@1092: foreign_id = "id",
bsw@1092: foreign_name = "name",
bsw@1092: value = param.get("free_timing")
bsw@1092: }
bsw@1092: else
bsw@1092: ui.field.text{
bsw@1092: name = "free_timing",
bsw@1092: value = param.get("free_timing")
bsw@1092: }
bsw@1092: end
bsw@1045: end
bsw@1045: end
bsw@1045:
bsw@1045: if issue and issue.policy.polling and app.session.member:has_polling_right_for_unit_id(area.unit_id) then
bsw@1045: slot.put("
")
bsw@1045: ui.field.boolean{ name = "polling", label = _"No admission needed", value = polling }
bsw@1045: end
bsw@1045:
bsw@1045: slot.put("
")
bsw@1045: ui.heading { level = 2, content = _"Enter a title for your initiative (max. 140 chars):" }
bsw@1045: ui.field.text{
bsw@1045: attr = { style = "width: 100%;" },
bsw@1045: name = "name",
bsw@1045: value = param.get("name")
poelzi@133: }
bsw@1045: 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!" }
bsw@1045:
bsw@1045: if not config.enforce_formatting_engine then
bsw@1045: slot.put("
")
bsw@1045: ui.heading { level = 4, content = _"Choose a formatting engine:" }
bsw@1045: ui.field.select{
bsw@1045: name = "formatting_engine",
bsw@1045: foreign_records = config.formatting_engines,
bsw@1045: attr = {id = "formatting_engine"},
bsw@1045: foreign_id = "id",
bsw@1045: foreign_name = "name",
bsw@1045: value = param.get("formatting_engine")
bsw@1045: }
bsw@1045: end
bsw@1045: slot.put("
")
bsw@1045:
bsw@1045: ui.heading { level = 2, content = _"Enter your proposal and/or reasons:" }
bsw@1045: ui.field.text{
bsw@1045: name = "draft",
bsw@1045: multiline = true,
bsw@1045: attr = { style = "height: 50ex; width: 100%;" },
bsw@1124: value = param.get("draft") or config.draft_template or [[
bsw@1045: Proposal
bsw@1045: ======
bsw@1045:
bsw@1045: Replace me with your proposal.
bsw@1045:
bsw@1045:
bsw@1045: Reasons
bsw@1045: ======
bsw@1045:
bsw@1045: Argument 1
bsw@1045: ------
bsw@1045:
bsw@1045: Replace me with your first argument
bsw@1045:
bsw@1045:
bsw@1045: Argument 2
bsw@1045: ------
bsw@1045:
bsw@1045: Replace me with your second argument
bsw@1045:
bsw@1045: ]]
bsw@1045: }
bsw@1045: if not issue or issue.state == "admission" or issue.state == "discussion" then
bsw@1045: ui.container { content = _"You can change your text again anytime during admission and discussion phase" }
bsw@1045: else
bsw@1045: ui.container { content = _"You cannot change your text again later, because this issue is already in verfication phase!" }
bsw@1045: end
bsw@1045: slot.put("
")
poelzi@133: ui.tag{
bsw@1045: tag = "input",
bsw@1045: attr = {
bsw@1045: type = "submit",
bsw@1045: name = "preview",
bsw@1045: class = "btn btn-default",
bsw@1045: value = _'Preview'
bsw@1045: },
bsw@1045: content = ""
poelzi@133: }
bsw@1045: slot.put("
")
bsw@1045: slot.put("
")
bsw@1045:
bsw@1045: if issue then
bsw@1045: ui.link{ content = _"Cancel", module = "issue", view = "show", id = issue.id }
bsw@1045: else
bsw@1045: ui.link{ content = _"Cancel", module = "area", view = "show", id = area.id }
bsw@1045: end
bsw@1045: end )
bsw@1045: end )
bsw@1045: end
bsw/jbe@0: end
bsw@907: }