liquid_feedback_frontend
view app/main/initiative/new.lua @ 131:adc1b0554667
add make file to generate html help files
| author | Daniel Poelzleithner <poelzi@poelzi.org> | 
|---|---|
| date | Tue Oct 05 14:28:37 2010 +0200 (2010-10-05) | 
| parents | 6a12fb7e4963 | 
| children | fa55c8ded9fd | 
 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   area = issue.area
     9 else
    10   local area_id = param.get("area_id", atom.integer)
    11   area = Area:new_selector():add_where{"id=?",area_id}:single_object_mode():exec()
    12 end
    14 if issue_id then
    15   slot.put_into("title", _"Add alternative initiative to issue")
    16 else
    17   slot.put_into("title", _"Create new issue")
    18 end
    20 ui.form{
    21   module = "initiative",
    22   action = "create",
    23   params = {
    24     area_id = area.id,
    25     issue_id = issue and issue.id or nil
    26   },
    27   attr = { class = "vertical" },
    28   content = function()
    29     ui.field.text{ label = _"Area",  value = area.name }
    30     slot.put("<br />")
    31     if issue_id then
    32       ui.field.text{ label = _"Issue",  value = issue_id }
    33     else
    34       tmp = { { id = -1, name = _"Please choose a policy" } }
    35       for i, allowed_policy in ipairs(area.allowed_policies) do
    36         tmp[#tmp+1] = allowed_policy
    37       end
    38       ui.field.select{
    39         label = _"Policy",
    40         name = "policy_id",
    41         foreign_records = tmp,
    42         foreign_id = "id",
    43         foreign_name = "name",
    44         value = area.default_policy and area.default_policy.id or param.get("policy_id", atom.integer)
    45       }
    46       ui.tag{
    47         tag = "div",
    48         content = function()
    49           ui.tag{
    50             tag = "label",
    51             attr = { class = "ui_field_label" },
    52             content = function() slot.put(" ") end,
    53           }
    54           ui.tag{
    55             content = function()
    56               ui.link{
    57                 text = _"Information about the available policies",
    58                 module = "policy",
    59                 view = "list"
    60               }
    61               slot.put(" ")
    62               ui.link{
    63                 attr = { target = "_blank" },
    64                 text = _"(new window)",
    65                 module = "policy",
    66                 view = "list"
    67               }
    68             end
    69           }
    70         end
    71       }
    72     end
    74     if param.get("preview") then
    75       ui.heading{ level = 1, content = encode.html(param.get("name")) }
    76       local discussion_url = param.get("discussion_url")
    77       ui.container{
    78         attr = { class = "ui_field_label" },
    79         content = _"Discussion with initiators"
    80       }
    81       ui.tag{
    82         tag = "span",
    83         content = function()
    84           if discussion_url:find("^https?://") then
    85             if discussion_url and #discussion_url > 0 then
    86               ui.link{
    87                 attr = {
    88                   class = "actions",
    89                   target = "_blank",
    90                   title = discussion_url
    91                 },
    92                 content = discussion_url,
    93                 external = discussion_url
    94               }
    95             end
    96           else
    97             slot.put(encode.html(discussion_url))
    98           end
    99         end
   100       }
   101       ui.container{
   102         attr = { class = "draft_content wiki" },
   103         content = function()
   104           slot.put(format.wiki_text(param.get("draft"), param.get("formatting_engine")))
   105         end
   106       }
   107       slot.put("<br />")
   108       ui.submit{ text = _"Save" }
   109       slot.put("<br />")
   110       slot.put("<br />")
   111     end
   112     slot.put("<br />")
   114     ui.field.text{
   115       label = _"Title of initiative",
   116       name  = "name",
   117       value = param.get("name")
   118     }
   119     ui.field.text{
   120       label = _"Discussion URL",
   121       name = "discussion_url",
   122       value = param.get("discussion_url")
   123     }
   124     ui.field.select{
   125       label = _"Wiki engine",
   126       name = "formatting_engine",
   127       foreign_records = {
   128         { id = "rocketwiki", name = "RocketWiki" },
   129         { id = "compat", name = _"Traditional wiki syntax" }
   130       },
   131       foreign_id = "id",
   132       foreign_name = "name",
   133       value = param.get("formatting_engine")
   134     }
   135     ui.field.text{
   136       label = _"Draft",
   137       name = "draft",
   138       multiline = true, 
   139       attr = { style = "height: 50ex;" },
   140       value = param.get("draft")
   141     }
   142     ui.submit{ name = "preview", text = _"Preview" }
   143     ui.submit{ text = _"Save" }
   144   end
   145 }
