From e8668f3ed40f94c1e1bf6e32f66c79f3e11ee43a Mon Sep 17 00:00:00 2001 From: Shannon Date: Tue, 21 Mar 2017 18:38:32 +1100 Subject: [PATCH] Don't pass in a value for snippets if it's not there, it will show up as a "undefined" string otherwise, adds the redirect method to the contentEditingHelper --- .../src/common/resources/codefile.resource.js | 10 ++++++++-- .../services/contenteditinghelper.service.js | 20 +++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/common/resources/codefile.resource.js b/src/Umbraco.Web.UI.Client/src/common/resources/codefile.resource.js index 44454f21e3..7cd55b268a 100644 --- a/src/Umbraco.Web.UI.Client/src/common/resources/codefile.resource.js +++ b/src/Umbraco.Web.UI.Client/src/common/resources/codefile.resource.js @@ -199,11 +199,17 @@ function codefileResource($q, $http, umbDataFormatter, umbRequestHelper) { */ getScaffold: function (type, id, snippetName) { + + var queryString = "?type=" + type + "&id=" + id; + if (snippetName) { + queryString += "&snippetName=" + snippetName; + } + return umbRequestHelper.resourcePromise( $http.get( umbRequestHelper.getApiUrl( - "codeFileApiBaseUrl", - "GetScaffold?type=" + type + "&id=" + id + "&snippetName=" + snippetName)), + "codeFileApiBaseUrl", + "GetScaffold" + queryString)), "Failed to get scaffold for" + type); }, diff --git a/src/Umbraco.Web.UI.Client/src/common/services/contenteditinghelper.service.js b/src/Umbraco.Web.UI.Client/src/common/services/contenteditinghelper.service.js index b1464e5c9d..020ac9c710 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/contenteditinghelper.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/contenteditinghelper.service.js @@ -522,6 +522,26 @@ function contentEditingHelper(fileManager, $q, $location, $routeParams, notifica return true; } return false; + }, + + /** + * @ngdoc function + * @name umbraco.services.contentEditingHelper#redirectToRenamedContent + * @methodOf umbraco.services.contentEditingHelper + * @function + * + * @description + * For some editors like scripts or entites that have names as ids, these names can change and we need to redirect + * to their new paths, this is helper method to do that. + */ + redirectToRenamedContent: function (id) { + //clear the query strings + $location.search(""); + //change to new path + $location.path("/" + $routeParams.section + "/" + $routeParams.tree + "/" + $routeParams.method + "/" + id); + //don't add a browser history for this + $location.replace(); + return true; } }; }