Added capability for organisation administrators to accept/reject join requests, remove members, edit their details and reset their passwords

This commit is contained in:
2022-02-22 18:11:59 +00:00
parent 5456902f77
commit 0dbfbef594
14 changed files with 582 additions and 9 deletions

View File

@@ -19,7 +19,7 @@ $(document).ready(function() {
// Bind user table buttons
$("#widget-organisation-members").on("pagerComplete.ufTable", function () {
bindMemberButtons($(this));
bindUserButtons($(this));
bindUserButtonsExtra($(this));
});
});

View File

@@ -0,0 +1,104 @@
/**
* Members widget. Sets up dropdowns, modals, etc for a table of members.
*
* Depends on widgets/users.js
*/
/**
* Link extra user action buttons in addition to the base ones.
* @param {module:jQuery} el jQuery wrapped element to target.
* @param {{delete_redirect: string}} options Options used to modify behaviour of button actions.
*/
function bindMemberButtons(el, options) {
if (!options) options = {};
// Remove user button
el.find('.js-member-remove').click(function(e) {
e.preventDefault();
$("body").ufModal({
sourceUrl: site.uri.public + '/modals/organisations/o/' + $(this).data('slug') + '/members/confirm-remove',
ajaxParams: {
slug: $(this).data('slug'),
user_name: $(this).data('user_name')
},
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
window.location.reload();
});
});
});
// Accept member button
el.find('.js-member-accept').click(function(e) {
e.preventDefault();
$("body").ufModal({
sourceUrl: site.uri.public + '/modals/organisations/o/' + $(this).data('slug') + '/members/confirm-accept',
ajaxParams: {
slug: $(this).data('slug'),
user_name: $(this).data('user_name')
},
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
window.location.reload();
});
});
});
// Reject user button
el.find('.js-member-reject').click(function(e) {
e.preventDefault();
$("body").ufModal({
sourceUrl: site.uri.public + '/modals/organisations/o/' + $(this).data('slug') + '/members/confirm-reject',
ajaxParams: {
slug: $(this).data('slug'),
user_name: $(this).data('user_name')
},
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
window.location.reload();
});
});
});
}
// function bindMemberCreationButton(el) {
// // Link create button
// el.find('.js-member-create').click(function(e) {
// e.preventDefault();
// $("body").ufModal({
// sourceUrl: site.uri.public + "/modals/users/create",
// msgTarget: $("#alerts-page")
// });
// attachUserForm();
// });
// };