From e98cd3fe8f0c03d52b272e181f85ceaaf26ac2a8 Mon Sep 17 00:00:00 2001 From: Warren Buckley Date: Wed, 3 Oct 2018 16:42:58 +0100 Subject: [PATCH] WIP - Get the custom content app icon as invalid if my form in my content app contains errors in the form --- .../validation/valformmanager.directive.js | 13 ++++++++++--- .../directives/validation/valsubview.directive.js | 5 +++-- .../components/editor/umb-editor-navigation.html | 2 +- .../components/editor/umb-editor-sub-view.html | 14 +++++++++----- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/validation/valformmanager.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/validation/valformmanager.directive.js index b201c877a3..eaf67bcb91 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/validation/valformmanager.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/validation/valformmanager.directive.js @@ -46,6 +46,12 @@ function valFormManager(serverValidationManager, $rootScope, $timeout, $location }, link: function (scope, element, attr, ctrls) { + function notifySubView() { + if (subView){ + subView.valStatusChanged({ form: formCtrl, showValidation: scope.showValidation }); + } + } + var formCtrl = ctrls[0]; var parentFormMgr = ctrls.length > 0 ? ctrls[1] : null; var subView = ctrls.length > 1 ? ctrls[2] : null; @@ -84,9 +90,7 @@ function valFormManager(serverValidationManager, $rootScope, $timeout, $location }, function (e) { scope.$broadcast("valStatusChanged", { form: formCtrl }); - if (subView){ - subView.valStatusChanged({ form: formCtrl }); - } + notifySubView(); //find all invalid elements' .control-group's and apply the error class var inError = element.find(".control-group .ng-invalid").closest(".control-group"); @@ -108,6 +112,7 @@ function valFormManager(serverValidationManager, $rootScope, $timeout, $location if (serverValidationManager.items.length > 0 || (parentFormMgr && parentFormMgr.showValidation)) { element.addClass(SHOW_VALIDATION_CLASS_NAME); scope.showValidation = true; + notifySubView(); } var unsubscribe = []; @@ -116,6 +121,7 @@ function valFormManager(serverValidationManager, $rootScope, $timeout, $location unsubscribe.push(scope.$on(SAVING_EVENT_NAME, function(ev, args) { element.addClass(SHOW_VALIDATION_CLASS_NAME); scope.showValidation = true; + notifySubView(); //set the flag so we can check to see if we should display the error. isSavingNewItem = $routeParams.create; })); @@ -125,6 +131,7 @@ function valFormManager(serverValidationManager, $rootScope, $timeout, $location //remove validation class element.removeClass(SHOW_VALIDATION_CLASS_NAME); scope.showValidation = false; + notifySubView(); //clear form state as at this point we retrieve new data from the server //and all validation will have cleared at this point formCtrl.$setPristine(); diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/validation/valsubview.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/validation/valsubview.directive.js index 8f4d93090b..097602fe20 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/validation/valsubview.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/validation/valsubview.directive.js @@ -19,14 +19,15 @@ if (subViewContent.length > 0) { $scope.model.hasError = true; - $element.addClass("show-validation"); + $scope.model.errorClass = args.showValidation ? 'show-validation' : null; } else { $scope.model.hasError = false; - $element.removeClass("show-validation"); + $scope.model.errorClass = null; } } else { $scope.model.hasError = false; + $scope.model.errorClass = null; } } } diff --git a/src/Umbraco.Web.UI.Client/src/views/components/editor/umb-editor-navigation.html b/src/Umbraco.Web.UI.Client/src/views/components/editor/umb-editor-navigation.html index 2bb6c1107b..ee46a89490 100644 --- a/src/Umbraco.Web.UI.Client/src/views/components/editor/umb-editor-navigation.html +++ b/src/Umbraco.Web.UI.Client/src/views/components/editor/umb-editor-navigation.html @@ -2,7 +2,7 @@
  • + ng-class="item.errorClass"> - + - + + +
    - -