liquid_feedback_frontend
view app/main/initiative/new.lua @ 139:bc2570b97c09
fix spelling
fixed bug #330
fixed bug #330
| author | Daniel Poelzleithner <poelzi@poelzi.org> | 
|---|---|
| date | Wed Oct 06 13:52:23 2010 +0200 (2010-10-06) | 
| parents | fa55c8ded9fd | 
| children | fecd4c13054a | 
 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       attr = {id = "formatting_engine"},
   132       foreign_id = "id",
   133       foreign_name = "name",
   134       value = param.get("formatting_engine")
   135     }
   136     ui.tag{
   137         tag = "div",
   138         content = function()
   139           ui.tag{
   140             tag = "label",
   141             attr = { class = "ui_field_label" },
   142             content = function() slot.put(" ") end,
   143           }
   144           ui.tag{
   145             content = function()
   146               ui.link{
   147                 text = _"Syntax help",
   148                 module = "help",
   149                 view = "show",
   150                 id = "wikisyntax",
   151                 attr = {onClick="this.href=this.href.replace(/wikisyntax[^.]*/g, 'wikisyntax_'+getElementById('formatting_engine').value)"}
   152               }
   153               slot.put(" ")
   154               ui.link{
   155                 text = _"(new window)",
   156                 module = "help",
   157                 view = "show",
   158                 id = "wikisyntax",
   159                 attr = {target = "_blank", onClick="this.href=this.href.replace(/wikisyntax[^.]*/g, 'wikisyntax_'+getElementById('formatting_engine').value)"}
   160               }
   161             end
   162           }
   163         end
   164       }
   165     ui.field.text{
   166       label = _"Draft",
   167       name = "draft",
   168       multiline = true, 
   169       attr = { style = "height: 50ex;" },
   170       value = param.get("draft")
   171     }
   172     ui.submit{ name = "preview", text = _"Preview" }
   173     ui.submit{ text = _"Save" }
   174   end
   175 }
