Merge pull request #3340 from aignatov-bio/ai-sci-5714-fix-checkbox-in-report-wizard

Add indeterminate state to report wizard checkbox [SCI-5714]
This commit is contained in:
Alex Kriuchykhin 2021-05-20 16:01:41 +02:00 committed by GitHub
commit 371a51c4de
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1331,10 +1331,7 @@ function reportHandsonTableConverter() {
disableSearch: true
});
function SelectAllRepositoriesStatus() {
var selectAll = $('.task-contents-container .select-all-repositories');
var all = $('.repositories-contents .sci-checkbox').length;
var checked = $('.repositories-contents .sci-checkbox:checked').length;
function selectAllCheckboxState(selectAll, all, checked) {
selectAll.prop('indeterminate', false);
if (all === checked) {
selectAll.prop('checked', true);
@ -1344,6 +1341,35 @@ function reportHandsonTableConverter() {
}
}
function SelectAllRepositoriesStatus() {
var selectAll = $('.task-contents-container .select-all-repositories');
var all = $('.repositories-contents .sci-checkbox').length;
var checked = $('.repositories-contents .sci-checkbox:checked').length;
selectAllCheckboxState(selectAll, all, checked);
}
function SelectAllProtocolStatus() {
var selectAll = $('.task-contents-container .protocol-steps-checkbox');
var all = $('.step-contents .sci-checkbox').length;
var checked = $('.step-contents .sci-checkbox:checked').length;
selectAllCheckboxState(selectAll, all, checked);
}
function SelectAllResultsStatus() {
var selectAll = $('.task-contents-container .all-results-checkbox');
var all = $('.results-type-contents .sci-checkbox:not(.skip-select-all)').length;
var checked = $('.results-type-contents .sci-checkbox:not(.skip-select-all):checked').length;
selectAllCheckboxState(selectAll, all, checked);
}
function SelectAllTaskContentStatus() {
var selectAll = $('.task-contents-container .select-all-task-contents');
var all = $('.report-task-settings .sci-checkbox:not(.skip-select-all)').length;
var checked = $('.report-task-settings .sci-checkbox:not(.skip-select-all):checked').length;
selectAllCheckboxState(selectAll, all, checked);
}
$('.task-contents-container')
.on('change', '.select-all-task-contents', function() {
$('.content-element .sci-checkbox:not(.skip-select-all)')
@ -1363,6 +1389,15 @@ function reportHandsonTableConverter() {
})
.on('change', '.repositories-contents .sci-checkbox', function() {
SelectAllRepositoriesStatus();
})
.on('change', '.step-contents .sci-checkbox', function() {
SelectAllProtocolStatus();
})
.on('change', '.results-type-contents .sci-checkbox:not(.skip-select-all)', function() {
SelectAllResultsStatus();
})
.on('change', '.report-task-settings .sci-checkbox:not(.skip-select-all)', function() {
SelectAllTaskContentStatus();
});
SelectAllRepositoriesStatus();