Allow members to leave organisations
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
|
||||
$(document).ready(function() {
|
||||
// Control buttons
|
||||
bindOrganisationButtons($("#view-organisation"), { delete_redirect: page.delete_redirect });
|
||||
bindOrganisationButtons($("#view-organisation"), { delete_redirect: page.delete_redirect, leave_redirect: page.leave_redirect });
|
||||
|
||||
// Table of users in this organisation
|
||||
$("#widget-organisation-members").ufTable({
|
||||
|
||||
@@ -133,6 +133,31 @@ function bindOrganisationButtons(el, options) {
|
||||
});
|
||||
});
|
||||
|
||||
// Leave organisation button
|
||||
el.find('.js-organisation-leave').click(function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
$("body").ufModal({
|
||||
sourceUrl: site.uri.public + "/modals/organisations/o/" + page.organisation_slug + "/members/confirm-leave",
|
||||
ajaxParams: {
|
||||
slug: $(this).data('slug')
|
||||
},
|
||||
msgTarget: $("#alerts-page")
|
||||
});
|
||||
|
||||
$("body").on('renderSuccess.ufModal', function() {
|
||||
var modal = $(this).ufModal('getModal');
|
||||
var form = modal.find('.js-form');
|
||||
|
||||
form.ufForm()
|
||||
.on("submitSuccess.ufForm", function() {
|
||||
// Navigate or reload page on success
|
||||
if (options.leave_redirect) window.location.href = options.leave_redirect;
|
||||
else window.location.reload();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Delete organisation button
|
||||
el.find('.js-organisation-delete').click(function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
Reference in New Issue
Block a user