Skip to content
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 @@ -15,6 +15,7 @@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
package com.adobe.cq.forms.core.components.internal.models.v1.form;

import javax.annotation.Nullable;
import javax.annotation.PostConstruct;

import org.apache.sling.api.SlingHttpServletRequest;
Expand All @@ -24,7 +25,6 @@
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.injectorspecific.InjectionStrategy;
import org.apache.sling.models.annotations.injectorspecific.ValueMapValue;
import org.jetbrains.annotations.Nullable;

import com.adobe.cq.export.json.ComponentExporter;
import com.adobe.cq.export.json.ExporterConstants;
Expand Down Expand Up @@ -64,7 +64,6 @@ public class NumberInputImpl extends AbstractFieldImpl implements NumberInput {
@Nullable
private Boolean excludeMinimumCheck;
/** End **/

private Long exclusiveMinimumVaue;
private Long exclusiveMaximumValue;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ public class TextInputImpl extends AbstractFieldImpl implements TextInput {
private Object exclusiveMaximumValue;

/** End of Type number specific constraints **/

@Override
public boolean isMultiLine() {
return multiLine;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,14 @@ default Object[] getDefault() {
return null;
}

/**
* The expression that when evaluated would determine what the displayValue of a field would be
*
* @return display value expression of the field
* @since com.adobe.cq.forms.core.components.models.form 5.2.0
*/
default String getDisplayValueExpression() {
return null;
}

}
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.12.1";
String DEFAULT_FORMS_SPEC_VERSION = "0.12.5";

/**
* Returns form metadata {@link FormMetaData}
Expand All @@ -89,7 +89,7 @@ default String getAdaptiveFormVersion() {
* Returns schema reference
*
* @return reference to schema
*
*
* @since com.adobe.cq.forms.core.components.models.form 2.1.0
*/
@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
*/
@ConsumerType
public interface NumberInput extends Field, NumberConstraint {

@Nullable
@JsonIgnore
default String getEditFormat() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ public abstract class AbstractFieldImpl extends AbstractBaseImpl implements Fiel
@Nullable
protected String editFormat;

@ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL)
@Nullable
protected String displayValueExpression;

@ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = "dataFormat")
@Nullable
protected String dataFormat;
Expand Down Expand Up @@ -181,6 +185,12 @@ public String getEditFormat() {
return editFormat;
}

@Override
@Nullable
public String getDisplayValueExpression() {
return displayValueExpression;
}

@Override
@Nullable
public String getDataFormat() {
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.12.1/adaptive-form.schema.json");
InputStream schemaStream = Utils.class.getResourceAsStream("/schema/0.12.5/adaptive-form.schema.json");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this new property is added via expression editor, I believe expression editor would be persisting the specVersion property in JCR ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I'm raising the PR for that.

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.12.0/form.json");
InputStream formContainerTemplate = Utils.class.getResourceAsStream("/schema/0.12.5/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 @@ -46,6 +46,7 @@ public class DatePickerImplTest {

private static final String PATH_DATEPICKER = CONTENT_ROOT + "/datepicker";
private static final String PATH_DATEPICKER_DATALAYER = CONTENT_ROOT + "/datepicker-datalayer";
private static final String PATH_DATEPICKER_DISPLAY_VALUE_EXPRESSION = CONTENT_ROOT + "/datepicker-displayValueExpression";

private final AemContext context = FormsCoreComponentTestContext.newAemContext();

Expand Down Expand Up @@ -292,4 +293,10 @@ void testJSONExportDataLayer() throws Exception {
FieldUtils.writeField(datePicker, "dataLayerEnabled", true, true);
Utils.testJSONExport(datePicker, Utils.getTestExporterJSONPath(BASE, PATH_DATEPICKER_DATALAYER));
}

@Test
void testJSONExportForDisplayValueExpression() throws Exception {
DatePicker datePicker = Utils.getComponentUnderTest(PATH_DATEPICKER_DISPLAY_VALUE_EXPRESSION, DatePicker.class, context);
Utils.testJSONExport(datePicker, Utils.getTestExporterJSONPath(BASE, PATH_DATEPICKER_DISPLAY_VALUE_EXPRESSION));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public class NumberInputImplTest {
private static final String PATH_NUMBER_INPUT = CONTENT_ROOT + "/numberinput";
private static final String PATH_NUMBER_INPUT_DATALAYER = CONTENT_ROOT + "/numberinput-datalayer";

private static final String PATH_NUMBER_INPUT_DISPLAY_VALUE_EXPRESSION = CONTENT_ROOT + "/numberinput-displayvalueExpression";

private final AemContext context = FormsCoreComponentTestContext.newAemContext();

@BeforeEach
Expand Down Expand Up @@ -366,4 +368,20 @@ void testJSONExportDataLayer() throws Exception {
FieldUtils.writeField(numberInput, "dataLayerEnabled", true, true);
Utils.testJSONExport(numberInput, Utils.getTestExporterJSONPath(BASE, PATH_NUMBER_INPUT_DATALAYER));
}

@Test
void testGetDisplayValueExpression() throws Exception {
NumberInput numberInputMock = Mockito.mock(NumberInput.class);
Mockito.when(numberInputMock.getDisplayValueExpression()).thenCallRealMethod();
assertEquals(null, numberInputMock.getDisplayValueExpression());
NumberInput numberInput = Utils.getComponentUnderTest(PATH_NUMBER_INPUT_DISPLAY_VALUE_EXPRESSION, NumberInput.class, context);
assertEquals("($field.$value & abc)", numberInput.getDisplayValueExpression());
}

@Test
void testJSONExportForDisplayValueExpression() throws Exception {
NumberInput numberInput = Utils.getComponentUnderTest(PATH_NUMBER_INPUT_DISPLAY_VALUE_EXPRESSION, NumberInput.class, context);
Utils.testJSONExport(numberInput, Utils.getTestExporterJSONPath(BASE, PATH_NUMBER_INPUT_DISPLAY_VALUE_EXPRESSION));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public class TextInputImplTest {
private static final String PATH_TEXTINPUT_UNBOUNDFORMELEMENT = CONTENT_ROOT + "/textinput_unboundFormElement";
private static final String PATH_TEXTINPUT_BLANK_DATAREF = CONTENT_ROOT + "/textinput-blank-dataref";
private static final String PATH_TEXTINPUT_BLANK_VALIDATIONEXPRESSION = CONTENT_ROOT + "/textinput-blank-validationExpression";
private static final String PATH_TEXTINPUT_DISPLAY_VALUE_EXPRESSION = CONTENT_ROOT + "/textinput-displayValueExpression";
private static final String PATH_TEXTINPUT_PLACEHOLDER_AUTOCOMPLETE = CONTENT_ROOT + "/textinput-placeholder-autocomplete";

private final AemContext context = FormsCoreComponentTestContext.newAemContext();
Expand Down Expand Up @@ -449,4 +450,10 @@ void testPlaceholderAndAutocomplete() throws Exception {
assertEquals("given-name", textInput.getAutoComplete());
assertEquals("test-placeholder", textInput.getPlaceHolder());
}

@Test
void testJSONExportForDisplayValueExpression() throws Exception {
TextInput textInput = Utils.getComponentUnderTest(PATH_TEXTINPUT_DISPLAY_VALUE_EXPRESSION, TextInput.class, context);
Utils.testJSONExport(textInput, Utils.getTestExporterJSONPath(BASE, PATH_TEXTINPUT_DISPLAY_VALUE_EXPRESSION));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ void testGetAdaptiveFormCustomVersion() throws Exception {
void testGetAdaptiveFormDefaultVersion() throws Exception {
FormContainer formContainer = Utils.getComponentUnderTest(PATH_FORM_1, FormContainer.class, context);
assertNotNull(formContainer.getAdaptiveFormVersion());
assertEquals("0.12.1", formContainer.getAdaptiveFormVersion());
assertEquals("0.12.5", formContainer.getAdaptiveFormVersion());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"id": "datepicker-c7fc29dc99",
"fieldType": "date-input",
"name": "abc",
"type": "string",
"displayValueExpression": "($field.$value & abc)",
"label": {
"value": "def"
},
"events": {
"custom:setProperty": [
"$event.payload"
]
},
"properties": {
"fd:dor": {
"dorExclusion": false
},
"fd:path": "/content/datepicker-displayValueExpression"
},
"format": "date",
":type": "core/fd/components/form/datepicker/v1/datepicker"
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,13 @@
},
"format": "date",
":type": "forms-components-examples/components/form/datepicker"
},
"datepicker-displayValueExpression" : {
"jcr:primaryType": "nt:unstructured",
"sling:resourceType" : "core/fd/components/form/datepicker/v1/datepicker",
"name" : "abc",
"jcr:title" : "def",
"fieldType": "date-input",
"displayValueExpression": "($field.$value & abc)"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,22 @@
},
"fd:path": "/content/forms/af/demo/jcr:content/formcontainerv2",
"fd:schemaType": "BASIC",
"fd:formDataEnabled" : true
"fd:formDataEnabled": true
},
"events": {
"custom:setProperty": [
"$event.payload"
]
},
":itemsOrder": [
"textinput"
],
"adaptiveform": "0.12.5",
"metadata": {
"version": "1.0.0",
"grammar": "json-formula-1.0.0"
},
":type": "core/fd/components/form/container/v2/container",
":items": {
"textinput": {
"id": "textinput-9a52c5fa93",
Expand All @@ -37,17 +51,5 @@
},
":type": "core/fd/components/form/textinput/v1/textinput"
}
},
":itemsOrder" : ["textinput"],
"events": {
"custom:setProperty": [
"$event.payload"
]
},
"metadata": {
"version": "1.0.0",
"grammar": "json-formula-1.0.0"
},
"adaptiveform": "0.12.1",
":type": "core/fd/components/form/container/v2/container"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"id": "numberinput-30f1c1a86c",
"fieldType": "number-input",
"name": "abc",
"type": "number",
"displayValueExpression": "($field.$value & abc)",
"label": {
"value": "def"
},
"events": {
"custom:setProperty": [
"$event.payload"
]
},
"properties": {
"fd:dor": {
"dorExclusion": false
},
"fd:path": "/content/numberinput-displayvalueExpression"
},
":type": "core/fd/components/form/numberinput/v1/numberinput"
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
"jcr:title" : "def",
"fieldType": "number-input"
},
"numberinput-displayvalueExpression" : {
"jcr:primaryType": "nt:unstructured",
"sling:resourceType" : "core/fd/components/form/numberinput/v1/numberinput",
"name" : "abc",
"jcr:title" : "def",
"fieldType": "number-input",
"displayValueExpression": "($field.$value & abc)"
},
"numberinput-customized" : {
"jcr:primaryType": "nt:unstructured",
"sling:resourceType" : "core/fd/components/form/numberinput/v1/numberinput",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"id": "textinput-1247cf0c35",
"fieldType": "text-input",
"name": "abc",
"type": "string",
"displayValueExpression": "($field.$value & abc)",
"label": {
"value": "def"
},
"events": {
"custom:setProperty": [
"$event.payload"
]
},
"properties": {
"fd:dor": {
"dorExclusion": false
},
"fd:path": "/content/textinput-displayValueExpression"
},
":type": "core/fd/components/form/textinput/v1/textinput"
}
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,14 @@
"fieldType": "text-input",
"validationExpression": ""
},
"textinput-displayValueExpression" : {
"jcr:primaryType": "nt:unstructured",
"sling:resourceType" : "core/fd/components/form/textinput/v1/textinput",
"name" : "abc",
"jcr:title" : "def",
"fieldType": "text-input",
"displayValueExpression": "($field.$value & abc)"
},
"textinput-placeholder-autocomplete" : {
"jcr:primaryType": "nt:unstructured",
"sling:resourceType" : "core/fd/components/form/textinput/v1/textinput",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"$id": "classpath:/schema/0.12.5/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"
}
}
}
Loading