mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-26 01:35:34 +08:00
Improved/removed annoying reloads when managing user access [SCI-6170] (#3618)
This commit is contained in:
parent
98be1ae0ff
commit
fc866640be
6 changed files with 10 additions and 62 deletions
|
@ -17,7 +17,6 @@ var ProjectsIndex = (function() {
|
|||
var editProjectModal = '#edit-modal';
|
||||
var moveToModal = '#move-to-modal';
|
||||
|
||||
var manageProjectUsersModal = null;
|
||||
var exportProjectsModal = null;
|
||||
var exportProjectsModalHeader = null;
|
||||
var exportProjectsModalBody = null;
|
||||
|
@ -173,7 +172,7 @@ var ProjectsIndex = (function() {
|
|||
|
||||
function initManageUsersModal() {
|
||||
// Reload users tab HTML element when modal is closed
|
||||
manageProjectUsersModal.on('hide.bs.modal', function() {
|
||||
$(document).on('ajax:success', '#user_assignments_modal form', function() {
|
||||
refreshCurrentView();
|
||||
});
|
||||
}
|
||||
|
@ -259,56 +258,6 @@ var ProjectsIndex = (function() {
|
|||
});
|
||||
}
|
||||
|
||||
// Initialize ajax listeners and elements style on modal body. This
|
||||
// function must be called when modal body is changed.
|
||||
function initManageProjectUsersModalBody(data) {
|
||||
manageProjectUsersModal.find('.modal-title').html(data.html_title);
|
||||
manageProjectUsersModal.find('.modal-body').html(data.html_body).find('.selectpicker').selectpicker();
|
||||
manageProjectUsersModal.find('.modal-footer').html(data.html_footer);
|
||||
}
|
||||
|
||||
// Initialize reloading manage user modal content after posting new
|
||||
// user.
|
||||
function initAddUserForm() {
|
||||
manageProjectUsersModal
|
||||
.on('ajax:success', '.add-user-form', function(e, data) {
|
||||
var errorBlock;
|
||||
initManageProjectUsersModalBody(data);
|
||||
if (data.status === 'error') {
|
||||
$(this).addClass('has-error');
|
||||
errorBlock = $(this).find('span.help-block');
|
||||
if (errorBlock.length && errorBlock.length > 0) {
|
||||
errorBlock.html(data.error);
|
||||
} else {
|
||||
$(this).append("<span class='help-block col-xs-8'>" + data.error + '</span>');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Initialize remove user from project links.
|
||||
function initRemoveUserLinks() {
|
||||
manageProjectUsersModal.on('ajax:success', '.remove-user-link', function(e, data) {
|
||||
initManageProjectUsersModalBody(data);
|
||||
});
|
||||
}
|
||||
|
||||
//
|
||||
function initUserRoleForms() {
|
||||
manageProjectUsersModal
|
||||
.on('change', '.update-user-form select', function() {
|
||||
$(this).parents('form').submit();
|
||||
});
|
||||
|
||||
manageProjectUsersModal
|
||||
.on('ajax:success', '.update-user-form', function(e, data) {
|
||||
initManageProjectUsersModalBody(data);
|
||||
})
|
||||
.on('ajax:error', function() {
|
||||
// TODO
|
||||
});
|
||||
}
|
||||
|
||||
function updateSelectedCards() {
|
||||
$('.project-card').removeClass('selected');
|
||||
$.each(selectedProjects, function(index, value) {
|
||||
|
@ -663,7 +612,6 @@ var ProjectsIndex = (function() {
|
|||
* Initializes cards view
|
||||
*/
|
||||
function init() {
|
||||
manageProjectUsersModal = $('#manageProjectUsersModal');
|
||||
exportProjectsModal = $('#export-projects-modal');
|
||||
exportProjectsModalHeader = exportProjectsModal.find('.modal-title');
|
||||
exportProjectsModalBody = exportProjectsModal.find('.modal-body');
|
||||
|
@ -676,9 +624,6 @@ var ProjectsIndex = (function() {
|
|||
initExportProjects();
|
||||
initDeleteFoldersToolbarButton();
|
||||
initArchiveRestoreToolbarButtons();
|
||||
initAddUserForm();
|
||||
initRemoveUserLinks();
|
||||
initUserRoleForms();
|
||||
initEditButton();
|
||||
initMoveButton();
|
||||
initProjectsViewModeSwitch();
|
||||
|
|
|
@ -4,8 +4,11 @@
|
|||
function initModalCloseListeners() {
|
||||
$(document).on('hidden.bs.modal', '[data-action*="modal-close"]', function({ currentTarget }) {
|
||||
let targetPath = currentTarget.getAttribute('data-target');
|
||||
animateSpinner();
|
||||
Turbolinks.visit(targetPath);
|
||||
|
||||
if (targetPath) {
|
||||
animateSpinner();
|
||||
Turbolinks.visit(targetPath);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<% # frozen_string_literal: true %>
|
||||
|
||||
<div class="modal fade" tabindex="-1" role="dialog" data-action="modal-close" data-target="<%= project_path %>">
|
||||
<div class="modal fade" tabindex="-1" role="dialog" data-action="modal-close">
|
||||
<div class="modal-dialog modal-lg" role="document">
|
||||
<div class="modal-content" id="user_assignments_modal">
|
||||
<div class="modal-header">
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<% # frozen_string_literal: true %>
|
||||
|
||||
<div class="modal fade" tabindex="-1" role="dialog" data-action="modal-close" data-target="<%= project_path %>">
|
||||
<div class="modal fade" tabindex="-1" role="dialog" data-action="modal-close">
|
||||
<div class="modal-dialog modal-md" role="document">
|
||||
<div class="modal-content" id="user_assignments_modal">
|
||||
<div class="modal-header">
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<% # frozen_string_literal: true %>
|
||||
|
||||
<div class="modal fade" tabindex="-1" role="dialog" data-action="modal-close" data-target="<%= projects_path %>">
|
||||
<div class="modal fade" tabindex="-1" role="dialog" data-action="modal-close">
|
||||
<div class="modal-dialog modal-lg" role="document">
|
||||
<%= render 'access_permissions/partials/edit_assignments_content', project: project, new_resource_path: new_resource_path, update_path: update_path %>
|
||||
</div>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<% # frozen_string_literal: true %>
|
||||
|
||||
<div class="modal fade" tabindex="-1" role="dialog" data-action="modal-close" data-target="<%= projects_path %>">
|
||||
<div class="modal fade" tabindex="-1" role="dialog" data-action="modal-close">
|
||||
<div class="modal-dialog modal-lg" role="document">
|
||||
<div class="modal-content" id="user_assignments_modal">
|
||||
<div class="modal-header">
|
||||
|
|
Loading…
Reference in a new issue