| rev | 
   line source | 
| 
bsw/jbe@0
 | 
     1 local issue
 | 
| 
bsw/jbe@0
 | 
     2 local area
 | 
| 
bsw/jbe@0
 | 
     3 
 | 
| 
bsw/jbe@0
 | 
     4 local issue_id = param.get("issue_id", atom.integer)
 | 
| 
bsw/jbe@0
 | 
     5 if issue_id then
 | 
| 
bsw/jbe@0
 | 
     6   issue = Issue:new_selector():add_where{"id=?",issue_id}:single_object_mode():exec()
 | 
| 
bsw@1045
 | 
     7   issue:load_everything_for_member_id(app.session.member_id)
 | 
| 
bsw/jbe@0
 | 
     8   area = issue.area
 | 
| 
bsw/jbe@0
 | 
     9 
 | 
| 
bsw/jbe@0
 | 
    10 else
 | 
| 
bsw/jbe@0
 | 
    11   local area_id = param.get("area_id", atom.integer)
 | 
| 
bsw/jbe@0
 | 
    12   area = Area:new_selector():add_where{"id=?",area_id}:single_object_mode():exec()
 | 
| 
bsw@1045
 | 
    13   area:load_delegation_info_once_for_member_id(app.session.member_id)
 | 
| 
bsw/jbe@0
 | 
    14 end
 | 
| 
bsw/jbe@0
 | 
    15 
 | 
| 
bsw@904
 | 
    16 local polling = param.get("polling", atom.boolean)
 | 
| 
bsw@904
 | 
    17 
 | 
| 
bsw@901
 | 
    18 local policy_id = param.get("policy_id", atom.integer)
 | 
| 
bsw@901
 | 
    19 local policy
 | 
| 
bsw@901
 | 
    20 
 | 
| 
bsw@1045
 | 
    21 local preview = param.get("preview")
 | 
| 
bsw@1045
 | 
    22 
 | 
| 
bsw@1045
 | 
    23 if #(slot.get_content("error")) > 0 then
 | 
| 
bsw@1045
 | 
    24   preview = false
 | 
| 
bsw@1045
 | 
    25 end
 | 
| 
bsw@1045
 | 
    26 
 | 
| 
bsw@901
 | 
    27 if policy_id then
 | 
| 
bsw@901
 | 
    28   policy = Policy:by_id(policy_id)
 | 
| 
bsw@901
 | 
    29 end
 | 
| 
bsw@901
 | 
    30 
 | 
| 
bsw/jbe@0
 | 
    31 if issue_id then
 | 
| 
bsw@1045
 | 
    32   execute.view {
 | 
| 
bsw@1045
 | 
    33     module = "issue", view = "_head", 
 | 
| 
bsw@1045
 | 
    34     params = { issue = issue, member = app.session.member }
 | 
| 
bsw@1045
 | 
    35   }
 | 
| 
bsw@1045
 | 
    36   execute.view { 
 | 
| 
bsw@1045
 | 
    37     module = "issue", view = "_sidebar_state", 
 | 
| 
bsw@1045
 | 
    38     params = {
 | 
| 
bsw@1045
 | 
    39       issue = issue
 | 
| 
bsw@1045
 | 
    40     }
 | 
| 
bsw@1045
 | 
    41   }
 | 
| 
bsw@1045
 | 
    42   execute.view { 
 | 
| 
bsw@1045
 | 
    43     module = "issue", view = "_sidebar_issue", 
 | 
| 
bsw@1045
 | 
    44     params = {
 | 
| 
bsw@1045
 | 
    45       issue = issue
 | 
| 
bsw@1045
 | 
    46     }
 | 
| 
bsw@1045
 | 
    47   }
 | 
| 
bsw/jbe@0
 | 
    48 else
 | 
| 
bsw@1045
 | 
    49   execute.view {
 | 
| 
bsw@1045
 | 
    50     module = "area", view = "_head", 
 | 
| 
bsw@1045
 | 
    51     params = { area = area, member = app.session.member }
 | 
| 
bsw@1045
 | 
    52   }
 | 
| 
bsw@1045
 | 
    53   execute.view { 
 | 
| 
bsw@1045
 | 
    54     module = "initiative", view = "_sidebar_policies", 
 | 
| 
bsw@1045
 | 
    55     params = {
 | 
| 
bsw@1045
 | 
    56       area = area,
 | 
| 
bsw@1045
 | 
    57     }
 | 
| 
bsw@1045
 | 
    58   }
 | 
