mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-08 16:40:16 +08:00
Fix checkboxes at the protocol template table [SCI-8099] (#5108)
This commit is contained in:
parent
90ea8425ff
commit
b1468df3e1
2 changed files with 39 additions and 25 deletions
|
@ -135,9 +135,30 @@ var ProtocolsIndex = (function() {
|
|||
});
|
||||
}
|
||||
|
||||
function initManageAccessButton() {
|
||||
$('.protocols-index').on('click', '#manageProtocolAccess', function() {
|
||||
$(`tr[data-row-id=${rowsSelected[0]}] .protocol-users-link`).click();
|
||||
function initManageAccess() {
|
||||
let protocolsContainer = '.protocols-container';
|
||||
let manageAccessModal = '.protocol-assignments-modal';
|
||||
|
||||
function loadManageAccessModal(href) {
|
||||
$.get(href, function(data) {
|
||||
$(protocolsContainer).append($.parseHTML(data.html));
|
||||
$(manageAccessModal).modal('show');
|
||||
|
||||
// Remove modal when it gets closed
|
||||
$(manageAccessModal).on('hidden.bs.modal', function() {
|
||||
$(manageAccessModal).remove();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
protocolsTableEl.on('click', '.protocol-users-link', function(e) {
|
||||
loadManageAccessModal(this.href);
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
$(protocolsContainer).on('click', '#manageProtocolAccess', function() {
|
||||
loadManageAccessModal($(`tr[data-row-id=${rowsSelected[0]}] .protocol-users-link`).attr('href'));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -643,29 +664,18 @@ var ProtocolsIndex = (function() {
|
|||
}
|
||||
|
||||
function updateDataTableSelectAllCheckbox() {
|
||||
var table = protocolsDatatable.table().node();
|
||||
var checkboxesAll = $("tbody input[type='checkbox']", protocolsTableEl);
|
||||
var checkboxesChecked = $("tbody input[type='checkbox']:checked", protocolsTableEl);
|
||||
var checkboxSelectAll = $("thead input[name='select_all']", table).get(0);
|
||||
var table = $('.protocols-datatable');
|
||||
var checkboxes = table.find("tbody input[type='checkbox']");
|
||||
var selectedCheckboxes = table.find("tbody input[type='checkbox']:checked");
|
||||
var selectAllCheckbox = table.find("thead input[name='select_all']");
|
||||
|
||||
if (checkboxesChecked.length === 0) {
|
||||
// If none of the checkboxes are checked
|
||||
checkboxSelectAll.checked = false;
|
||||
if ('indeterminate' in checkboxSelectAll) {
|
||||
checkboxSelectAll.indeterminate = false;
|
||||
}
|
||||
} else if (checkboxesChecked.length === checkboxesAll.length) {
|
||||
// If all of the checkboxes are checked
|
||||
checkboxSelectAll.checked = true;
|
||||
if ('indeterminate' in checkboxSelectAll) {
|
||||
checkboxSelectAll.indeterminate = false;
|
||||
}
|
||||
selectAllCheckbox.prop('indeterminate', false);
|
||||
if (selectedCheckboxes.length === 0) {
|
||||
selectAllCheckbox.prop('checked', false);
|
||||
} else if (selectedCheckboxes.length === checkboxes.length) {
|
||||
selectAllCheckbox.prop('checked', true);
|
||||
} else {
|
||||
// If some of the checkboxes are checked
|
||||
checkboxSelectAll.checked = true;
|
||||
if ('indeterminate' in checkboxSelectAll) {
|
||||
checkboxSelectAll.indeterminate = true;
|
||||
}
|
||||
selectAllCheckbox.prop('indeterminate', true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -970,7 +980,7 @@ var ProtocolsIndex = (function() {
|
|||
}
|
||||
|
||||
init();
|
||||
initManageAccessButton();
|
||||
initManageAccess();
|
||||
initArchiveProtocols();
|
||||
initRestoreProtocols();
|
||||
initExportProtocols();
|
||||
|
|
|
@ -61,6 +61,10 @@
|
|||
.dataTables_scrollBody {
|
||||
height: 100%;
|
||||
|
||||
td:first-child {
|
||||
padding-top: 13px;
|
||||
}
|
||||
|
||||
td:not(:first-child) {
|
||||
padding: 14px 8px;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue