From e640a9b4f47b40f8830862437123ab065d25cff5 Mon Sep 17 00:00:00 2001 From: kgiszewski Date: Mon, 14 Dec 2015 09:53:01 -0500 Subject: [PATCH] This depends on a core PR. --- app/controllers/controller.js | 4 ++-- app/directives/archetypeproperty.js | 14 ++++++++------ app/directives/archetypesubmitwatcher.js | 3 ++- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/app/controllers/controller.js b/app/controllers/controller.js index 264ea27..1af7336 100644 --- a/app/controllers/controller.js +++ b/app/controllers/controller.js @@ -468,7 +468,7 @@ angular.module("umbraco").controller("Imulus.ArchetypeController", function ($sc $scope.activeSubmitWatcher++; return $scope.activeSubmitWatcher; } - $scope.submitWatcherOnSubmit = function () { - $scope.$broadcast("archetypeFormSubmitting"); + $scope.submitWatcherOnSubmit = function (args) { + $scope.$broadcast("archetypeFormSubmitting", args); } }); diff --git a/app/directives/archetypeproperty.js b/app/directives/archetypeproperty.js index 58430f3..f5a2ab9 100644 --- a/app/directives/archetypeproperty.js +++ b/app/directives/archetypeproperty.js @@ -115,14 +115,16 @@ angular.module("umbraco.directives").directive('archetypeProperty', function ($c }); scope.$on('archetypeFormSubmitting', function (ev, args) { - // validate all fieldset properties - _.each(scope.fieldset.properties, function (property) { - archetypeService.validateProperty(scope.fieldset, property, configFieldsetModel); - }); + if(args.action !== 'save') { + // validate all fieldset properties + _.each(scope.fieldset.properties, function (property) { + archetypeService.validateProperty(scope.fieldset, property, configFieldsetModel); + }); - var validationKey = "validation-f" + scope.fieldsetIndex; + var validationKey = "validation-f" + scope.fieldsetIndex; - ngModelCtrl.$setValidity(validationKey, scope.fieldset.isValid); + ngModelCtrl.$setValidity(validationKey, scope.fieldset.isValid); + } // did the value change (if it did, it most likely did so during the "formSubmitting" event) var property = archetypeService.getFieldsetProperty(scope); diff --git a/app/directives/archetypesubmitwatcher.js b/app/directives/archetypesubmitwatcher.js index d2b06c7..75b4ac0 100644 --- a/app/directives/archetypesubmitwatcher.js +++ b/app/directives/archetypesubmitwatcher.js @@ -3,9 +3,10 @@ angular.module("umbraco.directives").directive('archetypeSubmitWatcher', functio // call the load callback on scope to obtain the ID of this submit watcher var id = scope.loadCallback(); scope.$on("formSubmitting", function (ev, args) { + // on the "formSubmitting" event, call the submit callback on scope to notify the Archetype controller to do it's magic if (id == scope.activeSubmitWatcher) { - scope.submitCallback(); + scope.submitCallback(args); } }); }