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