diff --git a/app/controllers/controller.js b/app/controllers/controller.js index 6c274f5..a91561a 100644 --- a/app/controllers/controller.js +++ b/app/controllers/controller.js @@ -340,6 +340,7 @@ angular.module("umbraco").controller("Imulus.ArchetypeController", function ($sc } $scope.focusFieldset(newFieldset); + $scope.handleMandatoryValidation(); } } @@ -349,6 +350,7 @@ angular.module("umbraco").controller("Imulus.ArchetypeController", function ($sc $scope.setDirty(); $scope.model.value.fieldsets.splice($index, 1); $scope.$broadcast("archetypeRemoveFieldset", {index: $index}); + $scope.handleMandatoryValidation(); } } } @@ -808,6 +810,20 @@ angular.module("umbraco").controller("Imulus.ArchetypeController", function ($sc }); }); + $scope.$on("formSubmitting", function (ev, args) { + $scope.handleMandatoryValidation(); + }); + + // handle mandatory validation of the entire Archetype + // - no fieldsets = not valid + $scope.handleMandatoryValidation = function () { + var valid = true; + if ($scope.model.validation && $scope.model.validation.mandatory) { + valid = $scope.model.value.fieldsets && $scope.model.value.fieldsets.length > 0; + } + $scope.model.mandatoryValidation = valid ? "valid" : null; + } + function toUtc(date) { if (!date) { return null; diff --git a/app/views/archetype.default.html b/app/views/archetype.default.html index f3b8baf..0d3d229 100644 --- a/app/views/archetype.default.html +++ b/app/views/archetype.default.html @@ -10,6 +10,10 @@ + + + Required +