diff --git a/src/Umbraco.Web.UI.Client/src/views/partialviewmacros/edit.controller.js b/src/Umbraco.Web.UI.Client/src/views/partialviewmacros/edit.controller.js index 4860773b02..30cb02092c 100644 --- a/src/Umbraco.Web.UI.Client/src/views/partialviewmacros/edit.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/partialviewmacros/edit.controller.js @@ -48,20 +48,25 @@ }); }); - vm.page.saveButtonState = "success"; - vm.partialViewMacro = saved; + //check if the name changed, if so we need to redirect + if (vm.partialViewMacro.id !== saved.id) { + contentEditingHelper.redirectToRenamedContent(saved.id); + } + else { + vm.page.saveButtonState = "success"; + vm.partialViewMacro = saved; - //sync state - editorState.set(vm.partialViewMacro); + //sync state + editorState.set(vm.partialViewMacro); - // normal tree sync - navigationService.syncTree({ tree: "partialViewMacros", path: vm.partialViewMacro.path, forceReload: true }).then(function (syncArgs) { - vm.page.menu.currentNode = syncArgs.node; - }); - - // clear $dirty state on form - setFormState("pristine"); + // normal tree sync + navigationService.syncTree({ tree: "partialViewMacros", path: vm.partialViewMacro.path, forceReload: true }).then(function (syncArgs) { + vm.page.menu.currentNode = syncArgs.node; + }); + // clear $dirty state on form + setFormState("pristine"); + } }, function (err) { vm.page.saveButtonState = "error"; @@ -237,26 +242,29 @@ } codefileResource.getScaffold("partialViewMacros", $routeParams.id, snippet).then(function (partialViewMacro) { - ready(partialViewMacro); + ready(partialViewMacro, false); }); } else { codefileResource.getByPath('partialViewMacros', $routeParams.id).then(function (partialViewMacro) { - ready(partialViewMacro); + ready(partialViewMacro, true); }); } } - function ready(partialViewMacro) { + function ready(partialViewMacro, syncTree) { vm.page.loading = false; vm.partialViewMacro = partialViewMacro; //sync state editorState.set(vm.partialViewMacro); - navigationService.syncTree({ tree: "partialViewMacros", path: vm.partialViewMacro.virtualPath, forceReload: true }).then(function (syncArgs) { - vm.page.menu.currentNode = syncArgs.node; - }); + + if (syncTree) { + navigationService.syncTree({ tree: "partialViewMacros", path: vm.partialViewMacro.path, forceReload: true }).then(function (syncArgs) { + vm.page.menu.currentNode = syncArgs.node; + }); + } // ace configuration vm.aceOption = { diff --git a/src/Umbraco.Web.UI.Client/src/views/partialviews/edit.controller.js b/src/Umbraco.Web.UI.Client/src/views/partialviews/edit.controller.js index fcd91071c0..a886b3c59d 100644 --- a/src/Umbraco.Web.UI.Client/src/views/partialviews/edit.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/partialviews/edit.controller.js @@ -58,20 +58,25 @@ }); }); - vm.page.saveButtonState = "success"; - vm.partialView = saved; + //check if the name changed, if so we need to redirect + if (vm.partialView.id !== saved.id) { + contentEditingHelper.redirectToRenamedContent(saved.id); + } + else { + vm.page.saveButtonState = "success"; + vm.partialView = saved; - //sync state - editorState.set(vm.partialView); + //sync state + editorState.set(vm.partialView); - // normal tree sync - navigationService.syncTree({ tree: "partialViews", path: vm.partialView.path, forceReload: true }).then(function (syncArgs) { - vm.page.menu.currentNode = syncArgs.node; - }); - - // clear $dirty state on form - setFormState("pristine"); + // normal tree sync + navigationService.syncTree({ tree: "partialViews", path: vm.partialView.path, forceReload: true }).then(function (syncArgs) { + vm.page.menu.currentNode = syncArgs.node; + }); + // clear $dirty state on form + setFormState("pristine"); + } }, function (err) { vm.page.saveButtonState = "error"; @@ -247,18 +252,18 @@ } codefileResource.getScaffold("partialViews", $routeParams.id, snippet).then(function (partialView) { - ready(partialView); + ready(partialView, false); }); } else { codefileResource.getByPath('partialViews', $routeParams.id).then(function (partialView) { - ready(partialView); + ready(partialView, true); }); } } - function ready(partialView) { + function ready(partialView, syncTree) { vm.page.loading = false; vm.partialView = partialView; @@ -266,9 +271,11 @@ //sync state editorState.set(vm.partialView); - navigationService.syncTree({ tree: "partialViews", path: vm.partialView.path, forceReload: true }).then(function (syncArgs) { - vm.page.menu.currentNode = syncArgs.node; - }); + if (syncTree) { + navigationService.syncTree({ tree: "partialViews", path: vm.partialView.path, forceReload: true }).then(function (syncArgs) { + vm.page.menu.currentNode = syncArgs.node; + }); + } // ace configuration vm.aceOption = { diff --git a/src/Umbraco.Web.UI.Client/src/views/scripts/edit.controller.js b/src/Umbraco.Web.UI.Client/src/views/scripts/edit.controller.js index d8c3723d2d..a54fa58097 100644 --- a/src/Umbraco.Web.UI.Client/src/views/scripts/edit.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/scripts/edit.controller.js @@ -55,16 +55,22 @@ notificationsService.success(header, message); }); - vm.page.saveButtonState = "success"; - vm.script = saved; + //check if the name changed, if so we need to redirect + if (vm.script.id !== saved.id) { + contentEditingHelper.redirectToRenamedContent(saved.id); + } + else { + vm.page.saveButtonState = "success"; + vm.script = saved; - //sync state - editorState.set(vm.script); - - // sync tree - navigationService.syncTree({ tree: "scripts", path: vm.script.virtualPath, forceReload: true }).then(function (syncArgs) { - vm.page.menu.currentNode = syncArgs.node; - }); + //sync state + editorState.set(vm.script); + + // sync tree + navigationService.syncTree({ tree: "scripts", path: vm.script.path, forceReload: true }).then(function (syncArgs) { + vm.page.menu.currentNode = syncArgs.node; + }); + } }, function (err) { @@ -90,17 +96,17 @@ if ($routeParams.create) { codefileResource.getScaffold("scripts", $routeParams.id).then(function (script) { - ready(script); + ready(script, false); }); } else { codefileResource.getByPath('scripts', $routeParams.id).then(function (script) { - ready(script); + ready(script, true); }); } } - function ready(script) { + function ready(script, syncTree) { vm.page.loading = false; @@ -109,9 +115,11 @@ //sync state editorState.set(vm.script); - navigationService.syncTree({ tree: "scripts", path: vm.script.virtualPath, forceReload: true }).then(function (syncArgs) { - vm.page.menu.currentNode = syncArgs.node; - }); + if (syncTree) { + navigationService.syncTree({ tree: "scripts", path: vm.script.path, forceReload: true }).then(function (syncArgs) { + vm.page.menu.currentNode = syncArgs.node; + }); + } vm.aceOption = { mode: "javascript",