Fixes: U4-6879 Validation issues when creating new content and cancelling save event.
This commit is contained in:
@@ -55,6 +55,12 @@ function contentEditingHelper(fileManager, $q, $location, $routeParams, notifica
|
||||
err: err,
|
||||
rebindCallback: self.reBindChangedProperties(args.content, err.data)
|
||||
});
|
||||
//show any notifications
|
||||
if (angular.isArray(err.data.notifications)) {
|
||||
for (var i = 0; i < err.data.notifications.length; i++) {
|
||||
notificationsService.showNotification(err.data.notifications[i]);
|
||||
}
|
||||
}
|
||||
args.scope.busy = false;
|
||||
deferred.reject(err);
|
||||
});
|
||||
@@ -466,13 +472,13 @@ function contentEditingHelper(fileManager, $q, $location, $routeParams, notifica
|
||||
* @description
|
||||
* Changes the location to be editing the newly created content after create was successful.
|
||||
* 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.
|
||||
* 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, modelState) {
|
||||
|
||||
//only continue if we are currently in create mode and if there is no 'Name' modelstate errors
|
||||
// since we need at least a name to create content.
|
||||
if ($routeParams.create && (!modelState || !modelState["Name"])) {
|
||||
if ($routeParams.create && (id > 0 && (!modelState || !modelState["Name"]))) {
|
||||
|
||||
//need to change the location to not be in 'create' mode. Currently the route will be something like:
|
||||
// /belle/#/content/edit/1234?doctype=newsArticle&create=true
|
||||
|
||||
@@ -108,6 +108,13 @@ function mediaEditController($scope, $routeParams, appState, mediaResource, enti
|
||||
rebindCallback: contentEditingHelper.reBindChangedProperties($scope.content, err.data)
|
||||
});
|
||||
|
||||
//show any notifications
|
||||
if (angular.isArray(err.data.notifications)) {
|
||||
for (var i = 0; i < err.data.notifications.length; i++) {
|
||||
notificationsService.showNotification(err.data.notifications[i]);
|
||||
}
|
||||
}
|
||||
|
||||
editorState.set($scope.content);
|
||||
$scope.busy = false;
|
||||
});
|
||||
|
||||
@@ -270,6 +270,7 @@ namespace Umbraco.Web.Editors
|
||||
{
|
||||
//publish the item and check if it worked, if not we will show a diff msg below
|
||||
publishStatus = Services.ContentService.SaveAndPublishWithStatus(contentItem.PersistedContent, Security.CurrentUser.Id);
|
||||
wasCancelled = publishStatus.Result.StatusType == PublishStatusType.FailedCancelledByEvent;
|
||||
}
|
||||
|
||||
//return the updated model
|
||||
@@ -315,6 +316,14 @@ namespace Umbraco.Web.Editors
|
||||
|
||||
UpdatePreviewContext(contentItem.PersistedContent.Id);
|
||||
|
||||
//If the item is new and the operation was cancelled, we need to return a different
|
||||
// status code so the UI can handle it since it won't be able to redirect since there
|
||||
// is no Id to redirect to!
|
||||
if (wasCancelled && IsCreatingAction(contentItem.Action))
|
||||
{
|
||||
throw new HttpResponseException(Request.CreateValidationErrorResponse(display));
|
||||
}
|
||||
|
||||
return display;
|
||||
}
|
||||
|
||||
|
||||
@@ -285,6 +285,14 @@ namespace Umbraco.Web.Editors
|
||||
else
|
||||
{
|
||||
AddCancelMessage(display);
|
||||
|
||||
//If the item is new and the operation was cancelled, we need to return a different
|
||||
// status code so the UI can handle it since it won't be able to redirect since there
|
||||
// is no Id to redirect to!
|
||||
if (saveStatus.Result.StatusType == OperationStatusType.FailedCancelledByEvent && IsCreatingAction(contentItem.Action))
|
||||
{
|
||||
throw new HttpResponseException(Request.CreateValidationErrorResponse(display));
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
@@ -11,6 +11,7 @@ namespace Umbraco.Web.Models.ContentEditing
|
||||
protected ContentItemDisplayBase()
|
||||
{
|
||||
Notifications = new List<Notification>();
|
||||
Errors = new Dictionary<string, object>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user