From d8d08ea326341241757526ab58447c465177e5c1 Mon Sep 17 00:00:00 2001 From: "desislava.borisova" Date: Thu, 7 Nov 2024 12:58:38 +0200 Subject: [PATCH 1/7] GDB-10692 - change toggle behaviour of import checkbox. Edit styles to make the checkbox look like the dropdown button. --- src/css/import-resource-tree.css | 6 ++- .../import-resource-tree.directive.js | 37 +++++++++++++++++++ .../templates/import-resource-tree.html | 11 +++--- 3 files changed, 47 insertions(+), 7 deletions(-) diff --git a/src/css/import-resource-tree.css b/src/css/import-resource-tree.css index 020e39a79..b4c5ebd36 100644 --- a/src/css/import-resource-tree.css +++ b/src/css/import-resource-tree.css @@ -97,12 +97,14 @@ margin-right: .5rem; } -.import-resource-tree .import-resources-actions .import-resource-status-dropdown .import-resource-status-checkbox { - pointer-events: none; +.import-resource-tree .import-resources-actions .import-resource-status-dropdown { + padding-left: 5px; + gap: 5px; } .import-resource-tree .import-resources-actions .import-resource-status-dropdown .dropdown-toggle { padding-left: 0.5rem; + margin-right: 0; } .import-resource-tree .import-resources-actions .import-resource-status-dropdown .dropdown-toggle:not(.selected) { diff --git a/src/js/angular/import/directives/import-resource-tree.directive.js b/src/js/angular/import/directives/import-resource-tree.directive.js index f93196c3c..50672dd92 100644 --- a/src/js/angular/import/directives/import-resource-tree.directive.js +++ b/src/js/angular/import/directives/import-resource-tree.directive.js @@ -180,6 +180,24 @@ function importResourceTreeDirective($timeout, ImportContextService) { $scope.onEditResource({resource}); }; + $scope.toggleSelectAll = () => { + const allSelected = $scope.displayResources.every((resource) => resource.selected); + const noneSelected = $scope.displayResources.every((resource) => !resource.selected); + const checkboxElement = document.getElementById('checkboxInput'); + + if (allSelected) { + toggleCheckboxes(checkboxElement, false); + } else if (noneSelected) { + toggleCheckboxes(checkboxElement, true); + } else { + toggleCheckboxes(checkboxElement, false); + } + + updateSelectByStateDropdownModel(); + updateHasSelection(); + }; + + // ========================= // Private functions // ========================= @@ -214,6 +232,25 @@ function importResourceTreeDirective($timeout, ImportContextService) { const hasSelectedDisplayedImportResource = $scope.displayResources.some((resource) => resource.selected); $scope.areAllDisplayedImportResourcesSelected = hasSelectedDisplayedImportResource && !hasUnselectedDisplayedImportResource; $scope.areAllDisplayedImportResourcesPartialSelected = hasSelectedDisplayedImportResource && hasUnselectedDisplayedImportResource; + + if ($scope.areAllDisplayedImportResourcesSelected) { + $scope.selectedByStatus = STATUS_OPTIONS.ALL; + } else if (!$scope.areAllDisplayedImportResourcesSelected && !$scope.areAllDisplayedImportResourcesPartialSelected) { + $scope.selectedByStatus = STATUS_OPTIONS.NONE; + } + }; + + const toggleCheckboxes = (checkboxElement, shouldSelect) => { + $scope.displayResources.forEach((resource) => resource.selected = shouldSelect); + $scope.selectedByStatus = shouldSelect ? STATUS_OPTIONS.ALL : STATUS_OPTIONS.NONE; + $scope.areAllDisplayedImportResourcesSelected = shouldSelect; + $scope.areAllDisplayedImportResourcesPartialSelected = false; + + $timeout(() => { + if (checkboxElement) { + checkboxElement.checked = shouldSelect; + } + }); }; const sortResources = () => { diff --git a/src/js/angular/import/templates/import-resource-tree.html b/src/js/angular/import/templates/import-resource-tree.html index 305c09faa..2a900528e 100644 --- a/src/js/angular/import/templates/import-resource-tree.html +++ b/src/js/angular/import/templates/import-resource-tree.html @@ -2,13 +2,14 @@
-
+
+