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 @@ -87,6 +87,8 @@ private ReservedProperties() {
public static final String PN_MINIMUM = "minimum";
public static final String PN_EXCLUSIVE_MINIMUM = "exclusiveMinimum";
public static final String PN_EXCLUSIVE_MAXIMUM = "exclusiveMaximum";
public static final String PN_EXCLUDE_MINIMUM = "excludeMinimum";
public static final String PN_EXCLUDE_MAXIMUM = "excludeMaximum";
public static final String PN_EXCLUDE_MINIMUM_CHECK = "excludeMinimumCheck";
public static final String PN_EXCLUDE_MAXIMUM_CHECK = "excludeMaximumCheck";
public static final String PN_ENFORCE_ENUM = "enforceEnum";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,18 @@

import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.Default;
import org.apache.sling.models.annotations.Exporter;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.injectorspecific.InjectionStrategy;
import org.apache.sling.models.annotations.injectorspecific.SlingObject;
import org.apache.sling.models.annotations.injectorspecific.ValueMapValue;
import org.jetbrains.annotations.NotNull;

import com.adobe.cq.export.json.ComponentExporter;
import com.adobe.cq.export.json.ExporterConstants;
import com.adobe.cq.forms.core.components.internal.form.FormConstants;
import com.adobe.cq.forms.core.components.internal.form.ReservedProperties;
import com.adobe.cq.forms.core.components.models.form.ConstraintType;
import com.adobe.cq.forms.core.components.models.form.DatePicker;
import com.adobe.cq.forms.core.components.util.AbstractFieldImpl;
Expand All @@ -46,6 +50,16 @@ public class DatePickerImpl extends AbstractFieldImpl implements DatePicker {
@SlingObject
private Resource resource;

/*** Not to be changed, kept for backward compatibility **/
@ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = ReservedProperties.PN_EXCLUDE_MINIMUM)
@Default(booleanValues = false)
protected boolean excludeMinimum;

@ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = ReservedProperties.PN_EXCLUDE_MAXIMUM)
@Default(booleanValues = false)
protected boolean excludeMaximum;
/*** end of Not to be changed **/

private Date exclusiveMinimumVaue;
private Date exclusiveMaximumValue;

