From 3b0da9be557cdb14a78cad91ccee4e70b282ec12 Mon Sep 17 00:00:00 2001 From: Marta Date: Mon, 22 Nov 2021 00:12:01 +0100 Subject: [PATCH] #7902 displaying messages on cancelled item creation (#7943) * #7902 displaying messages on cancelled item creation * remove debugger Co-authored-by: Nathan Woulfe --- .../components/content/edit.controller.js | 63 ++++++++++--------- 1 file changed, 35 insertions(+), 28 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js index 50a32e0b05..ae9f0121ca 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js @@ -602,8 +602,6 @@ $scope.page.buttonGroupState = 'error'; handleHttpException(err); }); - - }, close: function () { overlayService.close(); @@ -641,13 +639,14 @@ overlayService.close(); return $q.when(data); }, - function (err) { - clearDirtyState($scope.content.variants); - model.submitButtonState = "error"; - //re-map the dialog model since we've re-bound the properties - dialog.variants = $scope.content.variants; - handleHttpException(err); - }); + function (err) { + clearDirtyState($scope.content.variants); + model.submitButtonState = "error"; + //re-map the dialog model since we've re-bound the properties + dialog.variants = $scope.content.variants; + + handleHttpException(err); + }); }, close: function () { overlayService.close(); @@ -699,14 +698,18 @@ clearNotifications($scope.content); overlayService.close(); return $q.when(data); - }, - function (err) { - clearDirtyState($scope.content.variants); - model.submitButtonState = "error"; - //re-map the dialog model since we've re-bound the properties - dialog.variants = $scope.content.variants; - handleHttpException(err); - }); + }, function (err) { + clearDirtyState($scope.content.variants); + model.submitButtonState = "error"; + //re-map the dialog model since we've re-bound the properties + dialog.variants = $scope.content.variants; + + //ensure error messages are displayed + formHelper.showNotifications(err.data); + clearNotifications($scope.content); + + handleHttpException(err); + }); }, close: function () { overlayService.close(); @@ -760,20 +763,24 @@ clearNotifications($scope.content); overlayService.close(); return $q.when(data); - }, - function (err) { - clearDirtyState($scope.content.variants); - //model.submitButtonState = "error"; - // Because this is the "save"-action, then we actually save though there was a validation error, therefor we will show success and display the validation errors politely. - if(err && err.data && err.data.ModelState && Object.keys(err.data.ModelState).length > 0) { - model.submitButtonState = "success"; - } else { - model.submitButtonState = "error"; - } + }, function (err) { + clearDirtyState($scope.content.variants); + //model.submitButtonState = "error"; + // Because this is the "save"-action, then we actually save though there was a validation error, therefor we will show success and display the validation errors politely. + if(err && err.data && err.data.ModelState && Object.keys(err.data.ModelState).length > 0) { + model.submitButtonState = "success"; + } else { + model.submitButtonState = "error"; //re-map the dialog model since we've re-bound the properties dialog.variants = $scope.content.variants; + + //ensure error messages are displayed + formHelper.showNotifications(err.data); + clearNotifications($scope.content); + handleHttpException(err); - }); + } + }) }, close: function (oldModel) { overlayService.close();