From 4d8efc8bf2971b726e3c6f7d3c3dfb84388677ec Mon Sep 17 00:00:00 2001 From: Luke Payne Date: Tue, 1 Aug 2017 12:18:22 +1000 Subject: [PATCH 1/2] Change to X button behaviour when using multi-select - now clears all selections --- src/hierarchical-selector.js | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/hierarchical-selector.js b/src/hierarchical-selector.js index 8c95b14..d2c5303 100644 --- a/src/hierarchical-selector.js +++ b/src/hierarchical-selector.js @@ -82,6 +82,9 @@ angular.module('hierarchical-selector', [ $scope.asyncChildCache = {}; $document.off('click', docClickHide); $document.off('keydown', keyboardNav); + if($scope.$parent.onViewClosed){ + $scope.$parent.onViewClosed(); + } } function findById(id, inData) { @@ -322,13 +325,24 @@ angular.module('hierarchical-selector', [ $scope.deselectItem = function(item, $event) { $event.stopPropagation(); - $scope.selectedItems.splice($scope.selectedItems.indexOf(item), 1); - closePopup(); - var itemMeta = selectorUtils.getMetaData(item); - itemMeta.selected = false; + if($scope.multiSelect){ + var itemMeta; + for(var it in $scope.selectedItems){ + selectorUtils.getMetaData($scope.selectedItems[it]).selected = false; + } + $scope.selectedItems = []; + } + else + { + $scope.selectedItems.splice($scope.selectedItems.indexOf(item), 1); + + var itemMeta = selectorUtils.getMetaData(item); + itemMeta.selected = false; + } if ($scope.onSelectionChanged) { $scope.onSelectionChanged({items: $scope.selectedItems.length ? $scope.selectedItems : undefined}); } + closePopup(); }; $scope.onButtonClicked = function($event) { From 5c9249c84e8675870e2197d750522241d4a9c78d Mon Sep 17 00:00:00 2001 From: Luke Payne Date: Tue, 1 Aug 2017 12:18:22 +1000 Subject: [PATCH 2/2] Change to X button behaviour when using multi-select - now clears all selections --- src/hierarchical-selector.js | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/hierarchical-selector.js b/src/hierarchical-selector.js index 8c95b14..ec946ad 100644 --- a/src/hierarchical-selector.js +++ b/src/hierarchical-selector.js @@ -82,6 +82,9 @@ angular.module('hierarchical-selector', [ $scope.asyncChildCache = {}; $document.off('click', docClickHide); $document.off('keydown', keyboardNav); + if($scope.$parent.onViewClosed){ + $scope.$parent.onViewClosed(); + } } function findById(id, inData) { @@ -322,13 +325,24 @@ angular.module('hierarchical-selector', [ $scope.deselectItem = function(item, $event) { $event.stopPropagation(); - $scope.selectedItems.splice($scope.selectedItems.indexOf(item), 1); - closePopup(); - var itemMeta = selectorUtils.getMetaData(item); - itemMeta.selected = false; + if($scope.multiSelect){ + var itemMeta; + for(var it in $scope.selectedItems){ + selectorUtils.getMetaData($scope.selectedItems[it]).selected = false; + } + $scope.selectedItems = []; + } + else + { + $scope.selectedItems.splice($scope.selectedItems.indexOf(item), 1); + + var itemMeta = selectorUtils.getMetaData(item); + itemMeta.selected = false; + } if ($scope.onSelectionChanged) { $scope.onSelectionChanged({items: $scope.selectedItems.length ? $scope.selectedItems : undefined}); } + closePopup(); }; $scope.onButtonClicked = function($event) {