| rev | 
   line source | 
| 
bsw/jbe@19
 | 
     1 local initiative_id = param.get("initiative_id")
 | 
| 
bsw/jbe@19
 | 
     2 
 | 
| 
bsw/jbe@19
 | 
     3 ui.form{
 | 
| 
bsw/jbe@19
 | 
     4   module = "suggestion",
 | 
| 
bsw/jbe@19
 | 
     5   action = "add",
 | 
| 
bsw/jbe@19
 | 
     6   params = { initiative_id = initiative_id },
 | 
| 
bsw/jbe@19
 | 
     7   routing = {
 | 
| 
bsw/jbe@19
 | 
     8     default = {
 | 
| 
bsw/jbe@19
 | 
     9       mode = "redirect",
 | 
| 
bsw/jbe@19
 | 
    10       module = "initiative",
 | 
| 
bsw/jbe@19
 | 
    11       view = "show",
 | 
| 
bsw/jbe@19
 | 
    12       id = initiative_id,
 | 
| 
bsw/jbe@19
 | 
    13       params = { tab = "suggestions" }
 | 
| 
bsw/jbe@19
 | 
    14     }
 | 
| 
bsw/jbe@19
 | 
    15   },
 | 
| 
bsw@1045
 | 
    16   attr = { class = "section vertical" },
 | 
| 
bsw/jbe@19
 | 
    17   content = function()
 | 
| 
bsw@1045
 | 
    18   
 | 
| 
bsw@1045
 | 
    19     ui.sectionHead( function()
 | 
| 
bsw@1045
 | 
    20       ui.heading { level = 1, content = _"Add a new suggestion for improvement" }
 | 
| 
bsw@1045
 | 
    21     end)
 | 
| 
bsw@1045
 | 
    22     
 | 
| 
bsw@1045
 | 
    23     ui.sectionRow( function()
 | 
| 
bsw@1045
 | 
    24     
 | 
| 
bsw@1045
 | 
    25       local supported = Supporter:by_pk(initiative_id, app.session.member.id) and true or false
 | 
| 
bsw@1045
 | 
    26       if not supported then
 | 
| 
bsw@1045
 | 
    27         ui.field.text{
 | 
| 
bsw@1045
 | 
    28           attr = { class = "warning" },
 | 
| 
bsw@1045
 | 
    29           value = _"You are currently not supporting this initiative directly. By adding suggestions to this initiative you will automatically become a potential supporter."
 | 
| 
bsw@1045
 | 
    30         }
 | 
| 
bsw@1045
 | 
    31       end
 | 
| 
bsw@1045
 | 
    32       ui.field.text{ label = _"A short title (80 chars max)", name = "name" }
 | 
| 
bsw@1045
 | 
    33       
 | 
| 
bsw@1045
 | 
    34       if not config.enforce_formatting_engine then
 | 
| 
bsw@1045
 | 
    35         ui.field.select{
 | 
| 
bsw@1045
 | 
    36           label = _"Wiki engine",
 | 
| 
bsw@1045
 | 
    37           name = "formatting_engine",
 | 
| 
bsw@1045
 | 
    38           foreign_records = config.formatting_engines,
 | 
| 
bsw@1045
 | 
    39           attr = {id = "formatting_engine"},
 | 
| 
bsw@1045
 | 
    40           foreign_id = "id",
 | 
| 
bsw@1045
 | 
    41           foreign_name = "name",
 | 
| 
bsw@1045
 | 
    42           value = param.get("formatting_engine")
 | 
| 
bsw@279
 | 
    43         }
 | 
| 
bsw@279
 | 
    44         ui.tag{
 | 
| 
bsw@1045
 | 
    45           tag = "div",
 | 
| 
bsw@279
 | 
    46           content = function()
 | 
| 
bsw@1045
 | 
    47             ui.tag{
 | 
| 
bsw@1045
 | 
    48               tag = "label",
 | 
| 
bsw@1045
 | 
    49               attr = { class = "ui_field_label" },
 | 
| 
bsw@1045
 | 
    50               content = function() slot.put(" ") end,
 | 
| 
bsw@279
 | 
    51             }
 | 
| 
bsw@1045
 | 
    52             ui.tag{
 | 
| 
bsw@1045
 | 
    53               content = function()
 | 
| 
bsw@1045
 | 
    54                 ui.link{
 | 
| 
bsw@1045
 | 
    55                   text = _"Syntax help",
 | 
| 
bsw@1045
 | 
    56                   module = "help",
 | 
| 
bsw@1045
 | 
    57                   view = "show",
 | 
| 
bsw@1045
 | 
    58                   id = "wikisyntax",
 | 
| 
bsw@1045
 | 
    59                   attr = {onClick="this.href=this.href.replace(/wikisyntax[^.]*/g, 'wikisyntax_'+getElementById('formatting_engine').value)"}
 | 
| 
bsw@1045
 | 
    60                 }
 | 
| 
bsw@1045
 | 
    61                 slot.put(" ")
 | 
| 
bsw@1045
 | 
    62                 ui.link{
 | 
| 
bsw@1045
 | 
    63                   text = _"(new window)",
 | 
| 
bsw@1045
 | 
    64                   module = "help",
 | 
| 
bsw@1045
 | 
    65                   view = "show",
 | 
| 
bsw@1045
 | 
    66                   id = "wikisyntax",
 | 
| 
bsw@1045
 | 
    67                   attr = {target = "_blank", onClick="this.href=this.href.replace(/wikisyntax[^.]*/g, 'wikisyntax_'+getElementById('formatting_engine').value)"}
 | 
| 
bsw@1045
 | 
    68                 }
 | 
| 
bsw@1045
 | 
    69               end
 | 
| 
bsw@279
 | 
    70             }
 | 
| 
bsw@279
 | 
    71           end
 | 
| 
bsw@279
 | 
    72         }
 | 
| 
bsw@279
 | 
    73       end
 | 
| 
bsw@1045
 | 
    74 
 | 
| 
bsw@1045
 | 
    75       ui.field.text{
 | 
| 
bsw@1045
 | 
    76         label = _"Describe how the proposal and/or the reasons of the initiative could be improved",
 | 
| 
bsw@1045
 | 
    77         name = "content",
 | 
| 
bsw@1045
 | 
    78         multiline = true, 
 | 
| 
bsw@1045
 | 
    79         attr = { style = "height: 50ex;" },
 | 
| 
bsw@1045
 | 
    80         value = param.get("content")
 | 
| 
bsw@1045
 | 
    81       }
 | 
| 
bsw@279
 | 
    82 
 | 
| 
bsw@1045
 | 
    83       ui.field.select{
 | 
| 
bsw@1045
 | 
    84         label = _"How important is your suggestions for you?",
 | 
| 
bsw@1045
 | 
    85         name = "degree",
 | 
| 
bsw@1045
 | 
    86         foreign_records = {
 | 
| 
bsw@1045
 | 
    87           { id =  1, name = _"should be implemented"},
 | 
| 
bsw@1045
 | 
    88           { id =  2, name = _"must be implemented"},
 | 
| 
bsw@1045
 | 
    89         },
 | 
| 
bsw@1045
 | 
    90         foreign_id = "id",
 | 
| 
bsw@1045
 | 
    91         foreign_name = "name"
 | 
| 
bsw@1045
 | 
    92       }
 | 
| 
bsw@1045
 | 
    93       
 | 
| 
bsw@1045
 | 
    94       ui.submit{ text = _"publish suggestion" }
 | 
| 
bsw@1045
 | 
    95       slot.put(" ")
 | 
| 
bsw@1045
 | 
    96       ui.link{
 | 
| 
bsw@1045
 | 
    97         content = _"cancel",
 | 
| 
bsw@1045
 | 
    98         module = "initiative",
 | 
| 
bsw@1045
 | 
    99         view = "show",
 | 
| 
bsw@1045
 | 
   100         id = initiative_id,
 | 
| 
bsw@1045
 | 
   101         params = { tab = "suggestions" }
 | 
| 
bsw@1045
 | 
   102       }
 | 
| 
bsw@1045
 | 
   103 
 | 
| 
bsw@1045
 | 
   104     end )
 | 
| 
bsw/jbe@19
 | 
   105   end
 | 
| 
bsw/jbe@19
 | 
   106 }
 |