liquid_feedback_frontend
view app/main/draft/new.lua @ 1135:abee3e49cd44
Initiatives cannot be updated during verification phase
| author | bsw | 
|---|---|
| date | Tue Jan 27 12:07:58 2015 +0100 (2015-01-27) | 
| parents | 701a5cf6b067 | 
| children | 77412cc23325 | 
 line source
     1 local initiative = Initiative:by_id(param.get("initiative_id"))
     2 initiative:load_everything_for_member_id(app.session.member_id)
     3 initiative.issue:load_everything_for_member_id(app.session.member_id)
     5 if issue.closed then
     6   slot.put_into("error", _"This issue is already closed.")
     7   request.redirect{ module = "initiative", view = "show", id = initiative.id }
     8   return
     9 elseif issue.half_frozen then 
    10   slot.put_into("error", _"This issue is already frozen.")
    11   request.redirect{ module = "initiative", view = "show", id = initiative.id }
    12   return
    13 elseif issue.phase_finished then
    14   slot.put_into("error", _"Current phase is already closed.")
    15   request.redirect{ module = "initiative", view = "show", id = initiative.id }
    16   return
    17 end
    20 execute.view{
    21   module = "issue", view = "_head", params = {
    22     issue = initiative.issue,
    23     initiative = initiative
    24   }
    25 }
    27 execute.view { 
    28   module = "issue", view = "_sidebar_issue", 
    29   params = {
    30     issue = initiative.issue,
    31   }
    32 }
    36 ui.form{
    37   record = initiative.current_draft,
    38   attr = { class = "vertical section" },
    39   module = "draft",
    40   action = "add",
    41   params = { initiative_id = initiative.id },
    42   routing = {
    43     ok = {
    44       mode = "redirect",
    45       module = "initiative",
    46       view = "show",
    47       id = initiative.id
    48     }
    49   },
    50   content = function()
    52     ui.sectionHead( function()
    53       ui.heading { level = 1, content = initiative.display_name }
    54     end)
    56     if param.get("preview") then
    57       ui.sectionRow( function()
    58         ui.field.hidden{ name = "formatting_engine", value = param.get("formatting_engine") }
    59         ui.field.hidden{ name = "content", value = param.get("content") }
    60         if config.enforce_formatting_engine then
    61           formatting_engine = config.enforce_formatting_engine
    62         else
    63           formatting_engine = param.get("formatting_engine")
    64         end
    65         ui.container{
    66           attr = { class = "draft" },
    67           content = function()
    68             slot.put(format.wiki_text(param.get("content"), formatting_engine))
    69           end
    70         }
    72         slot.put("<br />")
    73         ui.tag{
    74           tag = "input",
    75           attr = {
    76             type = "submit",
    77             class = "btn btn-default",
    78             value = _'Publish now'
    79           },
    80           content = ""
    81         }
    82         slot.put("<br />")
    83         slot.put("<br />")
    85         ui.tag{
    86           tag = "input",
    87           attr = {
    88             type = "submit",
    89             name = "edit",
    90             class = "btn-link",
    91             value = _'Edit again'
    92           },
    93           content = ""
    94         }
    95         slot.put(" | ")
    96         ui.link{
    97           content = _"Cancel",
    98           module = "initiative",
    99           view = "show",
   100           id = initiative.id
   101         }
   102       end )
   104     else
   105       ui.sectionRow( function()
   106         execute.view{ module = "initiative", view = "_sidebar_wikisyntax" }
   108         if not config.enforce_formatting_engine then
   109           ui.field.select{
   110             label = _"Wiki engine",
   111             name = "formatting_engine",
   112             foreign_records = config.formatting_engines,
   113             attr = {id = "formatting_engine"},
   114             foreign_id = "id",
   115             foreign_name = "name"
   116           }
   117         end
   119         ui.heading{ level = 2, content = _"Enter your proposal and/or reasons" }
   121         ui.field.text{
   122           name = "content",
   123           multiline = true,
   124           attr = { style = "height: 50ex; width: 100%;" },
   125           value = param.get("content")
   126         }
   127         ui.tag{
   128           tag = "input",
   129           attr = {
   130             type = "submit",
   131             name = "preview",
   132             class = "btn btn-default",
   133             value = _'Preview'
   134           },
   135           content = ""
   136         }
   137         slot.put("<br />")
   138         slot.put("<br />")
   140         ui.link{
   141           content = _"Cancel",
   142           module = "initiative",
   143           view = "show",
   144           id = initiative.id
   145         }
   147       end )
   148     end
   149   end
   150 }
