| 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@1045
 | 
    61 
 | 
| 
bsw@1045
 | 
    62 
 | 
| 
bsw@1045
 | 
    63 
 | 
| 
bsw@903
 | 
    64 
 | 
| 
bsw@903
 | 
    65 if not preview and not issue_id and app.session.member:has_polling_right_for_unit_id(area.unit_id) then
 | 
| 
bsw@901
 | 
    66   ui.actions(function()
 | 
| 
bsw@903
 | 
    67     ui.link{ 
 | 
| 
bsw@903
 | 
    68       text = _"Standard policies",
 | 
| 
bsw@903
 | 
    69       module = "initiative", view = "new", params = {
 | 
| 
bsw@903
 | 
    70         area_id = area.id
 | 
| 
bsw@903
 | 
    71       }
 | 
| 
bsw@903
 | 
    72     }
 | 
| 
bsw@901
 | 
    73     for i, policy in ipairs(area.allowed_policies) do
 | 
| 
bsw@901
 | 
    74       if policy.polling  then
 | 
| 
bsw@903
 | 
    75         slot.put(" · ")
 | 
| 
bsw@901
 | 
    76         ui.link{ 
 | 
| 
bsw@901
 | 
    77           text = policy.name,
 | 
| 
bsw@901
 | 
    78           module = "initiative", view = "new", params = {
 | 
| 
bsw@901
 | 
    79             area_id = area.id, policy_id = policy.id        
 | 
| 
bsw@901
 | 
    80           }
 | 
| 
bsw@901
 | 
    81         }
 | 
| 
bsw@901
 | 
    82       end
 | 
| 
bsw@901
 | 
    83     end
 | 
| 
bsw@901
 | 
    84   end)
 | 
| 
bsw@901
 | 
    85 end
 | 
| 
bsw@901
 | 
    86 
 | 
