Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding more HTML input types to FieldType #1425

Merged
merged 3 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ public enum FieldType {
IMAGE("image"),
TELEPHONE("tel"),
PASSWORD("password"),
RANGE("range");
RANGE("range"),
TalmizAhmed marked this conversation as resolved.
Show resolved Hide resolved
COLOR("color"),
URL("url"),
HIDDEN("hidden");

private String value;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public interface FormContainer extends Container {
*/
String PN_CLIENT_LIB_REF = GuideConstants.CLIENT_LIB_REF;

String DEFAULT_FORMS_SPEC_VERSION = "0.14.1";
String DEFAULT_FORMS_SPEC_VERSION = "0.14.2";

/**
* Returns form metadata {@link FormMetaData}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,14 @@ public static void testSchemaValidation(@NotNull Object model) {
// create an instance of the JsonSchemaFactory using version flag
JsonSchemaFactory schemaFactory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7);
try {
InputStream schemaStream = Utils.class.getResourceAsStream("/schema/0.14.1/adaptive-form.schema.json");
InputStream schemaStream = Utils.class.getResourceAsStream("/schema/0.14.2/adaptive-form.schema.json");
JsonSchema schema = schemaFactory.getSchema(schemaStream);
// read data from the stream and store it into JsonNode
JsonNode json = objectMapper.readTree(jsonStream);
// if there is a version bump of schema, then it needs to be validated against its corresponding sling model here
// by explicitly checking the model implementation
if (!(model instanceof FormContainerImpl)) {
InputStream formContainerTemplate = Utils.class.getResourceAsStream("/schema/0.14.1/form.json");
InputStream formContainerTemplate = Utils.class.getResourceAsStream("/schema/0.14.2/form.json");
JsonNode formContainerTemplateNode = objectMapper.readTree(formContainerTemplate);
((ObjectNode) formContainerTemplateNode).putArray("items").add(json);
json = formContainerTemplateNode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ void testGetAdaptiveFormCustomVersion() throws Exception {
void testGetAdaptiveFormDefaultVersion() throws Exception {
FormContainer formContainer = Utils.getComponentUnderTest(PATH_FORM_1, FormContainer.class, context);
assertNotNull(formContainer.getAdaptiveFormVersion());
assertEquals("0.14.1", formContainer.getAdaptiveFormVersion());
assertEquals("0.14.2", formContainer.getAdaptiveFormVersion());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
":itemsOrder": [
"textinput"
],
"adaptiveform": "0.14.1",
"adaptiveform": "0.14.2",
"metadata": {
"version": "1.0.0",
"grammar": "json-formula-1.0.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"$id": "classpath:/schema/0.14.2/adaptive-form-aem-allowed-components.schema.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"title": "Allowed Components object for the current panel.",
"description": "This is applicable only if the panel's layout is grid system. This property is useful if needs to show list of allowed components in the client while authoring the panel.",
"properties": {
"components": {
"type": "array",
"title": "List of simple objects representing all Allowed Components for the given panel"
},
"applicable": {
"type": "boolean",
"title": "Is the given panel contained by a page, with authored template structure and is the given panel set as editable (unlocked)",
"description": "true if the template has structure support and the panel is editable, false otherwise"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"$id": "classpath:/schema/0.14.2/adaptive-form-aem-responsive-grid-properties.schema.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"allowedComponents": {
"$ref": "./adaptive-form-aem-allowed-components.schema.json"
},
"appliedCssClassNames": {
"title": "CSS classes delimited using a SPACE character",
"description": "Describes the style system information associated with the current form element",
"type": "string",
"examples": [
{
"appliedCssClassNames": "outlined red-border"
}
]
},
"gridClassNames": {
"title": "The CSS class names to be applied to the current panel delimited using a SPACE character",
"description": "This is applicable only if the panel's layout is grid system.",
"type": "string",
"examples": [
{
"gridClassNames": "aem-Grid aem-Grid--12 aem-Grid--default--12"
}
]
},
"columnClassNames": {
"title": "The CSS class names associated with each responsive grid column and listed by column name",
"description": "This is applicable only if the panel's layout is grid system.",
"type": "object",
"examples": [
{
"columnClassNames": {
"title_v3": "aem-GridColumn aem-GridColumn--default--12"
}
}
]
},
"columnCount": {
"title": "The number of columns available for direct children in the panel.",
"description": "This is applicable only if the panel's layout is grid system.",
"type": "number",
"examples": [
{
"columnCount": 12
}
]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"$id": "classpath:/schema/0.14.2/adaptive-form-container-dor-properties.schema.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"additionalProperties": false,
"properties": {
"dorType": {
"title": "DOR Type",
"description": "Describes the type of Document of Record (DOR)",
"type": "string",
"enum": [
"generate",
"select"
],
"examples": [
{
"dorType": "generate"
}
]
},
"dorTemplateRef": {
"title": "DOR Template Reference",
"description": "Reference to the template for the Document of Record (DOR).",
"type": "string",
"examples": [
{
"dorTemplateRef": "/content/dam/formsanddocuments/acro form conversion.pdf"
}
]
},
"dorTemplateType": {
"title": "DOR Template Type",
"description": "Type of the template for the Document of Record (DOR).",
"enum": [
"acroform",
"xfa"
],
"type": "string"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
{
"$id": "classpath:/schema/0.14.2/adaptive-form-data-constraints.schema.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Constraints applicable to fields",
"type": "object",
"properties": {
"accept": {
"title": "The constraint is applicable for fields having type file or with fields having type string and format as data-url / binary. It signifies the list of IANA media types that fields can accept.",
"type": "array",
"items": {
"type": "string"
}
},
"enforceEnum": {
"title": "Whether a user can enter a value that is not present in the enum array",
"description": "If set to true, a user will be able to enter any other value that is not in the list of enum. That generally means that enum is used a aid for users to enter the value but is not a validation constraint.",
"type": "boolean"
},
"exclusiveMaximum": {
"title": "maximum value or date (exclusive)",
"oneOf": [
{
"type": "string",
"format": "date"
},
{
"type": "number"
}
]
},
"exclusiveMinimum": {
"title": "minimum value or date (exclusive)",
"oneOf": [
{
"type": "string",
"format": "date"
},
{
"type": "number"
}
]
},
"format": {
"title": "formats as specified in JSON Schema. The constraint is applicable only for string data types",
"type": "string",
"enum": [
"date",
"email",
"date-time",
"data-url"
]
},
"maxFileSize": {
"title": "The constraint is applicable for fields having type file or with fields having type string and format as data-url / binary. It signifies the maximum file size as per IEC specification",
"type": "string"
},
"maximum": {
"title": "maximum value or date (inclusive)",
"oneOf": [
{
"type": "string",
"format": "date"
},
{
"type": "number"
}
]
},
"maxItems": {
"title": "Maximum number of items in a field/panel capturing array data",
"type": "number"
},
"maxOccur": {
"title": "Maximum number of occurrence of repeating panel - capturing array data,",
"type": "number"
},
"maxLength": {
"title": "Maximum Length of the data. The constraint is applicable only for string data types",
"type": "number"
},
"minimum": {
"title": "minimum value or date (inclusive)",
"oneOf": [
{
"type": "string",
"format": "date"
},
{
"type": "number"
}
]
},
"minItems": {
"title": "Minimum number of items in a field/panel capturing array data",
"type": "number"
},
"minOccur": {
"title": "Minimum number of occurrence of repeating panel - capturing array data",
"type": "number"
},
"minLength": {
"title": "Minimum Length of the data. The constraint is applicable only for string data types",
"type": "number"
},
"pattern": {
"title": "The regular expression against which the value will be compared against",
"type": "string",
"format": "regex"
},
"required": {
"type": "boolean",
"title": "Indicates whether the value is required or not"
},
"step": {
"title": "The constraint is applicable for fields having type number. It signifies the value should be a multipleOf some number",
"type": "number"
},
"type": {
"title": "Data Type of the value that this field captures. When submitting the value will be coerced into the format specified by the type",
"type": "string",
"enum": [
"string",
"file",
"number",
"array",
"object",
"string[]",
"file[]",
"number[]",
"boolean[]",
"boolean"
]
},
"uniqueItems": {
"title": "Array items must be unique",
"type": "boolean"
},
"validationExpression": {
"type": "string",
"format": "json-formula"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"$id": "classpath:/schema/0.14.2/adaptive-form-data-layer.schema.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"@id": {
"type": "string",
"title": "Id of the form element"
},
"@type": {
"type": "string",
"title": "Type of the form element used in the data layer"
},
"repo:modifyDate": {
"type": "string",
"title": "Last modified date using ISO 8601 standard"
},
"parentId": {
"type": "string",
"title": "Parent id of the form element"
},
"dc:title": {
"type": "string",
"title": "Label of the form element used in the data layer"
},
"dc:description": {
"type": "string",
"title": "Description of the form element used in the data layer"
},
"xdm:text": {
"type": "string",
"title": "Text of the form element used in the data layer"
},
"xdm:linkURL": {
"type": "string",
"title": "Link URL of the form element used in the data layer"
},
"fieldType": {
"title": "Type of widget to show to the user for capturing the data",
"enum": [
"text-input",
"number-input",
"date-input",
"file-input",
"multiline-input",
"drop-down",
"radio-group",
"checkbox-group",
"checkbox",
"switch",
"plain-text",
"button",
"panel",
"image",
"email",
"captcha"
]
}
}
}
Loading