From 7f5a117a67ed42c1fb2fbb06702ac0a9ebcc44e6 Mon Sep 17 00:00:00 2001 From: Shannon Date: Thu, 9 Oct 2014 17:01:36 +1100 Subject: [PATCH] Ensures that new nodes that are shown in the tree that have already been selected via the search results are shown as selected --- .../common/dialogs/treepicker.controller.js | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/treepicker.controller.js b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/treepicker.controller.js index 9bc07d2c1f..6ef18da41f 100644 --- a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/treepicker.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/treepicker.controller.js @@ -63,7 +63,7 @@ angular.module("umbraco").controller("Umbraco.Dialogs.TreePickerController", if (dialogOptions.filter[0] === "{") { dialogOptions.filterAdvanced = true; } - } + } function nodeSearchHandler(ev, args) { if (args.node.metaData.isContainer === true) { @@ -78,16 +78,17 @@ angular.module("umbraco").controller("Umbraco.Dialogs.TreePickerController", //TODO: Not only this but we need to ensure that any currently displayed nodes that get selected // from the search get updated to have a check box! - ////now we need to look in the already selected search results and - //// toggle the check boxes for those ones that are listed - //_.each($scope.searchInfo.results, function (result) { - // var exists = _.find($scope.searchInfo.selectedSearchResults, function (selectedId) { - // return result.id == selectedId; - // }); - // if (exists) { - // result.selected = true; - // } - //}); + + //now we need to look in the already selected search results and + // toggle the check boxes for those ones that are listed + _.each(args.children, function (result) { + var exists = _.find($scope.searchInfo.selectedSearchResults, function (selectedId) { + return result.id == selectedId; + }); + if (exists) { + result.selected = true; + } + }); //check filter if (dialogOptions.filter) { @@ -135,7 +136,7 @@ angular.module("umbraco").controller("Umbraco.Dialogs.TreePickerController", else { if ($scope.multiPicker) { - $scope.select(id); + $scope.select(Number(id)); } else {