Orgs: Moved some JS around, no real semantic changes
This commit is contained in:
@@ -233,6 +233,14 @@ script.
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$('body').off('click', '.user-remove'); // remove previous handlers.
|
||||||
|
$('body').on('click', '.user-remove', function(e) {
|
||||||
|
var user_id = $(this).closest('*[data-user-id]').data('user-id');
|
||||||
|
var user_email = $(this).closest('*[data-user-email]').data('user-email');
|
||||||
|
removeUser(user_id, user_email);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
function addUser(userId) {
|
function addUser(userId) {
|
||||||
if (!userId || userId.length == 0) {
|
if (!userId || userId.length == 0) {
|
||||||
toastr.error('Please select a user from the list');
|
toastr.error('Please select a user from the list');
|
||||||
@@ -256,6 +264,31 @@ script.
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function removeUser(user_id, email) {
|
||||||
|
if (typeof user_id == 'undefined' && typeof email == 'undefined') {
|
||||||
|
throw "removeUser(undefined, undefined) called";
|
||||||
|
}
|
||||||
|
var organization_id = '{{ organization._id }}';
|
||||||
|
var patch = {op: 'remove-user'};
|
||||||
|
|
||||||
|
if (typeof user_id !== 'undefined') {
|
||||||
|
patch.user_id = user_id;
|
||||||
|
}
|
||||||
|
if (typeof email !== 'undefined') {
|
||||||
|
patch.email = String(email);
|
||||||
|
}
|
||||||
|
|
||||||
|
patchOrganization(patch)
|
||||||
|
.done(function() {
|
||||||
|
$("ul.sharing-users-list").find("[data-user-id='" + user_id + "']").remove();
|
||||||
|
item_open('{{ organization._id }}', false);
|
||||||
|
toastr.success('User removed from this organization');
|
||||||
|
}).fail(function (data) {
|
||||||
|
var msg = xhrErrorResponseMessage(data);
|
||||||
|
toastr.error('Error removing user: ' + msg);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function setAdmin(user_id, full_name) {
|
function setAdmin(user_id, full_name) {
|
||||||
if (!user_id || user_id.length == 0) {
|
if (!user_id || user_id.length == 0) {
|
||||||
toastr.error('Please select a user from the list');
|
toastr.error('Please select a user from the list');
|
||||||
@@ -282,44 +315,6 @@ script.
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
| {% endif %}
|
|
||||||
script.
|
|
||||||
$(document).ready(function() {
|
|
||||||
$('body').off('click', '.user-remove'); // remove previous handlers.
|
|
||||||
$('body').on('click', '.user-remove', function(e) {
|
|
||||||
var user_id = $(this).closest('*[data-user-id]').data('user-id');
|
|
||||||
var user_email = $(this).closest('*[data-user-email]').data('user-email');
|
|
||||||
removeUser(user_id, user_email);
|
|
||||||
});
|
|
||||||
|
|
||||||
function removeUser(user_id, email) {
|
|
||||||
if (typeof user_id == 'undefined' && typeof email == 'undefined') {
|
|
||||||
throw "removeUser(undefined, undefined) called";
|
|
||||||
}
|
|
||||||
var organization_id = '{{ organization._id }}';
|
|
||||||
var patch = {op: 'remove-user'};
|
|
||||||
|
|
||||||
if (typeof user_id !== 'undefined') {
|
|
||||||
patch.user_id = user_id;
|
|
||||||
}
|
|
||||||
if (typeof email !== 'undefined') {
|
|
||||||
patch.email = String(email);
|
|
||||||
}
|
|
||||||
|
|
||||||
patchOrganization(patch)
|
|
||||||
.done(function() {
|
|
||||||
$("ul.sharing-users-list").find("[data-user-id='" + user_id + "']").remove();
|
|
||||||
item_open('{{ organization._id }}', false);
|
|
||||||
toastr.success('User removed from this organization');
|
|
||||||
}).fail(function (data) {
|
|
||||||
var msg = xhrErrorResponseMessage(data);
|
|
||||||
toastr.error('Error removing user: ' + msg);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
function editOrganization() {
|
function editOrganization() {
|
||||||
var $form = $('#item_form');
|
var $form = $('#item_form');
|
||||||
var new_name = $form.find('*[name="name"]').val();
|
var new_name = $form.find('*[name="name"]').val();
|
||||||
@@ -386,4 +381,5 @@ script.
|
|||||||
$('#admin-name').show();
|
$('#admin-name').show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
| {% endif %}
|
||||||
| {% endblock %}
|
| {% endblock %}
|
||||||
|
Reference in New Issue
Block a user