Expand Down Expand Up @@ -84,8 +98,8 @@ public Date getExclusiveMinimumDate() {

@PostConstruct
private void initDatePicker() {
exclusiveMaximumValue = ComponentUtils.getExclusiveValue(exclusiveMaximum, maximumDate, null);
exclusiveMinimumVaue = ComponentUtils.getExclusiveValue(exclusiveMinimum, minimumDate, null);
exclusiveMaximumValue = ComponentUtils.getExclusiveValue(exclusiveMaximum, maximumDate, excludeMaximum);
exclusiveMinimumVaue = ComponentUtils.getExclusiveValue(exclusiveMinimum, minimumDate, excludeMinimum);
// in json either, exclusiveMaximum or maximum should be present
if (exclusiveMaximumValue != null) {
maximumDate = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ public static <T> T getExclusiveValue(Object exclusiveValue, T value, Object exc
} else {
return null;
}
} else if (Boolean.TRUE.equals(exclusiveValueCheck) && value != null) { // backward compatibility case // not to be changed
// If so, return the value
return (T) value;
} else {
// Handle other cases or return null if desired
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,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 static final String PATH_DATEPICKER_BACKWARD_COMPATIBLE = CONTENT_ROOT + "/datepicker-backwardcompatible";

private final AemContext context = FormsCoreComponentTestContext.newAemContext();

Expand Down Expand Up @@ -241,6 +242,12 @@ void testJSONExport() throws Exception {
Utils.testJSONExport(datePicker, Utils.getTestExporterJSONPath(BASE, PATH_DATEPICKER));
}

@Test
void testJSONExportBackwardCompatibility() throws Exception {
DatePicker datePicker = Utils.getComponentUnderTest(PATH_DATEPICKER_BACKWARD_COMPATIBLE, DatePicker.class, context);
Utils.testJSONExport(datePicker, Utils.getTestExporterJSONPath(BASE, PATH_DATEPICKER_BACKWARD_COMPATIBLE));
}

@Test
void testJSONExportForCustomized() throws Exception {
DatePicker datePicker = Utils.getComponentUnderTest(PATH_DATEPICKER_CUSTOMIZED, DatePicker.class, context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public class NumberInputImplTest {
private static final String PATH_NUMBER_INPUT_INTEGER_TYPE = CONTENT_ROOT + "/numberinput-integer-type";
private static final String PATH_NUMBER_INPUT_CONSTRAINTS = CONTENT_ROOT + "/numberinput-exclusive";
private static final String PATH_NUMBER_INPUT_BACKWARD_COMPATIBLE = CONTENT_ROOT + "/numberinput-backwardcompatible";
private static final String PATH_NUMBER_INPUT_BACKWARD_COMPATIBLE_2 = CONTENT_ROOT + "/numberinput-backwardcompatible-2";
private static final String PATH_NUMBER_INPUT_BACKWARD_COMPATIBLE_STRING = CONTENT_ROOT + "/numberinput-backwardcompatible-string";
private static final String PATH_NUMBER_INPUT = CONTENT_ROOT + "/numberinput";
private static final String PATH_NUMBER_INPUT_DATALAYER = CONTENT_ROOT + "/numberinput-datalayer";
Expand Down Expand Up @@ -267,6 +268,12 @@ void testJSONExportBackwardCompatible() throws Exception {
Utils.testJSONExport(numberInput, Utils.getTestExporterJSONPath(BASE, PATH_NUMBER_INPUT_BACKWARD_COMPATIBLE));
}

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

@Test
void testGetProperties() throws Exception {
NumberInput numberInput = Utils.getComponentUnderTest(PATH_NUMBER_INPUT_CUSTOMIZED, NumberInput.class, context);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"id": "datepicker-0ac1fed1fe",
"fieldType": "date-input",
"name": "DoB",
"description": "Date of Birth",
"type": "string",
"label": {
"value": "DoB"
},
"events": {
"custom:setProperty": [
"$event.payload"
]
},
"properties": {
"fd:dor": {
"dorExclusion": false
},
"fd:path": "/content/datepicker-backwardcompatible"
},
"format": "date",
"exclusiveMaximum": "2024-07-23",
"exclusiveMinimum": "2024-07-10",
":type": "core/fd/components/form/datepicker/v1/datepicker"
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,33 @@
"fd:path": "/content/forms/af/af2/jcr:content/guideContainer/datepicker"
}
},
"datepicker-backwardcompatible": {
"id": "datepicker-0ac1fed1fe",
"sling:resourceType": "core/fd/components/form/datepicker/v1/datepicker",
"fieldType": "date-input",
"excludeMaximum" : true,
"excludeMinimum" : true,
"minimumDate": "Wed Jul 10 2024 00:00:00 GMT+0000",
"maximumDate": "Tue Jul 23 2024 00:00:00 GMT+0000",
"description": "Date of Birth",
"jcr:title" : "DoB",
"name": "DoB",
"type": "string",
"label": {
"value": "DoB"
},
"events": {
"custom:setProperty": [
"$event.payload"
]
},
"properties": {
"fd:dor": {
"dorExclusion": false
},
"fd:path": "/content/forms/af/af2/jcr:content/guideContainer/datepicker"
}
},
"datepicker-displayValueExpression" : {
"jcr:primaryType": "nt:unstructured",
"sling:resourceType" : "core/fd/components/form/datepicker/v1/datepicker",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
":type": "core/fd/components/form/numberinput/v1/numberinput",
"description": "Enter your phone number.",
"events": {
"custom:setProperty": [
"$event.payload"
]
},
"exclusiveMaximum": 2000002,
"exclusiveMinimum": 10002,
"fieldType": "number-input",
"id": "numberinput-57e5de6073",
"label": {
"value": "Phone Number"
},
"name": "Phone Number",
"properties": {
"fd:dor": {
"dorExclusion": false
},
"fd:path": "/content/numberinput-backwardcompatible-2"
},
"type": "number"
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,33 @@
"fd:path": "/content/forms/af/af2/jcr:content/guideContainer/accordion/item_2/numberinput"
}
},
"numberinput-backwardcompatible-2": {
"id": "numberinput-57e5de6073",
"sling:resourceType": "core/fd/components/form/numberinput/v1/numberinput",
"fieldType": "number-input",
"description": "Enter your phone number.",
"name": "Phone Number",
"jcr:title" : "Phone Number",
"type": "string",
"label": {
"value": "Phone Number"
},
"events": {
"custom:setProperty": [
"$event.payload"
]
},
"excludeMinimumCheck" : true,
"excludeMaximumCheck" : true,
"minimum" : 10002,
"maximum" : 2000002,
"properties": {
"fd:dor": {
"dorExclusion": false
},
"fd:path": "/content/forms/af/af2/jcr:content/guideContainer/accordion/item_2/numberinput"
}
},
"numberinput-backwardcompatible-string": {
"sling:resourceType": "core/fd/components/form/numberinput/v1/numberinput",
"fieldType": "number-input",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
jcr:title="I agree to the terms &amp; conditions"
sling:resourceType="core/fd/components/form/checkbox/v1/checkbox"
enabled="false"
required="true"
checkedValue="true"
fieldType="checkbox">
</approvalcheckbox>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,17 @@ function testRemoveInstance(globals)
{
var repeatablePanel = globals.form.panelcontainer2;
globals.functions.dispatchEvent(repeatablePanel, 'removeInstance');
}
}

/**
* clearValueCustomFunction
* @name clearValueCustomFunction
* @param {object} field field whose value to be cleared
* @param {scope} globals
**/
function clearValueCustomFunction(field, globals) {
// only clear data if change was done by user from the UI.
if (globals.event.payload.eventSource == "ui") {
globals.functions.setProperty(field, {value: null});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@
setModel(model) {
super.setModel(model);
if (this.widget.value !== '') {
this._model.value = this.widget.value;
this.setModelValue(this.widget.value)
}
this.widget.addEventListener('blur', (e) => {
this._model.value = e.target.value;
this.setModelValue(e.target.value);
this.setWidgetValueToDisplayValue();
this.setInactive();
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:xmp="http://ns.adobe.com/xap/1.0/" xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:fd="http://www.adobe.com/aemfd/fd/1.0" xmlns:dam="http://www.day.com/dam/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
jcr:primaryType="dam:Asset">
<jcr:content
cq:conf=""
jcr:lastModified="{Date}2022-11-25T14:51:30.437+05:30"
jcr:primaryType="dam:AssetContent"
sling:resourceType="fd/fm/af/render"
guide="1"
type="guide">
<metadata
fd:version="2.1"
jcr:primaryType="nt:unstructured"
xmp:CreatorTool="AEM Forms"
allowedRenderFormat="HTML"
author="admin"
formmodel="none"
themeRef="/libs/fd/af/themes/canvas"
title="Email"/>
</jcr:content>
</jcr:root>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:dam="http://www.day.com/dam/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" xmlns:xmp="http://ns.adobe.com/xap/1.0/" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:fd="http://www.adobe.com/aemfd/fd/1.0"
jcr:primaryType="dam:Asset">
<jcr:content
cq:conf="\0"
jcr:lastModified="{Date}2024-03-01T10:40:51.331Z"
jcr:primaryType="dam:AssetContent"
sling:resourceType="fd/fm/af/render"
guide="1"
type="guide">
<metadata
fd:version="2.1"
jcr:language="en"
jcr:primaryType="nt:unstructured"
xmp:CreatorTool="AEM Forms AF Wizard"
allowedRenderFormat="HTML"
author="admin"
dorType="none"
formmodel="none"
themeRef="/libs/fd/af/themes/canvas"
title="uichange"/>
</jcr:content>
</jcr:root>
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:fd="http://www.adobe.com/aemfd/fd/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
jcr:primaryType="cq:Page">
<jcr:content
cq:deviceGroups="[/etc/mobile/groups/responsive]"
cq:lastModified="{Date}2022-11-25T14:51:30.442+05:30"
cq:lastModifiedBy="admin"
cq:template="/conf/core-components-examples/settings/wcm/templates/af-blank-v2"
jcr:language="en"
jcr:primaryType="cq:PageContent"
jcr:title="Email"
sling:configRef="/conf/forms/core-components-it/samples/actions/submit/basic/"
sling:resourceType="forms-components-examples/components/page">
<guideContainer
fd:version="2.1"
jcr:lastModified="{Date}2022-11-25T14:51:30.433+05:30"
jcr:lastModifiedBy="admin"
jcr:primaryType="nt:unstructured"
sling:resourceType="forms-components-examples/components/form/container"
actionType="fd/af/components/guidesubmittype/email"
fieldType="form"
textIsRich="true"
useExternalEmailTemplate="false"
template="Thanks you ${firstName}"
from="abc@def.com"
mailto="[abc@abc.om]"
thankYouMessage="Thank you for submitting the form."
thankYouOption="message"
themeRef="/libs/fd/af/themes/canvas">
<textinput
jcr:lastModified="{Date}2023-01-18T17:47:33.769+05:30"
jcr:lastModifiedBy="admin"
jcr:primaryType="nt:unstructured"
jcr:title="Text Input"
sling:resourceType="forms-components-examples/components/form/textinput"
autocomplete="off"
enabled="{Boolean}true"
fieldType="text-input"
name="firstName"
visible="{Boolean}true"/>
<submit
jcr:created="{Date}2022-11-23T12:16:03.945+05:30"
jcr:createdBy="admin"
jcr:lastModified="{Date}2022-11-23T12:16:03.945+05:30"
jcr:lastModifiedBy="admin"
jcr:primaryType="nt:unstructured"
jcr:title="Submit"
sling:resourceType="forms-components-examples/components/form/actions/submit"
buttonType="submit"
dorExclusion="true"
fieldType="button"
name="submit1669185963968">
<fd:rules
fd:click="[{&quot;nodeName&quot;:&quot;ROOT&quot;\,&quot;items&quot;:[{&quot;nodeName&quot;:&quot;STATEMENT&quot;\,&quot;choice&quot;:{&quot;nodeName&quot;:&quot;EVENT_SCRIPTS&quot;\,&quot;items&quot;:[{&quot;nodeName&quot;:&quot;EVENT_CONDITION&quot;\,&quot;choice&quot;:{&quot;nodeName&quot;:&quot;EVENT_AND_COMPARISON&quot;\,&quot;items&quot;:[{&quot;nodeName&quot;:&quot;COMPONENT&quot;\,&quot;value&quot;:{&quot;id&quot;:&quot;$form.button1667450213112&quot;\,&quot;type&quot;:&quot;BUTTON&quot;\,&quot;name&quot;:&quot;button1667450213112&quot;}}\,{&quot;nodeName&quot;:&quot;EVENT_AND_COMPARISON_OPERATOR&quot;\,&quot;choice&quot;:{&quot;nodeName&quot;:&quot;is clicked&quot;\,&quot;value&quot;:null}}\,{&quot;nodeName&quot;:&quot;PRIMITIVE_EXPRESSION&quot;\,&quot;choice&quot;:null}]}\,&quot;nested&quot;:false}\,{&quot;nodeName&quot;:&quot;Then&quot;\,&quot;value&quot;:null}\,{&quot;nodeName&quot;:&quot;BLOCK_STATEMENTS&quot;\,&quot;items&quot;:[{&quot;nodeName&quot;:&quot;BLOCK_STATEMENT&quot;\,&quot;choice&quot;:{&quot;nodeName&quot;:&quot;SUBMIT_FORM&quot;\,&quot;items&quot;:[]}}]}]}}]\,&quot;isValid&quot;:true\,&quot;enabled&quot;:true\,&quot;version&quot;:1\,&quot;script&quot;:[&quot;submitForm()&quot;]\,&quot;eventName&quot;:&quot;Click&quot;\,&quot;ruleType&quot;:&quot;&quot;\,&quot;description&quot;:&quot;&quot;}]"
jcr:primaryType="nt:unstructured"/>
<fd:events
jcr:primaryType="nt:unstructured"
click="[submitForm()]"/>
</submit>
</guideContainer>
</jcr:content>
</jcr:root>
Loading