From a32190066cacc439620184ed5e4f43838475b916 Mon Sep 17 00:00:00 2001 From: "ala'n (Alexey Stsefanovich)" Date: Mon, 29 Jan 2024 20:21:13 +0100 Subject: [PATCH] [EAK-504] Fix review suggestions --- .../aem/toolkit/api/annotations/policies/MaxChildren.java | 4 ++++ .../toolkit/plugin/handlers/common/MaxChildrenHandler.java | 6 +++--- .../apps/etoolbox-authoring-kit/policies/js/maxChildren.js | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/com/exadel/aem/toolkit/api/annotations/policies/MaxChildren.java b/core/src/main/java/com/exadel/aem/toolkit/api/annotations/policies/MaxChildren.java index 1ad8695e5..c50179e52 100644 --- a/core/src/main/java/com/exadel/aem/toolkit/api/annotations/policies/MaxChildren.java +++ b/core/src/main/java/com/exadel/aem/toolkit/api/annotations/policies/MaxChildren.java @@ -18,6 +18,9 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import com.exadel.aem.toolkit.api.annotations.meta.ValueRestriction; +import com.exadel.aem.toolkit.api.annotations.meta.ValueRestrictions; + @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) public @interface MaxChildren { @@ -25,6 +28,7 @@ * Specifies the maximum number of children allowed for container component * @return Long value, 0 or greater */ + @ValueRestriction(ValueRestrictions.NON_NEGATIVE) long value(); /** diff --git a/plugin/src/main/java/com/exadel/aem/toolkit/plugin/handlers/common/MaxChildrenHandler.java b/plugin/src/main/java/com/exadel/aem/toolkit/plugin/handlers/common/MaxChildrenHandler.java index b9e212b8b..6647db81d 100644 --- a/plugin/src/main/java/com/exadel/aem/toolkit/plugin/handlers/common/MaxChildrenHandler.java +++ b/plugin/src/main/java/com/exadel/aem/toolkit/plugin/handlers/common/MaxChildrenHandler.java @@ -30,12 +30,12 @@ public class MaxChildrenHandler implements Handler { /** * Name of the listener to resolve max children limit for `policies` js module */ - public static final String MAX_LIMIT_RESOLVER_NAME = "resolvemaxchildren"; + public static final String MAX_CHILDREN_RESOLVER_NAME = "resolvemaxchildren"; /** * Format of default max children limit resolver */ - private static final String MAX_LIMIT_RESOLVER_FORMAT = "() => %d"; + private static final String MAX_CHILDREN_RESOLVER_FORMAT = "() => %d"; /** @@ -61,7 +61,7 @@ private static void populate(MaxChildren rule, Target target) { .attribute(DialogConstants.PN_PRIMARY_TYPE, DialogConstants.NT_EDIT_CONFIG) .getOrCreateTarget(DialogConstants.NN_LISTENERS) .attribute(DialogConstants.PN_PRIMARY_TYPE, DialogConstants.NT_LISTENERS) - .attribute(MAX_LIMIT_RESOLVER_NAME, String.format(MAX_LIMIT_RESOLVER_FORMAT, rule.value())); + .attribute(MAX_CHILDREN_RESOLVER_NAME, String.format(MAX_CHILDREN_RESOLVER_FORMAT, rule.value())); } } diff --git a/ui.apps/src/main/content/jcr_root/apps/etoolbox-authoring-kit/policies/js/maxChildren.js b/ui.apps/src/main/content/jcr_root/apps/etoolbox-authoring-kit/policies/js/maxChildren.js index 2a56f11c5..e8b4ebf65 100644 --- a/ui.apps/src/main/content/jcr_root/apps/etoolbox-authoring-kit/policies/js/maxChildren.js +++ b/ui.apps/src/main/content/jcr_root/apps/etoolbox-authoring-kit/policies/js/maxChildren.js @@ -29,7 +29,7 @@ ns.MaxChildrenLimiter.LIMIT_RESOLVER_PROPERTY = 'eak-max-children'; /** The default limit active message */ - ns.MaxChildrenLimiter.ERROR_MESSAGE = ns.I18n.get('Maximum number of allowed components reached'); + ns.MaxChildrenLimiter.ERROR_MESSAGE = ns.I18n.get('Maximum number of allowed components is reached'); /** The name of attribute to store limit message and marker */ ns.MaxChildrenLimiter.ERROR_MESSAGE_ATTR = 'data-max-children-marker';