Fixes: U4-7575 Deselecting items in the MNTP are not deselected

This commit is contained in:
Mads Rasmussen
2016-01-09 20:49:54 +01:00
parent 273d2e2a2b
commit d4a1eea8e5

View File

@@ -267,12 +267,23 @@ angular.module("umbraco").controller("Umbraco.Overlays.TreePickerController",
function multiSelectItem(item) {
var i = $scope.model.selection.indexOf(item);
var found = false;
var foundIndex = 0;
if (i < 0) {
$scope.model.selection.push(item);
if($scope.model.selection.length > 0) {
for(i = 0; $scope.model.selection.length > i; i++) {
var selectedItem = $scope.model.selection[i];
if(selectedItem.id === item.id) {
found = true;
foundIndex = i;
}
}
}
if(found) {
$scope.model.selection.splice(foundIndex, 1);
} else {
$scope.model.selection.splice(i, 1);
$scope.model.selection.push(item);
}
}