Delete organisation functionality
This commit is contained in:
@@ -16,4 +16,9 @@ $(document).ready(function() {
|
||||
|
||||
// Bind creation button
|
||||
bindOrganisationCreationButton($("#widget-organisations"));
|
||||
|
||||
// Bind table buttons
|
||||
$("#widget-organisations").on("pagerComplete.ufTable", function () {
|
||||
bindOrganisationButtons($(this));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -46,6 +46,44 @@ function attachOrganisationForm() {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Link organisation action buttons, for example in a table or on a specific organisation's page.
|
||||
* @param {module:jQuery} el jQuery wrapped element to target.
|
||||
* @param {{delete_redirect: string}} options Options used to modify behaviour of button actions.
|
||||
*/
|
||||
function bindOrganisationButtons(el, options) {
|
||||
if (!options) options = {};
|
||||
|
||||
/**
|
||||
* Link row buttons after table is loaded.
|
||||
*/
|
||||
|
||||
// Delete organisation button
|
||||
el.find('.js-organisation-delete').click(function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
$("body").ufModal({
|
||||
sourceUrl: site.uri.public + "/modals/organisations/confirm-delete",
|
||||
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.delete_redirect) window.location.href = options.delete_redirect;
|
||||
else window.location.reload();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function bindOrganisationCreationButton(el) {
|
||||
// Link create button
|
||||
el.find('.js-organisation-create').click(function(e) {
|
||||
|
||||
Reference in New Issue
Block a user