diff --git a/app/Umbraco/Umbraco.Archetype/Models/ArchetypePreValue.cs b/app/Umbraco/Umbraco.Archetype/Models/ArchetypePreValue.cs index d670bae..6c99901 100644 --- a/app/Umbraco/Umbraco.Archetype/Models/ArchetypePreValue.cs +++ b/app/Umbraco/Umbraco.Archetype/Models/ArchetypePreValue.cs @@ -49,6 +49,9 @@ namespace Archetype.Models [JsonProperty("hidePropertyLabel")] public bool HidePropertyLabel { get; set; } + [JsonProperty("minFieldsets", NullValueHandling = NullValueHandling.Ignore)] + public int MinFieldsets { get; set; } + [JsonProperty("maxFieldsets", NullValueHandling = NullValueHandling.Ignore)] public int MaxFieldsets { get; set; } diff --git a/app/controllers/controller.js b/app/controllers/controller.js index 358062a..2f538f7 100644 --- a/app/controllers/controller.js +++ b/app/controllers/controller.js @@ -1,5 +1,5 @@ {{VERSION}} -angular.module("umbraco").controller("Imulus.ArchetypeController", function ($scope, $http, $filter, assetsService, angularHelper, notificationsService, $timeout, fileManager, entityResource, archetypeService, archetypeLabelService, archetypeCacheService, archetypePropertyEditorResource) { +angular.module("umbraco").controller("Imulus.ArchetypeController", function ($scope, $http, $filter, $interpolate, assetsService, angularHelper, notificationsService, $timeout, fileManager, entityResource, archetypeService, archetypeLabelService, archetypeCacheService, archetypePropertyEditorResource, archetypeLocalizationService) { // Variables. var draggedParent; @@ -541,6 +541,13 @@ angular.module("umbraco").controller("Imulus.ArchetypeController", function ($sc $timeout(function () { $scope.handleMandatoryValidation(); }, 50); + + // localize the message for minimum fieldsets validation errors + archetypeLocalizationService.localize("minFieldsetsMessage").then(function (value) { + value = value || "You must add minimum {{minFieldsets}} items"; + var exp = $interpolate(value); + $scope.minFieldsetsMessage = exp({ minFieldsets: $scope.model.config.minFieldsets }); + }); } function addDefaultProperties(fieldsets) @@ -798,6 +805,13 @@ angular.module("umbraco").controller("Imulus.ArchetypeController", function ($sc } } + $scope.minFieldsetsFulfilled = function () { + if (!$scope.model.config.minFieldsets) { + return true; + } + return $scope.numberOfEnabledFieldsets() >= $scope.model.config.minFieldsets; + } + //custom js if ($scope.model.config.customJsPath) { assetsService.loadJs($scope.model.config.customJsPath); diff --git a/app/views/archetype.config.fieldset.dialog.html b/app/views/archetype.config.fieldset.dialog.html index a686220..e296528 100644 --- a/app/views/archetype.config.fieldset.dialog.html +++ b/app/views/archetype.config.fieldset.dialog.html @@ -14,6 +14,10 @@
+
+ + +
diff --git a/app/views/archetype.default.html b/app/views/archetype.default.html index 3a2c754..087b09d 100644 --- a/app/views/archetype.default.html +++ b/app/views/archetype.default.html @@ -14,6 +14,10 @@
Required
+ + +
{{minFieldsetsMessage}}
+