Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call rebindCallback on errors as well #9688

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@
* @param {any} app the active content app
*/
function createButtons(content) {

var isBlueprint = content.isBlueprint;

if ($scope.page.isNew && $location.path().search(/contentBlueprints/i) !== -1) {
Expand Down Expand Up @@ -474,6 +474,10 @@
return $q.when(data);
},
function (err) {

//needs to be manually set for infinite editing mode
$scope.page.isNew = false;

syncTreeNode($scope.content, $scope.content.path);

resetNestedFieldValiation(fieldsToRollback);
Expand Down Expand Up @@ -981,7 +985,7 @@
$scope.appChanged = function (activeApp) {

$scope.activeApp = activeApp;

_.forEach($scope.content.apps, function (app) {
app.active = false;
if (app.alias === $scope.activeApp.alias) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function contentEditingHelper(fileManager, $q, $location, $routeParams, editorSt
//when true, the url will change but it won't actually re-route
//this is merely here for compatibility, if only the content/media/members used this service we'd prob be ok but tons of editors
//use this service unfortunately and probably packages too.
args.softRedirect = false;
args.softRedirect = false;
}


Expand Down Expand Up @@ -123,7 +123,13 @@ function contentEditingHelper(fileManager, $q, $location, $routeParams, editorSt
self.handleSaveError({
showNotifications: args.showNotifications,
softRedirect: args.softRedirect,
err: err
err: err,
rebindCallback: function () {
// if the error contains data, we want to map that back as we want to continue editing this save. Especially important when the content is new as the returned data will contain ID etc.
if(err.data) {
rebindCallback.apply(self, [args.content, err.data]);
}
}
});

//update editor state to what is current
Expand Down Expand Up @@ -298,7 +304,7 @@ function contentEditingHelper(fileManager, $q, $location, $routeParams, editorSt
}

// if publishing is allowed also allow schedule publish
// we add this manually becuase it doesn't have a permission so it wont
// we add this manually becuase it doesn't have a permission so it wont
// get picked up by the loop through permissions
if (_.contains(args.content.allowedActions, "U")) {
buttons.subButtons.push(createButtonDefinition("SCHEDULE"));
Expand Down Expand Up @@ -622,7 +628,7 @@ function contentEditingHelper(fileManager, $q, $location, $routeParams, editorSt
if (!args.err) {
throw "args.err cannot be null";
}

//When the status is a 400 status with a custom header: X-Status-Reason: Validation failed, we have validation errors.
//Otherwise the error is probably due to invalid data (i.e. someone mucking around with the ids or something).
//Or, some strange server error
Expand All @@ -640,7 +646,7 @@ function contentEditingHelper(fileManager, $q, $location, $routeParams, editorSt

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).
// soft-redirecting which means the URL will change but the route wont (i.e. creating content).

// In this case we need to detect what properties have changed and re-bind them with the server data.
if (args.rebindCallback && angular.isFunction(args.rebindCallback)) {
Expand Down Expand Up @@ -687,7 +693,7 @@ function contentEditingHelper(fileManager, $q, $location, $routeParams, editorSt
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).
// soft-redirecting which means the URL will change but the route wont (i.e. creating content).

// In this case we need to detect what properties have changed and re-bind them with the server data.
if (args.rebindCallback && angular.isFunction(args.rebindCallback)) {
Expand Down Expand Up @@ -723,7 +729,7 @@ function contentEditingHelper(fileManager, $q, $location, $routeParams, editorSt
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;
Expand Down