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 0c39bdfa38..4576f3344b 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 @@ -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 diff --git a/src/Umbraco.Web.UI.Client/src/views/media/media.edit.controller.js b/src/Umbraco.Web.UI.Client/src/views/media/media.edit.controller.js index b74cfeb463..0895ded13c 100644 --- a/src/Umbraco.Web.UI.Client/src/views/media/media.edit.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/media/media.edit.controller.js @@ -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; }); diff --git a/src/Umbraco.Web/Editors/ContentController.cs b/src/Umbraco.Web/Editors/ContentController.cs index 573439f4e4..f8a75a23d1 100644 --- a/src/Umbraco.Web/Editors/ContentController.cs +++ b/src/Umbraco.Web/Editors/ContentController.cs @@ -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; } diff --git a/src/Umbraco.Web/Editors/MediaController.cs b/src/Umbraco.Web/Editors/MediaController.cs index 12a35e3b20..e03f55a785 100644 --- a/src/Umbraco.Web/Editors/MediaController.cs +++ b/src/Umbraco.Web/Editors/MediaController.cs @@ -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; diff --git a/src/Umbraco.Web/Models/ContentEditing/ContentItemDisplayBase.cs b/src/Umbraco.Web/Models/ContentEditing/ContentItemDisplayBase.cs index c01470f7e4..3a13a85f78 100644 --- a/src/Umbraco.Web/Models/ContentEditing/ContentItemDisplayBase.cs +++ b/src/Umbraco.Web/Models/ContentEditing/ContentItemDisplayBase.cs @@ -11,6 +11,7 @@ namespace Umbraco.Web.Models.ContentEditing protected ContentItemDisplayBase() { Notifications = new List(); + Errors = new Dictionary(); } ///