bsw@10: local initiative = Initiative:by_id(param.get("initiative_id"))
bsw@10: 
bsw@1045: local member = app.session.member
bsw@1045: if member then
bsw@1045:   initiative:load_everything_for_member_id(member.id)
bsw@1045:   initiative.issue:load_everything_for_member_id(member.id)
bsw@1045: end
bsw@1045: 
bsw@10: local initiator = Initiator:by_pk(initiative.id, app.session.member.id)
bsw@10: if not initiator or initiator.accepted ~= true then
bsw@10:   error("access denied")
bsw@10: end
bsw@10: 
bsw@1045: execute.view {
bsw@1045:   module = "issue", view = "_head", params = {
bsw@1045:     issue = initiative.issue,
bsw@1045:     member = app.session.member
bsw@1045:   }
bsw@1045: }
bsw@1045: 
bsw@1045: execute.view{ module = "issue", view = "_sidebar_state", params = {
bsw@1045:   initiative = initiative
bsw@1045: } }
bsw@10: 
bsw@1045: execute.view { 
bsw@1045:   module = "issue", view = "_sidebar_issue", 
bsw@1045:   params = {
bsw@1045:     issue = initiative.issue,
bsw@1045:     highlight_initiative_id = initiative.id
bsw@10:   }
bsw@1045: }
bsw@10: 
bsw@1045: execute.view {
bsw@1045:   module = "issue", view = "_sidebar_whatcanido",
bsw@1045:   params = { initiative = initiative }
bsw@1045: }
bsw@1045: 
bsw@1045: execute.view { 
bsw@1045:   module = "issue", view = "_sidebar_members", params = {
bsw@1045:     issue = initiative.issue, initiative = initiative
bsw@1045:   }
bsw@1045: }
bsw@10: 
bsw@10: ui.form{
bsw@1045:   attr = { class = "vertical section" },
bsw@10:   module = "initiative",
bsw@10:   action = "remove_initiator",
bsw@10:   params = {
bsw@10:     initiative_id = initiative.id,
bsw@10:   },
bsw@10:   routing = {
bsw@10:     ok = {
bsw@10:       mode = "redirect",
bsw@10:       module = "initiative",
bsw@10:       view = "show",
bsw@10:       id = initiative.id,
bsw@10:       params = {
bsw@10:         tab = "initiators",
bsw@10:       }
bsw@10:     }
bsw@10:   },
bsw@10:   content = function()
bsw@1045: 
bsw@1045:     ui.sectionHead( function()
bsw@1045:       ui.link{
bsw@1045:         module = "initiative", view = "show", id = initiative.id,
bsw@1045:         content = function ()
bsw@1045:           ui.heading { 
bsw@1045:             level = 1,
bsw@1045:             content = initiative.display_name
bsw@1045:           }
bsw@1045:         end
bsw@1045:       }
bsw@1045:       ui.heading { level = 2, content = _"Remove an initiator from initiative" }
bsw@1045:     end )
bsw@1045: 
bsw@1045:     ui.sectionRow( function()
bsw@1045:       local records = initiative:get_reference_selector("initiating_members"):add_where("accepted OR accepted ISNULL"):exec()
bsw@1045:       ui.heading{ level = 2, content = _"Choose an initiator to remove" }
bsw@1045:       ui.field.select{
bsw@1045:         name = "member_id",
bsw@1045:         foreign_records = records,
bsw@1045:         foreign_id = "id",
bsw@1045:         foreign_name = "name",
bsw@10:       }
bsw@1045:       slot.put("
")
bsw@1045:       ui.tag{
bsw@1045:         tag = "input",
bsw@1045:         attr = {
bsw@1045:           type = "submit",
bsw@1045:           class = "btn btn-dangerous",
bsw@1045:           value = _"Remove initiator"
bsw@1045:         },
bsw@1045:         content = ""
bsw@1045:       }
bsw@1045:       slot.put("
")
bsw@1045:       slot.put("
")
bsw@1045:       ui.link{
bsw@1045:         content = _"Cancel",
bsw@1045:         module = "initiative",
bsw@1045:         view = "show",
bsw@1045:         id = initiative.id,
bsw@1045:         params = {
bsw@1045:           tab = "initiators"
bsw@1045:         }
bsw@1045:       }
bsw@1045:     end )
bsw@10:   end
bsw@10: }