From 318d994cf3529565aa3e5dcd539ba32d3fd4082e Mon Sep 17 00:00:00 2001 From: Terence Burridge <134947113+CodeBunTes@users.noreply.github.com> Date: Wed, 7 Feb 2024 17:07:46 +0000 Subject: [PATCH] Reload the List View after a copy, if to the same parent (#15312) --- .../listview/listview.controller.js | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/listview.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/listview.controller.js index 68075cb999..0edcd67c19 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/listview.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/listview.controller.js @@ -650,8 +650,17 @@ function listViewController($scope, $interpolate, $routeParams, $injector, $time }; function performCopy(target, relateToOriginal, includeDescendants) { + var newPath = null; + var newTarget = null; applySelected( - function (selected, index) { return contentResource.copy({ parentId: target.id, id: getIdCallback(selected[index]), relateToOriginal: relateToOriginal, recursive: includeDescendants }); }, + function (selected, index) { + return contentResource.copy({ parentId: target.id, id: getIdCallback(selected[index]), relateToOriginal: relateToOriginal, recursive: includeDescendants }) + .then(function (path) { + newPath = path; + newTarget = parseInt(target.id); + return path; + }); + }, function (count, total) { var key = (total === 1 ? "bulk_copiedItemOfItem" : "bulk_copiedItemOfItems"); return localizationService.localize(key, [count, total]); @@ -659,6 +668,18 @@ function listViewController($scope, $interpolate, $routeParams, $injector, $time function (total) { var key = (total === 1 ? "bulk_copiedItem" : "bulk_copiedItems"); return localizationService.localize(key, [total]); + }) + .then(function () { + //executes if all is successful + if (newPath) { + if (newTarget === $scope.contentId) { + // if we copied this to the same parent, reload the current view completely + $scope.reloadView($scope.contentId); + } else { + // Otherwise just clear the current selection but don't reload + $scope.clearSelection(); + } + } }); }