annotate app/main/draft/new.lua @ 99:ae5fbdbc1758
Fixed hard error in initiative API
 | author | 
 bsw | 
 | date | 
 Tue Aug 31 17:38:36 2010 +0200 (2010-08-31) | 
 | parents | 
 6a12fb7e4963  | 
 | children | 
 fa55c8ded9fd  | 
 
 | rev | 
   line source | 
| 
bsw/jbe@4
 | 
     1 slot.put_into("title", _"Edit draft")
 | 
| 
bsw/jbe@0
 | 
     2 
 | 
| 
bsw@2
 | 
     3 local initiative = Initiative:by_id(param.get("initiative_id"))
 | 
| 
bsw/jbe@0
 | 
     4 
 | 
| 
bsw/jbe@4
 | 
     5 slot.select("actions", function()
 | 
| 
bsw/jbe@4
 | 
     6   ui.link{
 | 
| 
bsw/jbe@4
 | 
     7     content = function()
 | 
| 
bsw/jbe@4
 | 
     8         ui.image{ static = "icons/16/cancel.png" }
 | 
| 
bsw/jbe@4
 | 
     9         slot.put(_"Cancel")
 | 
| 
bsw/jbe@4
 | 
    10     end,
 | 
| 
bsw/jbe@4
 | 
    11     module = "initiative",
 | 
| 
bsw/jbe@4
 | 
    12     view = "show",
 | 
| 
bsw/jbe@4
 | 
    13     id = initiative.id
 | 
| 
bsw/jbe@4
 | 
    14   }
 | 
| 
bsw/jbe@4
 | 
    15 end)
 | 
| 
bsw/jbe@4
 | 
    16 
 | 
| 
bsw@95
 | 
    17 
 | 
| 
bsw@95
 | 
    18 
 | 
| 
bsw/jbe@0
 | 
    19 ui.form{
 | 
| 
bsw@2
 | 
    20   record = initiative.current_draft,
 | 
| 
bsw/jbe@0
 | 
    21   attr = { class = "vertical" },
 | 
| 
bsw/jbe@0
 | 
    22   module = "draft",
 | 
| 
bsw/jbe@0
 | 
    23   action = "add",
 | 
| 
bsw@2
 | 
    24   params = { initiative_id = initiative.id },
 | 
| 
bsw/jbe@0
 | 
    25   routing = {
 | 
| 
bsw@95
 | 
    26     ok = {
 | 
| 
bsw/jbe@0
 | 
    27       mode = "redirect",
 | 
| 
bsw/jbe@0
 | 
    28       module = "initiative",
 | 
| 
bsw/jbe@0
 | 
    29       view = "show",
 | 
| 
bsw@2
 | 
    30       id = initiative.id
 | 
| 
bsw/jbe@0
 | 
    31     }
 | 
| 
bsw/jbe@0
 | 
    32   },
 | 
| 
bsw/jbe@0
 | 
    33   content = function()
 | 
| 
bsw/jbe@0
 | 
    34 
 | 
| 
bsw/jbe@0
 | 
    35     ui.field.text{ label = _"Author", value = app.session.member.name, readonly = true }
 | 
| 
bsw@95
 | 
    36 
 | 
| 
bsw@95
 | 
    37     if param.get("preview") then
 | 
| 
bsw@95
 | 
    38       ui.container{
 | 
| 
bsw@95
 | 
    39         attr = { class = "draft_content wiki" },
 | 
| 
bsw@95
 | 
    40         content = function()
 | 
| 
bsw@95
 | 
    41           slot.put(format.wiki_text(param.get("content"), param.get("formatting_engine")))
 | 
| 
bsw@95
 | 
    42         end
 | 
| 
bsw@95
 | 
    43       }
 | 
| 
bsw@95
 | 
    44       slot.put("<br />")
 | 
| 
bsw@95
 | 
    45       ui.submit{ text = _"Save" }
 | 
| 
bsw@95
 | 
    46       slot.put("<br />")
 | 
| 
bsw@95
 | 
    47       slot.put("<br />")
 | 
| 
bsw@95
 | 
    48     end
 | 
| 
bsw@95
 | 
    49     slot.put("<br />")
 | 
| 
bsw@95
 | 
    50 
 | 
| 
bsw@95
 | 
    51 
 | 
| 
bsw/jbe@4
 | 
    52     ui.field.select{
 | 
| 
bsw/jbe@4
 | 
    53       label = _"Wiki engine",
 | 
| 
bsw/jbe@4
 | 
    54       name = "formatting_engine",
 | 
| 
bsw/jbe@4
 | 
    55       foreign_records = {
 | 
| 
bsw/jbe@4
 | 
    56         { id = "rocketwiki", name = "RocketWiki" },
 | 
| 
bsw/jbe@4
 | 
    57         { id = "compat", name = _"Traditional wiki syntax" }
 | 
| 
bsw/jbe@4
 | 
    58       },
 | 
| 
bsw/jbe@4
 | 
    59       foreign_id = "id",
 | 
| 
bsw/jbe@4
 | 
    60       foreign_name = "name"
 | 
| 
bsw/jbe@4
 | 
    61     }
 | 
| 
bsw@2
 | 
    62     ui.field.text{
 | 
| 
bsw@2
 | 
    63       label = _"Content",
 | 
| 
bsw@2
 | 
    64       name = "content",
 | 
| 
bsw@2
 | 
    65       multiline = true,
 | 
| 
bsw@95
 | 
    66       attr = { style = "height: 50ex;" },
 | 
| 
bsw@95
 | 
    67       value = param.get("content")
 | 
| 
bsw@2
 | 
    68    }
 | 
| 
bsw/jbe@0
 | 
    69 
 | 
| 
bsw@95
 | 
    70     ui.submit{ name = "preview", text = _"Preview" }
 | 
| 
bsw/jbe@0
 | 
    71     ui.submit{ text = _"Save" }
 | 
| 
bsw/jbe@0
 | 
    72   end
 | 
| 
bsw/jbe@0
 | 
    73 }
 |