Skip to content

Commit

Permalink
Merge pull request #4 from LPayne91/master
Browse files Browse the repository at this point in the history
Multi select update: X button removes all selected items
  • Loading branch information
rjrudman authored Aug 2, 2017
2 parents d53abc2 + 26a3859 commit 4aff64a
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/hierarchical-selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 4aff64a

Please sign in to comment.