| 
bsw/jbe@0
 | 
    87 ui.form{
 | 
| 
bsw/jbe@0
 | 
    88   module = "initiative",
 | 
| 
bsw/jbe@0
 | 
    89   action = "create",
 | 
| 
bsw/jbe@0
 | 
    90   params = {
 | 
| 
bsw/jbe@0
 | 
    91     area_id = area.id,
 | 
| 
bsw/jbe@0
 | 
    92     issue_id = issue and issue.id or nil
 | 
| 
bsw/jbe@0
 | 
    93   },
 | 
| 
bsw/jbe@0
 | 
    94   attr = { class = "vertical" },
 | 
| 
bsw/jbe@0
 | 
    95   content = function()
 | 
| 
bsw@1045
 | 
    96   
 | 
| 
bsw@1045
 | 
    97     if preview then
 | 
| 
bsw@1045
 | 
    98       ui.section( function()
 | 
| 
bsw@1045
 | 
    99         ui.sectionHead( function()
 | 
| 
bsw@1045
 | 
   100           ui.heading{ level = 1, content = encode.html(param.get("name")) }
 | 
| 
bsw@1045
 | 
   101           if not issue then
 | 
| 
bsw@1045
 | 
   102             ui.container { content = policy.name }
 | 
| 
bsw@901
 | 
   103           end
 | 
| 
bsw@1045
 | 
   104           slot.put("<br />")
 | 
| 
bsw@1045
 | 
   105 
 | 
| 
bsw@1045
 | 
   106           ui.field.hidden{ name = "formatting_engine", value = param.get("formatting_engine") }
 | 
| 
bsw@1045
 | 
   107           ui.field.hidden{ name = "policy_id", value = param.get("policy_id") }
 | 
| 
bsw@1045
 | 
   108           ui.field.hidden{ name = "name", value = param.get("name") }
 | 
| 
bsw@1045
 | 
   109           ui.field.hidden{ name = "draft", value = param.get("draft") }
 | 
| 
bsw@1045
 | 
   110           local formatting_engine
 | 
| 
bsw@1045
 | 
   111           if config.enforce_formatting_engine then
 | 
| 
bsw@1045
 | 
   112             formatting_engine = config.enforce_formatting_engine
 | 
| 
bsw@1045
 | 
   113           else
 | 
| 
bsw@1045
 | 
   114             formatting_engine = param.get("formatting_engine")
 | 
| 
bsw@1045
 | 
   115           end
 | 
| 
bsw@1045
 | 
   116           ui.container{
 | 
| 
bsw@1045
 | 
   117             attr = { class = "draft_content wiki" },
 | 
| 
bsw@64
 | 
   118             content = function()
 | 
| 
bsw@1045
 | 
   119               slot.put(format.wiki_text(param.get("draft"), formatting_engine))
 | 
| 
bsw@64
 | 
   120             end
 | 
| 
bsw@64
 | 
   121           }
 | 
| 
bsw@1045
 | 
   122           slot.put("<br />")
 | 
| 
bsw@1045
 | 
   123 
 | 
| 
bsw@1045
 | 
   124           ui.tag{
 | 
| 
bsw@1045
 | 
   125             tag = "input",
 | 
| 
bsw@1045
 | 
   126             attr = {
 | 
| 
bsw@1045
 | 
   127               type = "submit",
 | 
| 
bsw@1045
 | 
   128               class = "btn btn-default",
 | 
| 
bsw@1045
 | 
   129               value = _'Publish now'
 | 
| 
bsw@1045
 | 
   130             },
 | 
| 
bsw@1045
 | 
   131             content = ""
 | 
| 
bsw@1045
 | 
   132           }
 | 
| 
bsw@1045
 | 
   133           slot.put("<br />")
 | 
| 
bsw@1045
 | 
   134           slot.put("<br />")
 | 
| 
bsw@1045
 | 
   135           ui.tag{
 | 
| 
bsw@1045
 | 
   136             tag = "input",
 | 
| 
bsw@1045
 | 
   137             attr = {
 | 
| 
bsw@1045
 | 
   138               type = "submit",
 | 
| 
bsw@1045
 | 
   139               name = "edit",
 | 
| 
bsw@1045
 | 
   140               class = "btn-link",
 | 
| 
bsw@1045
 | 
   141               value = _'Edit again'
 | 
| 
bsw@1045
 | 
   142             },
 | 
| 
bsw@1045
 | 
   143             content = ""
 | 
| 
bsw@1045
 | 
   144           }
 | 
| 
bsw@1045
 | 
   145           slot.put(" | ")
 | 
| 
bsw@1045
 | 
   146           if issue then
 | 
| 
bsw@1045
 | 
   147             ui.link{ content = _"Cancel", module = "issue", view = "show", id = issue.id }
 | 
| 
bsw@95
 | 
   148           else
 | 
| 
bsw@1045
 | 
   149             ui.link{ content = _"Cancel", module = "area", view = "show", id = area.id }
 | 
| 
bsw@95
 | 
   150           end
 | 
| 
bsw@1045
 | 
   151         end )
 | 
| 
bsw@1045
 | 
   152       end )
 | 
| 
bsw@1045
 | 
   153     else
 | 
| 
bsw@1045
 | 
   154       
 | 
| 
bsw@1045
 | 
   155      
 | 
| 
bsw@1045
 | 
   156       execute.view{ module = "initiative", view = "_sidebar_wikisyntax" }
 | 
| 
bsw@95
 | 
   157 
 | 
| 
bsw@1045
 | 
   158       ui.section( function()
 | 
| 
bsw@1045
 | 
   159         if preview then
 | 
| 
bsw@1045
 | 
   160           ui.sectionHead( function()
 | 
| 
bsw@1045
 | 
   161             ui.heading { level = 1, content = _"Edit again" }
 | 
| 
bsw@1045
 | 
   162           end )
 | 
| 
bsw@1045
 | 
   163         elseif issue_id then
 | 
| 
bsw@1045
 | 
   164           ui.sectionHead( function()
 | 
| 
bsw@1045
 | 
   165             ui.heading { level = 1, content = _"Add a new competing initiative to issue" }
 | 
| 
bsw@1045
 | 
   166           end )
 | 
| 
bsw@1045
 | 
   167         else
 | 
| 
bsw@1045
 | 
   168           ui.sectionHead( function()
 | 
| 
bsw@1045
 | 
   169             ui.heading { level = 1, content = _"Create a new issue" }
 | 
| 
bsw@1045
 | 
   170           end )
 | 
| 
bsw@1045
 | 
   171         end
 | 
| 
bsw@1045
 | 
   172       
 | 
| 
bsw@1045
 | 
   173         ui.sectionRow( function()
 | 
| 
bsw@1045
 | 
   174           if not preview and not issue_id then
 | 
| 
bsw@1045
 | 
   175             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
 | 
   176             slot.put("<br />")
 | 
| 
bsw@1045
 | 
   177           end
 | 
| 
bsw@1045
 | 
   178           if not issue_id then
 | 
| 
bsw@1045
 | 
   179             tmp = { { id = -1, name = "" } }
 | 
| 
bsw@1045
 | 
   180             for i, allowed_policy in ipairs(area.allowed_policies) do
 | 
| 
bsw@1045
 | 
   181               if not allowed_policy.polling then
 | 
| 
bsw@1045
 | 
   182                 tmp[#tmp+1] = allowed_policy
 | 
| 
bsw@1045
 | 
   183               end
 | 
| 
bsw@1045
 | 
   184             end
 | 
| 
bsw@1045
 | 
   185             ui.heading{ level = 2, content = _"Please choose a policy for the new issue:" }
 | 
| 
bsw@1045
 | 
   186             ui.field.select{
 | 
| 
bsw@1045
 | 
   187               name = "policy_id",
 | 
| 
bsw@1045
 | 
   188               foreign_records = tmp,
 | 
| 
bsw@1045
 | 
   189               foreign_id = "id",
 | 
| 
bsw@1045
 | 
   190               foreign_name = "name",
 | 
| 
bsw@1045
 | 
   191               value = param.get("policy_id", atom.integer) or area.default_policy and area.default_policy.id
 | 
| 
bsw@1045
 | 
   192             }
 | 
| 
bsw@1045
 | 
   193             if policy and policy.free_timeable then
 | 
| 
bsw@1045
 | 
   194               ui.sectionRow( function()
 | 
| 
bsw@1045
 | 
   195                 local available_timings
 | 
| 
bsw@1045
 | 
   196                 if config.free_timing and config.free_timing.available_func then
 | 
| 
bsw@1045
 | 
   197                   available_timings = config.free_timing.available_func(policy)
 | 
| 
bsw@1045
 | 
   198                   if available_timings == false then
 | 
| 
bsw@1045
 | 
   199                     error("error in free timing config")
 | 
| 
bsw@1045
 | 
   200                   end
 | 
| 
bsw@1045
 | 
   201                 end
 | 
| 
bsw@1045
 | 
   202                 ui.heading{ level = 4, content = _"Free timing:" }
 | 
| 
bsw@1045
 | 
   203                 if available_timings then
 | 
| 
bsw@1045
 | 
   204                   ui.field.select{
 | 
| 
bsw@1045
 | 
   205                     name = "free_timing",
 | 
| 
bsw@1045
 | 
   206                     foreign_records = available_timings,
 | 
| 
bsw@1045
 | 
   207                     foreign_id = "id",
 | 
| 
bsw@1045
 | 
   208                     foreign_name = "name",
 | 
| 
bsw@1045
 | 
   209                     value = param.get("free_timing")
 | 
| 
bsw@1045
 | 
   210                   }
 | 
| 
bsw@1045
 | 
   211                 else
 | 
| 
bsw@1045
 | 
   212                   ui.field.text{
 | 
| 
bsw@1045
 | 
   213                     name = "free_timing",
 | 
| 
bsw@1045
 | 
   214                     value = param.get("free_timing")
 | 
| 
bsw@1045
 | 
   215                   }
 | 
| 
bsw@1045
 | 
   216                 end
 | 
| 
bsw@1045
 | 
   217               end )
 | 
| 
bsw@1045
 | 
   218             end
 | 
| 
bsw@1045
 | 
   219           end
 | 
| 
bsw@1045
 | 
   220 
 | 
| 
bsw@1045
 | 
   221           if issue and issue.policy.polling and app.session.member:has_polling_right_for_unit_id(area.unit_id) then
 | 
| 
bsw@1045
 | 
   222             slot.put("<br />")
 | 
| 
bsw@1045
 | 
   223             ui.field.boolean{ name = "polling", label = _"No admission needed", value = polling }
 | 
| 
bsw@1045
 | 
   224           end
 | 
| 
bsw@1045
 | 
   225           
 | 
| 
bsw@1045
 | 
   226           slot.put("<br />")
 | 
| 
bsw@1045
 | 
   227           ui.heading { level = 2, content = _"Enter a title for your initiative (max. 140 chars):" }
 | 
| 
bsw@1045
 | 
   228           ui.field.text{
 | 
| 
bsw@1045
 | 
   229             attr = { style = "width: 100%;" },
 | 
| 
bsw@1045
 | 
   230             name  = "name",
 | 
| 
bsw@1045
 | 
   231             value = param.get("name")
 | 
| 
poelzi@133
 | 
   232           }
 | 
| 
bsw@1045
 | 
   233           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
 | 
   234           
 | 
| 
bsw@1045
 | 
   235           if not config.enforce_formatting_engine then
 | 
| 
bsw@1045
 | 
   236             slot.put("<br />")
 | 
| 
bsw@1045
 | 
   237             ui.heading { level = 4, content = _"Choose a formatting engine:" }
 | 
| 
bsw@1045
 | 
   238             ui.field.select{
 | 
| 
bsw@1045
 | 
   239               name = "formatting_engine",
 | 
| 
bsw@1045
 | 
   240               foreign_records = config.formatting_engines,
 | 
| 
bsw@1045
 | 
   241               attr = {id = "formatting_engine"},
 | 
| 
bsw@1045
 | 
   242               foreign_id = "id",
 | 
| 
bsw@1045
 | 
   243               foreign_name = "name",
 | 
| 
bsw@1045
 | 
   244               value = param.get("formatting_engine")
 | 
| 
bsw@1045
 | 
   245             }
 | 
| 
bsw@1045
 | 
   246           end
 | 
| 
bsw@1045
 | 
   247           slot.put("<br />")
 | 
| 
bsw@1045
 | 
   248 
 | 
| 
bsw@1045
 | 
   249           ui.heading { level = 2, content = _"Enter your proposal and/or reasons:" }
 | 
| 
bsw@1045
 | 
   250           ui.field.text{
 | 
| 
bsw@1045
 | 
   251             name = "draft",
 | 
| 
bsw@1045
 | 
   252             multiline = true, 
 | 
| 
bsw@1045
 | 
   253             attr = { style = "height: 50ex; width: 100%;" },
 | 
| 
bsw@1045
 | 
   254             value = param.get("draft") or
 | 
| 
bsw@1045
 | 
   255                 [[
 | 
| 
bsw@1045
 | 
   256 Proposal
 | 
| 
bsw@1045
 | 
   257 ======
 | 
| 
bsw@1045
 | 
   258 
 | 
| 
bsw@1045
 | 
   259 Replace me with your proposal.
 | 
| 
bsw@1045
 | 
   260 
 | 
| 
bsw@1045
 | 
   261 
 | 
| 
bsw@1045
 | 
   262 Reasons
 | 
| 
bsw@1045
 | 
   263 ======
 | 
| 
bsw@1045
 | 
   264 
 | 
| 
bsw@1045
 | 
   265 Argument 1
 | 
| 
bsw@1045
 | 
   266 ------
 | 
| 
bsw@1045
 | 
   267 
 | 
| 
bsw@1045
 | 
   268 Replace me with your first argument
 | 
| 
bsw@1045
 | 
   269 
 | 
| 
bsw@1045
 | 
   270 
 | 
| 
bsw@1045
 | 
   271 Argument 2
 | 
| 
bsw@1045
 | 
   272 ------
 | 
| 
bsw@1045
 | 
   273 
 | 
| 
bsw@1045
 | 
   274 Replace me with your second argument
 | 
| 
bsw@1045
 | 
   275 
 | 
| 
bsw@1045
 | 
   276 ]]
 | 
| 
bsw@1045
 | 
   277           }
 | 
| 
bsw@1045
 | 
   278           if not issue or issue.state == "admission" or issue.state == "discussion" then
 | 
| 
bsw@1045
 | 
   279             ui.container { content = _"You can change your text again anytime during admission and discussion phase" }
 | 
| 
bsw@1045
 | 
   280           else
 | 
| 
bsw@1045
 | 
   281             ui.container { content = _"You cannot change your text again later, because this issue is already in verfication phase!" }
 | 
| 
bsw@1045
 | 
   282           end
 | 
| 
bsw@1045
 | 
   283           slot.put("<br />")
 | 
| 
poelzi@133
 | 
   284           ui.tag{
 | 
| 
bsw@1045
 | 
   285             tag = "input",
 | 
| 
bsw@1045
 | 
   286             attr = {
 | 
| 
bsw@1045
 | 
   287               type = "submit",
 | 
| 
bsw@1045
 | 
   288               name = "preview",
 | 
| 
bsw@1045
 | 
   289               class = "btn btn-default",
 | 
| 
bsw@1045
 | 
   290               value = _'Preview'
 | 
| 
bsw@1045
 | 
   291             },
 | 
| 
bsw@1045
 | 
   292             content = ""
 | 
| 
poelzi@133
 | 
   293           }
 | 
| 
bsw@1045
 | 
   294           slot.put("<br />")
 | 
| 
bsw@1045
 | 
   295           slot.put("<br />")
 | 
| 
bsw@1045
 | 
   296           
 | 
| 
bsw@1045
 | 
   297           if issue then
 | 
| 
bsw@1045
 | 
   298             ui.link{ content = _"Cancel", module = "issue", view = "show", id = issue.id }
 | 
| 
bsw@1045
 | 
   299           else
 | 
| 
bsw@1045
 | 
   300             ui.link{ content = _"Cancel", module = "area", view = "show", id = area.id }
 | 
| 
bsw@1045
 | 
   301           end
 | 
| 
bsw@1045
 | 
   302         end )
 | 
| 
bsw@1045
 | 
   303       end )
 | 
| 
bsw@1045
 | 
   304     end
 | 
| 
bsw/jbe@0
 | 
   305   end
 | 
| 
bsw@907
 | 
   306 }
 |