182 lines
5.7 KiB
JavaScript
182 lines
5.7 KiB
JavaScript
/**
|
|
* 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-promote').click(function(e) {
|
|
e.preventDefault();
|
|
|
|
$("body").ufModal({
|
|
sourceUrl: site.uri.public + '/modals/organisations/o/' + $(this).data('slug') + '/members/confirm-promote',
|
|
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();
|
|
});
|
|
});
|
|
});
|
|
|
|
// Remove user button
|
|
el.find('.js-member-demote').click(function(e) {
|
|
e.preventDefault();
|
|
|
|
$("body").ufModal({
|
|
sourceUrl: site.uri.public + '/modals/organisations/o/' + $(this).data('slug') + '/members/confirm-demote',
|
|
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();
|
|
});
|
|
});
|
|
});
|
|
|
|
// 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();
|
|
});
|
|
});
|
|
});
|
|
|
|
|
|
// Reset member password button
|
|
el.find('.js-member-password').click(function(e) {
|
|
e.preventDefault();
|
|
|
|
var userName = $(this).data('user_name');
|
|
$("body").ufModal({
|
|
sourceUrl: site.uri.public + '/modals/organisations/o/' + $(this).data('slug') + '/members/reset-password',
|
|
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();
|
|
// });
|
|
// };
|