liquid_feedback_frontend
view app/main/initiative/remove_initiator.lua @ 1542:8f354722d754
Create empty session if no session available
| author | bsw | 
|---|---|
| date | Tue Oct 20 18:04:33 2020 +0200 (2020-10-20) | 
| parents | 32cc544d5a5b | 
| children | ca68bd1c851d | 
 line source
     1 local initiative = Initiative:by_id(param.get("initiative_id"))
     3 local member = app.session.member
     4 if member then
     5   initiative:load_everything_for_member_id(member.id)
     6   initiative.issue:load_everything_for_member_id(member.id)
     7 end
     9 local initiator = Initiator:by_pk(initiative.id, app.session.member.id)
    10 if not initiator or initiator.accepted ~= true then
    11   return execute.view { module = "index", view = "403" }
    12 end
    14 execute.view {
    15   module = "issue", view = "_head", params = {
    16     issue = initiative.issue,
    17     member = app.session.member
    18   }
    19 }
    21 execute.view{ module = "issue", view = "_sidebar_state", params = {
    22   initiative = initiative
    23 } }
    25 execute.view { 
    26   module = "issue", view = "_sidebar_issue", 
    27   params = {
    28     issue = initiative.issue,
    29     highlight_initiative_id = initiative.id
    30   }
    31 }
    33 execute.view {
    34   module = "issue", view = "_sidebar_whatcanido",
    35   params = { initiative = initiative }
    36 }
    38 execute.view { 
    39   module = "issue", view = "_sidebar_members", params = {
    40     issue = initiative.issue, initiative = initiative
    41   }
    42 }
    44 ui.form{
    45   attr = { class = "vertical section" },
    46   module = "initiative",
    47   action = "remove_initiator",
    48   params = {
    49     initiative_id = initiative.id,
    50   },
    51   routing = {
    52     ok = {
    53       mode = "redirect",
    54       module = "initiative",
    55       view = "show",
    56       id = initiative.id,
    57       params = {
    58         tab = "initiators",
    59       }
    60     }
    61   },
    62   content = function()
    64     ui.sectionHead( function()
    65       ui.link{
    66         module = "initiative", view = "show", id = initiative.id,
    67         content = function ()
    68           ui.heading { 
    69             level = 1,
    70             content = initiative.display_name
    71           }
    72         end
    73       }
    74       ui.heading { level = 2, content = _"Remove an initiator from initiative" }
    75     end )
    77     ui.sectionRow( function()
    78       local records = initiative:get_reference_selector("initiating_members"):add_where("accepted OR accepted ISNULL"):exec()
    79       ui.heading{ level = 2, content = _"Choose an initiator to remove" }
    80       ui.field.select{
    81         name = "member_id",
    82         foreign_records = records,
    83         foreign_id = "id",
    84         foreign_name = "name",
    85       }
    86       slot.put("<br />")
    87       ui.tag{
    88         tag = "input",
    89         attr = {
    90           type = "submit",
    91           class = "btn btn-dangerous",
    92           value = _"Remove initiator"
    93         },
    94         content = ""
    95       }
    96       slot.put("<br />")
    97       slot.put("<br />")
    98       ui.link{
    99         content = _"Cancel",
   100         module = "initiative",
   101         view = "show",
   102         id = initiative.id,
   103         params = {
   104           tab = "initiators"
   105         }
   106       }
   107     end )
   108   end
   109 }
