bsw@10: local initiative = Initiative:by_id(param.get("initiative_id")) bsw@10: 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@10: slot.put_into("title", _"Remove initiator from initiative") bsw@10: bsw@10: slot.select("actions", function() bsw@10: ui.link{ bsw@10: content = function() bsw@10: ui.image{ static = "icons/16/cancel.png" } bsw@10: slot.put(_"Cancel") bsw@10: end, 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: end) bsw@10: bsw@10: util.help("initiative.remove_initiator", _"Remove initiator from initiative") bsw@10: bsw@10: ui.form{ bsw@10: attr = { class = "vertical" }, 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@10: local records = { bsw@10: { bsw@10: id = "-1", bsw@10: name = _"Choose initiator" bsw@10: } bsw@10: } bsw@10: local members = initiative:get_reference_selector("initiating_members"):add_where("accepted OR accepted ISNULL"):exec() bsw@10: for i, record in ipairs(members) do bsw@10: records[#records+1] = record bsw@10: end bsw@10: ui.field.select{ bsw@10: label = _"Member", bsw@10: name = "member_id", bsw@10: foreign_records = records, bsw@10: foreign_id = "id", bsw@10: foreign_name = "name" bsw@10: } bsw@10: ui.submit{ text = _"Save" } bsw@10: end bsw@10: }