| 
bsw/jbe@0
 | 
    59 end
 | 
| 
bsw/jbe@0
 | 
    60 
 | 
| 
bsw/jbe@0
 | 
    61 ui.form{
 | 
| 
bsw/jbe@0
 | 
    62   module = "initiative",
 | 
| 
bsw/jbe@0
 | 
    63   action = "create",
 | 
| 
bsw/jbe@0
 | 
    64   params = {
 | 
| 
bsw/jbe@0
 | 
    65     area_id = area.id,
 | 
| 
bsw/jbe@0
 | 
    66     issue_id = issue and issue.id or nil
 | 
| 
bsw/jbe@0
 | 
    67   },
 | 
| 
bsw/jbe@0
 | 
    68   attr = { class = "vertical" },
 | 
| 
bsw/jbe@0
 | 
    69   content = function()
 | 
| 
bsw@1045
 | 
    70   
 | 
| 
bsw@1045
 | 
    71     if preview then
 | 
| 
bsw@1045
 | 
    72       ui.section( function()
 | 
| 
bsw@1045
 | 
    73         ui.sectionHead( function()
 | 
| 
bsw@1045
 | 
    74           ui.heading{ level = 1, content = encode.html(param.get("name")) }
 | 
| 
bsw@1045
 | 
    75           if not issue then
 | 
| 
bsw@1045
 | 
    76             ui.container { content = policy.name }
 | 
| 
bsw@901
 | 
    77           end
 | 
| 
bsw@1092
 | 
    78 	  if param.get("free_timing") then
 | 
| 
bsw@1092
 | 
    79 	    ui.container { content = param.get("free_timing") }
 | 
| 
bsw@1092
 | 
    80 	  end
 | 
| 
bsw@1045
 | 
    81           slot.put("<br />")
 | 
| 
bsw@1045
 | 
    82 
 | 
| 
bsw@1045
 | 
    83           ui.field.hidden{ name = "formatting_engine", value = param.get("formatting_engine") }
 | 
| 
bsw@1045
 | 
    84           ui.field.hidden{ name = "policy_id", value = param.get("policy_id") }
 | 
| 
bsw@1045
 | 
    85           ui.field.hidden{ name = "name", value = param.get("name") }
 | 
| 
bsw@1045
 | 
    86           ui.field.hidden{ name = "draft", value = param.get("draft") }
 | 
| 
bsw@1092
 | 
    87           ui.field.hidden{ name = "free_timing", value = param.get("free_timing") }
 | 
| 
bsw@1096
 | 
    88           ui.field.hidden{ name = "polling", value = param.get("polling", atom.boolean) }
 | 
| 
bsw@1045
 | 
    89           local formatting_engine
 | 
| 
bsw@1045
 | 
    90           if config.enforce_formatting_engine then
 | 
| 
bsw@1045
 | 
    91             formatting_engine = config.enforce_formatting_engine
 | 
| 
bsw@1045
 | 
    92           else
 | 
| 
bsw@1045
 | 
    93             formatting_engine = param.get("formatting_engine")
 | 
| 
bsw@1045
 | 
    94           end
 | 
| 
bsw@1045
 | 
    95           ui.container{
 | 
| 
bsw@1102
 | 
    96             attr = { class = "draft" },
 | 
| 
bsw@64
 | 
    97             content = function()
 | 
| 
bsw@1045
 | 
    98               slot.put(format.wiki_text(param.get("draft"), formatting_engine))
 | 
| 
bsw@64
 | 
    99             end
 | 
| 
bsw@64
 | 
   100           }
 | 
| 
bsw@1045
 | 
   101           slot.put("<br />")
 | 
| 
bsw@1045
 | 
   102 
 | 
| 
bsw@1045
 | 
   103           ui.tag{
 | 
| 
bsw@1045
 | 
   104             tag = "input",
 | 
| 
bsw@1045
 | 
   105             attr = {
 | 
| 
bsw@1045
 | 
   106               type = "submit",
 | 
| 
bsw@1045
 | 
   107               class = "btn btn-default",
 | 
| 
bsw@1045
 | 
   108               value = _'Publish now'
 | 
| 
bsw@1045
 | 
   109             },
 | 
| 
bsw@1045
 | 
   110             content = ""
 | 
| 
bsw@1045
 | 
   111           }
 | 
| 
bsw@1045
 | 
   112           slot.put("<br />")
 | 
| 
bsw@1045
 | 
   113           slot.put("<br />")
 | 
| 
bsw@1045
 | 
   114           ui.tag{
 | 
| 
bsw@1045
 | 
   115             tag = "input",
 | 
| 
bsw@1045
 | 
   116             attr = {
 | 
| 
bsw@1045
 | 
   117               type = "submit",
 | 
| 
bsw@1045
 | 
   118               name = "edit",
 | 
| 
bsw@1045
 | 
   119               class = "btn-link",
 | 
| 
bsw@1045
 | 
   120               value = _'Edit again'
 | 
| 
bsw@1045
 | 
   121             },
 | 
| 
bsw@1045
 | 
   122             content = ""
 | 
| 
bsw@1045
 | 
   123           }
 | 
| 
bsw@1045
 | 
   124           slot.put(" | ")
 | 
| 
bsw@1045
 | 
   125           if issue then
 | 
| 
bsw@1045
 | 
   126             ui.link{ content = _"Cancel", module = "issue", view = "show", id = issue.id }
 | 
| 
bsw@95
 | 
   127           else
 | 
| 
bsw@1045
 | 
   128             ui.link{ content = _"Cancel", module = "area", view = "show", id = area.id }
 | 
| 
bsw@95
 | 
   129           end
 | 
| 
bsw@1045
 | 
   130         end )
 | 
| 
bsw@1045
 | 
   131       end )
 | 
| 
bsw@1045
 | 
   132     else
 | 
| 
bsw@1045
 | 
   133       
 | 
| 
bsw@1045
 | 
   134      
 | 
| 
bsw@1045
 | 
   135       execute.view{ module = "initiative", view = "_sidebar_wikisyntax" }
 | 
| 
bsw@95
 | 
   136 
 | 
| 
bsw@1045
 | 
   137       ui.section( function()
 | 
| 
bsw@1045
 | 
   138         if preview then
 | 
| 
bsw@1045
 | 
   139           ui.sectionHead( function()
 | 
| 
bsw@1045
 | 
   140             ui.heading { level = 1, content = _"Edit again" }
 | 
| 
bsw@1045
 | 
   141           end )
 | 
| 
bsw@1045
 | 
   142         elseif issue_id then
 | 
| 
bsw@1045
 | 
   143           ui.sectionHead( function()
 | 
| 
bsw@1045
 | 
   144             ui.heading { level = 1, content = _"Add a new competing initiative to issue" }
 | 
| 
bsw@1045
 | 
   145           end )
 | 
| 
bsw@1045
 | 
   146         else
 | 
| 
bsw@1045
 | 
   147           ui.sectionHead( function()
 | 
| 
bsw@1045
 | 
   148             ui.heading { level = 1, content = _"Create a new issue" }
 | 
| 
bsw@1045
 | 
   149           end )
 | 
| 
bsw@1045
 | 
   150         end
 | 
| 
bsw@1045
 | 
   151       
 | 
| 
bsw@1045
 | 
   152         ui.sectionRow( function()
 | 
| 
bsw@1045
 | 
   153           if not preview and not issue_id then
 | 
| 
bsw@1045
 | 
   154             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
 | 
   155             slot.put("<br />")
 | 
| 
bsw@1045
 | 
   156           end
 | 
| 
bsw@1045
 | 
   157           if not issue_id then
 | 
| 
bsw@1045
 | 
   158             tmp = { { id = -1, name = "" } }
 | 
| 
bsw@1045
 | 
   159             for i, allowed_policy in ipairs(area.allowed_policies) do
 | 
| 
bsw@1091
 | 
   160               if not allowed_policy.polling or app.session.member:has_polling_right_for_unit_id(area.unit_id) then
 | 
| 
bsw@1045
 | 
   161                 tmp[#tmp+1] = allowed_policy
 | 
| 
bsw@1045
 | 
   162               end
 | 
| 
bsw@1045
 | 
   163             end
 | 
| 
bsw@1045
 | 
   164             ui.heading{ level = 2, content = _"Please choose a policy for the new issue:" }
 | 
| 
bsw@1045
 | 
   165             ui.field.select{
 | 
| 
bsw@1045
 | 
   166               name = "policy_id",
 | 
| 
bsw@1045
 | 
   167               foreign_records = tmp,
 | 
| 
bsw@1045
 | 
   168               foreign_id = "id",
 | 
| 
bsw@1045
 | 
   169               foreign_name = "name",
 | 
| 
bsw@1045
 | 
   170               value = param.get("policy_id", atom.integer) or area.default_policy and area.default_policy.id
 | 
| 
bsw@1045
 | 
   171             }
 | 
| 
bsw@1045
 | 
   172             if policy and policy.free_timeable then
 | 
| 
bsw@1092
 | 
   173 	      local available_timings
 | 
| 
bsw@1092
 | 
   174 	      if config.free_timing and config.free_timing.available_func then
 | 
| 
bsw@1092
 | 
   175 		available_timings = config.free_timing.available_func(policy)
 | 
| 
bsw@1092
 | 
   176 		if available_timings == false then
 | 
| 
bsw@1092
 | 
   177 		  error("error in free timing config")
 | 
| 
bsw@1092
 | 
   178 		end
 | 
| 
bsw@1092
 | 
   179 	      end
 | 
| 
bsw@1092
 | 
   180 	      ui.heading{ level = 4, content = _"Free timing:" }
 | 
| 
bsw@1092
 | 
   181 	      if available_timings then
 | 
| 
bsw@1092
 | 
   182 		ui.field.select{
 | 
| 
bsw@1092
 | 
   183 		  name = "free_timing",
 | 
| 
bsw@1092
 | 
   184 		  foreign_records = available_timings,
 | 
| 
bsw@1092
 | 
   185 		  foreign_id = "id",
 | 
| 
bsw@1092
 | 
   186 		  foreign_name = "name",
 | 
| 
bsw@1092
 | 
   187 		  value = param.get("free_timing")
 | 
| 
bsw@1092
 | 
   188 		}
 | 
| 
bsw@1092
 | 
   189 	      else
 | 
| 
bsw@1092
 | 
   190 		ui.field.text{
 | 
| 
bsw@1092
 | 
   191 		  name = "free_timing",
 | 
| 
bsw@1092
 | 
   192 		  value = param.get("free_timing")
 | 
| 
bsw@1092
 | 
   193 		}
 | 
| 
bsw@1092
 | 
   194 	      end
 | 
| 
bsw@1045
 | 
   195             end
 | 
| 
bsw@1045
 | 
   196           end
 | 
| 
bsw@1045
 | 
   197 
 | 
| 
bsw@1045
 | 
   198           if issue and issue.policy.polling and app.session.member:has_polling_right_for_unit_id(area.unit_id) then
 | 
| 
bsw@1045
 | 
   199             slot.put("<br />")
 | 
| 
bsw@1045
 | 
   200             ui.field.boolean{ name = "polling", label = _"No admission needed", value = polling }
 | 
| 
bsw@1045
 | 
   201           end
 | 
| 
bsw@1045
 | 
   202           
 | 
| 
bsw@1045
 | 
   203           slot.put("<br />")
 | 
| 
bsw@1045
 | 
   204           ui.heading { level = 2, content = _"Enter a title for your initiative (max. 140 chars):" }
 | 
| 
bsw@1045
 | 
   205           ui.field.text{
 | 
| 
bsw@1045
 | 
   206             attr = { style = "width: 100%;" },
 | 
| 
bsw@1045
 | 
   207             name  = "name",
 | 
| 
bsw@1045
 | 
   208             value = param.get("name")
 | 
| 
poelzi@133
 | 
   209           }
 | 
| 
bsw@1045
 | 
   210           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
 | 
   211           
 | 
| 
bsw@1045
 | 
   212           if not config.enforce_formatting_engine then
 | 
| 
bsw@1045
 | 
   213             slot.put("<br />")
 | 
| 
bsw@1045
 | 
   214             ui.heading { level = 4, content = _"Choose a formatting engine:" }
 | 
| 
bsw@1045
 | 
   215             ui.field.select{
 | 
| 
bsw@1045
 | 
   216               name = "formatting_engine",
 | 
| 
bsw@1045
 | 
   217               foreign_records = config.formatting_engines,
 | 
| 
bsw@1045
 | 
   218               attr = {id = "formatting_engine"},
 | 
| 
bsw@1045
 | 
   219               foreign_id = "id",
 | 
| 
bsw@1045
 | 
   220               foreign_name = "name",
 | 
| 
bsw@1045
 | 
   221               value = param.get("formatting_engine")
 | 
| 
bsw@1045
 | 
   222             }
 | 
| 
bsw@1045
 | 
   223           end
 | 
| 
bsw@1045
 | 
   224           slot.put("<br />")
 | 
| 
bsw@1045
 | 
   225 
 | 
| 
bsw@1045
 | 
   226           ui.heading { level = 2, content = _"Enter your proposal and/or reasons:" }
 | 
| 
bsw@1045
 | 
   227           ui.field.text{
 | 
| 
bsw@1045
 | 
   228             name = "draft",
 | 
| 
bsw@1045
 | 
   229             multiline = true, 
 | 
| 
bsw@1045
 | 
   230             attr = { style = "height: 50ex; width: 100%;" },
 | 
| 
bsw@1124
 | 
   231             value = param.get("draft") or config.draft_template or [[
 | 
| 
bsw@1045
 | 
   232 Proposal
 | 
| 
bsw@1045
 | 
   233 ======
 | 
| 
bsw@1045
 | 
   234 
 | 
| 
bsw@1045
 | 
   235 Replace me with your proposal.
 | 
| 
bsw@1045
 | 
   236 
 | 
| 
bsw@1045
 | 
   237 
 | 
| 
bsw@1045
 | 
   238 Reasons
 | 
| 
bsw@1045
 | 
   239 ======
 | 
| 
bsw@1045
 | 
   240 
 | 
| 
bsw@1045
 | 
   241 Argument 1
 | 
| 
bsw@1045
 | 
   242 ------
 | 
| 
bsw@1045
 | 
   243 
 | 
| 
bsw@1045
 | 
   244 Replace me with your first argument
 | 
| 
bsw@1045
 | 
   245 
 | 
| 
bsw@1045
 | 
   246 
 | 
| 
bsw@1045
 | 
   247 Argument 2
 | 
| 
bsw@1045
 | 
   248 ------
 | 
| 
bsw@1045
 | 
   249 
 | 
| 
bsw@1045
 | 
   250 Replace me with your second argument
 | 
| 
bsw@1045
 | 
   251 
 | 
| 
bsw@1045
 | 
   252 ]]
 | 
| 
bsw@1045
 | 
   253           }
 | 
| 
bsw@1045
 | 
   254           if not issue or issue.state == "admission" or issue.state == "discussion" then
 | 
| 
bsw@1045
 | 
   255             ui.container { content = _"You can change your text again anytime during admission and discussion phase" }
 | 
| 
bsw@1045
 | 
   256           else
 | 
| 
bsw@1045
 | 
   257             ui.container { content = _"You cannot change your text again later, because this issue is already in verfication phase!" }
 | 
| 
bsw@1045
 | 
   258           end
 | 
| 
bsw@1045
 | 
   259           slot.put("<br />")
 | 
| 
poelzi@133
 | 
   260           ui.tag{
 | 
| 
bsw@1045
 | 
   261             tag = "input",
 | 
| 
bsw@1045
 | 
   262             attr = {
 | 
| 
bsw@1045
 | 
   263               type = "submit",
 | 
| 
bsw@1045
 | 
   264               name = "preview",
 | 
| 
bsw@1045
 | 
   265               class = "btn btn-default",
 | 
| 
bsw@1045
 | 
   266               value = _'Preview'
 | 
| 
bsw@1045
 | 
   267             },
 | 
| 
bsw@1045
 | 
   268             content = ""
 | 
| 
poelzi@133
 | 
   269           }
 | 
| 
bsw@1045
 | 
   270           slot.put("<br />")
 | 
| 
bsw@1045
 | 
   271           slot.put("<br />")
 | 
| 
bsw@1045
 | 
   272           
 | 
| 
bsw@1045
 | 
   273           if issue then
 | 
| 
bsw@1045
 | 
   274             ui.link{ content = _"Cancel", module = "issue", view = "show", id = issue.id }
 | 
| 
bsw@1045
 | 
   275           else
 | 
| 
bsw@1045
 | 
   276             ui.link{ content = _"Cancel", module = "area", view = "show", id = area.id }
 | 
| 
bsw@1045
 | 
   277           end
 | 
| 
bsw@1045
 | 
   278         end )
 | 
| 
bsw@1045
 | 
   279       end )
 | 
| 
bsw@1045
 | 
   280     end
 | 
| 
bsw/jbe@0
 | 
   281   end
 | 
| 
bsw@907
 | 
   282 }
 |