From badb1055f52ac9df44afee9f9fec1c8d741b12df Mon Sep 17 00:00:00 2001 From: Kenn Jacobsen Date: Fri, 30 Nov 2018 21:26:27 +0100 Subject: [PATCH 1/3] Reload the recycle bin when an item is deleted --- .../src/views/content/content.delete.controller.js | 8 ++++---- .../src/views/media/media.delete.controller.js | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/content/content.delete.controller.js b/src/Umbraco.Web.UI.Client/src/views/content/content.delete.controller.js index b0b7fc2312ff..d0cf0bdf5094 100644 --- a/src/Umbraco.Web.UI.Client/src/views/content/content.delete.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/content/content.delete.controller.js @@ -6,7 +6,7 @@ * @description * The controller for deleting content */ -function ContentDeleteController($scope, contentResource, treeService, navigationService, editorState, $location, dialogService, notificationsService) { +function ContentDeleteController($scope, contentResource, treeService, navigationService, editorState, $location, dialogService, notificationsService, $timeout) { $scope.performDelete = function() { @@ -26,13 +26,13 @@ function ContentDeleteController($scope, contentResource, treeService, navigatio treeService.removeNode($scope.currentNode); if (rootNode) { - //ensure the recycle bin has child nodes now var recycleBin = treeService.getDescendantNode(rootNode, -20); if (recycleBin) { - recycleBin.hasChildren = true; + // reload the recycle bin + treeService.loadNodeChildren({ node: recycleBin, section: "content" }); } } - + //if the current edited item is the same one as we're deleting, we need to navigate elsewhere if (editorState.current && editorState.current.id == $scope.currentNode.id) { diff --git a/src/Umbraco.Web.UI.Client/src/views/media/media.delete.controller.js b/src/Umbraco.Web.UI.Client/src/views/media/media.delete.controller.js index a8be3d0be561..00d4e5697392 100644 --- a/src/Umbraco.Web.UI.Client/src/views/media/media.delete.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/media/media.delete.controller.js @@ -26,10 +26,10 @@ function MediaDeleteController($scope, mediaResource, treeService, navigationSer treeService.removeNode($scope.currentNode); if (rootNode) { - //ensure the recycle bin has child nodes now var recycleBin = treeService.getDescendantNode(rootNode, -21); if (recycleBin) { - recycleBin.hasChildren = true; + // reload the recycle bin + treeService.loadNodeChildren({ node: recycleBin, section: "media" }); } } From 9fdce0d4bd07772a27fb599d63e9d324d75bee7c Mon Sep 17 00:00:00 2001 From: Kenn Jacobsen Date: Sun, 2 Dec 2018 14:08:14 +0100 Subject: [PATCH 2/3] Only reload if the bin is already expanded --- .../src/views/content/content.delete.controller.js | 8 ++++++-- .../src/views/media/media.delete.controller.js | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/content/content.delete.controller.js b/src/Umbraco.Web.UI.Client/src/views/content/content.delete.controller.js index d0cf0bdf5094..8be263d1af8f 100644 --- a/src/Umbraco.Web.UI.Client/src/views/content/content.delete.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/content/content.delete.controller.js @@ -26,10 +26,14 @@ function ContentDeleteController($scope, contentResource, treeService, navigatio treeService.removeNode($scope.currentNode); if (rootNode) { + //ensure the recycle bin has child nodes now var recycleBin = treeService.getDescendantNode(rootNode, -20); if (recycleBin) { - // reload the recycle bin - treeService.loadNodeChildren({ node: recycleBin, section: "content" }); + recycleBin.hasChildren = true; + //reload the recycle bin if it's already expanded so the deleted item is shown + if (recycleBin.expanded) { + treeService.loadNodeChildren({ node: recycleBin, section: "content" }); + } } } diff --git a/src/Umbraco.Web.UI.Client/src/views/media/media.delete.controller.js b/src/Umbraco.Web.UI.Client/src/views/media/media.delete.controller.js index 00d4e5697392..87fcef79d782 100644 --- a/src/Umbraco.Web.UI.Client/src/views/media/media.delete.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/media/media.delete.controller.js @@ -26,10 +26,14 @@ function MediaDeleteController($scope, mediaResource, treeService, navigationSer treeService.removeNode($scope.currentNode); if (rootNode) { + //ensure the recycle bin has child nodes now var recycleBin = treeService.getDescendantNode(rootNode, -21); if (recycleBin) { - // reload the recycle bin - treeService.loadNodeChildren({ node: recycleBin, section: "media" }); + recycleBin.hasChildren = true; + //reload the recycle bin if it's already expanded so the deleted item is shown + if (recycleBin.expanded) { + treeService.loadNodeChildren({ node: recycleBin, section: "media" }); + } } } From 6864c327a17d62ca60cd5b687ba3757b1207a526 Mon Sep 17 00:00:00 2001 From: Kenn Jacobsen Date: Mon, 3 Dec 2018 19:38:38 +0100 Subject: [PATCH 3/3] Not sure why $timeout was added to the content delete controller, but now it's gone again. --- .../src/views/content/content.delete.controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/content/content.delete.controller.js b/src/Umbraco.Web.UI.Client/src/views/content/content.delete.controller.js index 8be263d1af8f..56010840c3b6 100644 --- a/src/Umbraco.Web.UI.Client/src/views/content/content.delete.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/content/content.delete.controller.js @@ -6,7 +6,7 @@ * @description * The controller for deleting content */ -function ContentDeleteController($scope, contentResource, treeService, navigationService, editorState, $location, dialogService, notificationsService, $timeout) { +function ContentDeleteController($scope, contentResource, treeService, navigationService, editorState, $location, dialogService, notificationsService) { $scope.performDelete = function() {