Changes how soft redirecting works
This commit is contained in:
@@ -614,7 +614,7 @@ function contentEditingHelper(fileManager, $q, $location, $routeParams, editorSt
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.redirectToCreatedContent(args.err.data.id) || args.softRedirect) {
|
||||
if (!this.redirectToCreatedContent(args.err.data.id, args.softRedirect) || args.softRedirect) {
|
||||
// If we are not redirecting it's because this is not newly created content, else in some cases we are
|
||||
// soft-redirecting which means the URL will change but the route wont (i.e. creating content).
|
||||
|
||||
@@ -660,7 +660,7 @@ function contentEditingHelper(fileManager, $q, $location, $routeParams, editorSt
|
||||
throw "args.savedContent cannot be null";
|
||||
}
|
||||
|
||||
if (!this.redirectToCreatedContent(args.redirectId ? args.redirectId : args.savedContent.id) || args.softRedirect) {
|
||||
if (!this.redirectToCreatedContent(args.redirectId ? args.redirectId : args.savedContent.id, args.softRedirect) || args.softRedirect) {
|
||||
|
||||
// If we are not redirecting it's because this is not newly created content, else in some cases we are
|
||||
// soft-redirecting which means the URL will change but the route wont (i.e. creating content).
|
||||
@@ -683,7 +683,7 @@ function contentEditingHelper(fileManager, $q, $location, $routeParams, editorSt
|
||||
* We need to decide if we need to redirect to edito mode or if we will remain in create mode.
|
||||
* We will only need to maintain create mode if we have not fulfilled the basic requirements for creating an entity which is at least having a name and ID
|
||||
*/
|
||||
redirectToCreatedContent: function (id) {
|
||||
redirectToCreatedContent: function (id, softRedirect) {
|
||||
|
||||
//only continue if we are currently in create mode and not in infinite mode and if the resulting ID is valid
|
||||
if ($routeParams.create && (isValidIdentifier(id))) {
|
||||
@@ -695,9 +695,11 @@ function contentEditingHelper(fileManager, $q, $location, $routeParams, editorSt
|
||||
|
||||
//clear the query strings
|
||||
navigationService.clearSearch(["cculture"]);
|
||||
|
||||
if (softRedirect) {
|
||||
navigationService.setSoftRedirect();
|
||||
}
|
||||
//change to new path
|
||||
$location.path("/" + $routeParams.section + "/" + $routeParams.tree + "/" + $routeParams.method + "/" + id);
|
||||
$location.path("/" + $routeParams.section + "/" + $routeParams.tree + "/" + $routeParams.method + "/" + id);
|
||||
//don't add a browser history for this
|
||||
$location.replace();
|
||||
return true;
|
||||
|
||||
@@ -29,11 +29,9 @@ function navigationService($routeParams, $location, $q, $injector, eventsService
|
||||
|
||||
|
||||
//A list of query strings defined that when changed will not cause a reload of the route
|
||||
var nonRoutingQueryStrings = ["mculture", "cculture", "lq"];
|
||||
var nonRoutingQueryStrings = ["mculture", "cculture", "lq", "sr"];
|
||||
var retainedQueryStrings = ["mculture"];
|
||||
//A list of trees that don't cause a route when creating new items (TODO: eventually all trees should do this!)
|
||||
var nonRoutingTreesOnCreate = ["content", "contentblueprints"];
|
||||
|
||||
|
||||
function setMode(mode) {
|
||||
switch (mode) {
|
||||
case 'tree':
|
||||
@@ -140,11 +138,8 @@ function navigationService($routeParams, $location, $q, $injector, eventsService
|
||||
nextUrlParams = pathToRouteParts(nextUrlParams);
|
||||
}
|
||||
|
||||
//first check if this is a ?create=true url being redirected to it's true url
|
||||
if (currUrlParams.create === "true" && currUrlParams.id && currUrlParams.section && currUrlParams.tree && currUrlParams.method === "edit" &&
|
||||
!nextUrlParams.create && nextUrlParams.id && nextUrlParams.section === currUrlParams.section && nextUrlParams.tree === currUrlParams.tree && nextUrlParams.method === currUrlParams.method &&
|
||||
nonRoutingTreesOnCreate.indexOf(nextUrlParams.tree.toLowerCase()) >= 0) {
|
||||
//this means we're coming from a path like /content/content/edit/1234?create=true to the created path like /content/content/edit/9999
|
||||
//check if there is a query string to indicate that a "soft redirect" is taking place, if so we are not changing navigation
|
||||
if (nextUrlParams.sr === true) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -204,6 +199,18 @@ function navigationService($routeParams, $location, $q, $injector, eventsService
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @ngdoc method
|
||||
* @name umbraco.services.navigationService#setSoftRedirect
|
||||
* @methodOf umbraco.services.navigationService
|
||||
*
|
||||
* @description
|
||||
* utility to set a special query string to indicate that the pending navigation change is a soft redirect
|
||||
*/
|
||||
setSoftRedirect: function () {
|
||||
$location.search("sr", true);
|
||||
},
|
||||
|
||||
/**
|
||||
* @ngdoc method
|
||||
* @name umbraco.services.navigationService#retainQueryStrings
|
||||
|
||||
@@ -155,7 +155,13 @@ app.run(['$rootScope', '$route', '$location', 'urlHelper', 'navigationService',
|
||||
currentRouteParams = toRetain;
|
||||
}
|
||||
else {
|
||||
currentRouteParams = angular.copy(next.params);
|
||||
currentRouteParams = angular.copy(next.params);
|
||||
}
|
||||
|
||||
//always clear the 'sr' query string (soft redirect) if it exists
|
||||
if (currentRouteParams.sr) {
|
||||
currentRouteParams.sr = null;
|
||||
$route.updateParams(currentRouteParams);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user