diff --git a/app/assets/javascripts/reports/new.js b/app/assets/javascripts/reports/new.js index 5333253a2..e1f16c1a5 100644 --- a/app/assets/javascripts/reports/new.js +++ b/app/assets/javascripts/reports/new.js @@ -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();