From 4281610bc11a92dda9a2e06ebc65fc7c0ba06361 Mon Sep 17 00:00:00 2001 From: Shannon Date: Thu, 14 Nov 2013 19:09:13 +1100 Subject: [PATCH] fixes tree sync with move media/content --- .../views/content/content.move.controller.js | 3 +++ .../src/views/media/media.move.controller.js | 22 +++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/content/content.move.controller.js b/src/Umbraco.Web.UI.Client/src/views/content/content.move.controller.js index d798b137d4..284e4a5fa2 100644 --- a/src/Umbraco.Web.UI.Client/src/views/content/content.move.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/content/content.move.controller.js @@ -38,6 +38,9 @@ angular.module("umbraco").controller("Umbraco.Editors.Content.MoveController", $scope.error = false; $scope.success = true; + //first we need to remove the node that launched the dialog + treeService.removeNode($scope.currentNode); + //get the currently edited node (if any) var activeNode = appState.getTreeState("selectedNode"); diff --git a/src/Umbraco.Web.UI.Client/src/views/media/media.move.controller.js b/src/Umbraco.Web.UI.Client/src/views/media/media.move.controller.js index a705229221..1340c2bd33 100644 --- a/src/Umbraco.Web.UI.Client/src/views/media/media.move.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/media/media.move.controller.js @@ -1,6 +1,6 @@ //used for the media picker dialog angular.module("umbraco").controller("Umbraco.Editors.Media.MoveController", - function ($scope, eventsService, mediaResource, $log) { + function ($scope, eventsService, mediaResource, appState, treeService, navigationService) { var dialogOptions = $scope.$parent.dialogOptions; $scope.dialogTreeEventHandler = $({}); @@ -28,9 +28,27 @@ angular.module("umbraco").controller("Umbraco.Editors.Media.MoveController", $scope.move = function(){ mediaResource.move({parentId: $scope.target.id, id: node.id}) - .then(function(){ + .then(function (path) { $scope.error = false; $scope.success = true; + + //first we need to remove the node that launched the dialog + treeService.removeNode($scope.currentNode); + + //get the currently edited node (if any) + var activeNode = appState.getTreeState("selectedNode"); + + //we need to do a double sync here: first sync to the moved content - but don't activate the node, + //then sync to the currenlty edited content (note: this might not be the content that was moved!!) + + navigationService.syncTree({ tree: "media", path: path, forceReload: true, activate: false }).then(function (args) { + if (activeNode) { + var activeNodePath = treeService.getPath(activeNode).join(); + //sync to this node now - depending on what was copied this might already be synced but might not be + navigationService.syncTree({ tree: "media", path: activeNodePath, forceReload: false, activate: true }); + } + }); + },function(err){ $scope.success = false; $scope.error = err;