Skip to content

UE: Support for fd:customDisplayFormat #1619

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

Merged
merged 1 commit into from
Jul 15, 2025
Merged
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
@@ -77,6 +77,7 @@ private ReservedProperties() {
public static final String PN_MULTI_DEFAULT_VALUES = "fd:multiDefaultValues";
public static final String PN_FORMAT = "format";
public static final String PN_DISPLAY_FORMAT = "displayFormat";
public static final String PN_CUSTOM_DISPLAY_FORMAT = "fd:customDisplayFormat";
public static final String PN_EDIT_FORMAT = "editFormat";
public static final String PN_DISPLAY_VALUE_EXPRESSION = "displayValueExpression";
public static final String PN_DATA_FORMAT = "dataFormat";
Original file line number Diff line number Diff line change
@@ -57,6 +57,10 @@ public abstract class AbstractFieldImpl extends AbstractBaseImpl implements Fiel
@Nullable
protected String displayFormat;

@ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = ReservedProperties.PN_CUSTOM_DISPLAY_FORMAT)
@Nullable
protected String customDisplayFormat;

@ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = ReservedProperties.PN_EDIT_FORMAT)
@Nullable
protected String editFormat;
@@ -165,6 +169,9 @@ public String getPlaceHolder() {
@Override
@Nullable
public String getDisplayFormat() {
if (customDisplayFormat != null) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is confusing, we already have displayFormat property for this, why do you need fd:customDisplayFormat ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rismehta The property displayFormat is used for OOTB display formats and custom display formats, which does not allow us to support custom formats in UE. Therefore I have created a separate property just like for the Multiselect in dropdown PR
cc: @jalagari @ravise5

Copy link
Collaborator

@rismehta rismehta Jul 15, 2025

Choose a reason for hiding this comment

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

This property will only be present for EDS use-case, hence merging this. I don't think this would impact existing core component based form.

It might impact use-cases where EDS form is created using crispr json, which @TalmizAhmed can fix separately

return customDisplayFormat;
}
return displayFormat;
}

Original file line number Diff line number Diff line change
@@ -49,6 +49,9 @@ public class DatePickerImplTest {
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 static final String PATH_DATEPICKER_WITHOUT_FIELDTYPE = CONTENT_ROOT + "/datepicker-without-fieldtype";
private static final String PATH_DATEPICKER_WITH_DISPLAY_FORMAT = CONTENT_ROOT + "/datepicker-with-display-format";
private static final String PATH_DATEPICKER_WITH_CUSTOM_DISPLAY_FORMAT = CONTENT_ROOT + "/datepicker-with-custom-display-format";
private static final String PATH_DATEPICKER_WITH_BOTH_DISPLAY_FORMATS = CONTENT_ROOT + "/datepicker-with-both-display-formats";

private final AemContext context = FormsCoreComponentTestContext.newAemContext();

@@ -209,6 +212,19 @@ void testGetDisplayFormat() {
assertEquals(null, datePickerMock.getDisplayFormat());
}

@Test
void testGetDisplayFormatWithCustomDisplayFormat() {
DatePicker datePicker = Utils.getComponentUnderTest(PATH_DATEPICKER_WITH_CUSTOM_DISPLAY_FORMAT, DatePicker.class, context);
assertEquals("DD/MM/YYYY", datePicker.getDisplayFormat());
}

@Test
void testGetDisplayFormatWithBothFormats() {
DatePicker datePicker = Utils.getComponentUnderTest(PATH_DATEPICKER_WITH_BOTH_DISPLAY_FORMATS, DatePicker.class, context);
// customDisplayFormat should take priority over displayFormat
assertEquals("DD/MM/YYYY", datePicker.getDisplayFormat());
}

@Test
void testGetEditFormat() {
DatePicker datePicker = Utils.getComponentUnderTest(PATH_DATEPICKER_CUSTOMIZED, DatePicker.class, context);
@@ -313,4 +329,17 @@ void testNoFieldType() throws Exception {
DatePicker datePicker = Utils.getComponentUnderTest(PATH_DATEPICKER_WITHOUT_FIELDTYPE, DatePicker.class, context);
Utils.testJSONExport(datePicker, Utils.getTestExporterJSONPath(BASE, PATH_DATEPICKER_WITHOUT_FIELDTYPE));
}

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

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

}
Original file line number Diff line number Diff line change
@@ -59,6 +59,9 @@ public class NumberInputImplTest {
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 static final String PATH_NUMBER_INPUT_WITHOUT_FIELDTYPE = CONTENT_ROOT + "/numberinput-without-fieldtype";
private static final String PATH_NUMBER_INPUT_WITH_DISPLAY_FORMAT = CONTENT_ROOT + "/numberinput-with-display-format";
private static final String PATH_NUMBER_INPUT_WITH_CUSTOM_DISPLAY_FORMAT = CONTENT_ROOT + "/numberinput-with-custom-display-format";
private static final String PATH_NUMBER_INPUT_WITH_BOTH_DISPLAY_FORMATS = CONTENT_ROOT + "/numberinput-with-both-display-formats";

private final AemContext context = FormsCoreComponentTestContext.newAemContext();

@@ -207,6 +210,19 @@ void testGetDisplayFormat() {
assertEquals(null, numberInputMock.getDisplayFormat());
}

@Test
void testGetDisplayFormatWithCustomDisplayFormat() {
NumberInput numberInput = Utils.getComponentUnderTest(PATH_NUMBER_INPUT_WITH_CUSTOM_DISPLAY_FORMAT, NumberInput.class, context);
assertEquals("customCurrency", numberInput.getDisplayFormat());
}

@Test
void testGetDisplayFormatWithBothFormats() {
NumberInput numberInput = Utils.getComponentUnderTest(PATH_NUMBER_INPUT_WITH_BOTH_DISPLAY_FORMATS, NumberInput.class, context);
// customDisplayFormat should take priority over displayFormat
assertEquals("customCurrency", numberInput.getDisplayFormat());
}

@Test
void testGetEditFormat() {
NumberInput numberInput = Utils.getComponentUnderTest(PATH_NUMBER_INPUT_CUSTOMIZED, NumberInput.class, context);
@@ -428,4 +444,17 @@ void testNoFieldType() {
NumberInput numberInput = Utils.getComponentUnderTest(PATH_NUMBER_INPUT_WITHOUT_FIELDTYPE, NumberInput.class, context);
assertEquals(FieldType.NUMBER_INPUT.getValue(), numberInput.getFieldType());
}

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

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

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"id": "datepicker-bbbb612dba",
"fieldType": "date-input",
"name": "abc",
"type": "string",
"displayFormat": "DD/MM/YYYY",
"label": {
"value": "def"
},
"events": {
"custom:setProperty": [
"$event.payload"
]
},
"properties": {
"fd:dor": {
"dorExclusion": false
},
"fd:path": "/content/datepicker-with-both-display-formats"
},
"format": "date",
":type": "core/fd/components/form/datepicker/v1/datepicker"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"id": "datepicker-b80fc90202",
"fieldType": "date-input",
"name": "abc",
"type": "string",
"displayFormat": "DD/MM/YYYY",
"label": {
"value": "def"
},
"events": {
"custom:setProperty": [
"$event.payload"
]
},
"properties": {
"fd:dor": {
"dorExclusion": false
},
"fd:path": "/content/datepicker-with-custom-display-format"
},
"format": "date",
":type": "core/fd/components/form/datepicker/v1/datepicker"
}
Original file line number Diff line number Diff line change
@@ -130,5 +130,22 @@
"sling:resourceType" : "core/fd/components/form/datepicker/v1/datepicker",
"name" : "abc",
"jcr:title" : "def"
},
"datepicker-with-custom-display-format" : {
"jcr:primaryType": "nt:unstructured",
"sling:resourceType" : "core/fd/components/form/datepicker/v1/datepicker",
"name" : "abc",
"jcr:title" : "def",
"fieldType": "date-input",
"fd:customDisplayFormat": "DD/MM/YYYY"
},
"datepicker-with-both-display-formats" : {
"jcr:primaryType": "nt:unstructured",
"sling:resourceType" : "core/fd/components/form/datepicker/v1/datepicker",
"name" : "abc",
"jcr:title" : "def",
"fieldType": "date-input",
"displayFormat": "YYYY-MM-DD",
"fd:customDisplayFormat": "DD/MM/YYYY"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"id": "numberinput-54ced6bd67",
"fieldType": "number-input",
"name": "abc",
"type": "number",
"displayFormat": "customCurrency",
"label": {
"value": "def"
},
"events": {
"custom:setProperty": [
"$event.payload"
]
},
"properties": {
"fd:dor": {
"dorExclusion": false
},
"fd:path": "/content/numberinput-with-both-display-formats"
},
":type": "core/fd/components/form/numberinput/v1/numberinput"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"id": "numberinput-7e9f700655",
"fieldType": "number-input",
"name": "abc",
"type": "number",
"displayFormat": "customCurrency",
"label": {
"value": "def"
},
"events": {
"custom:setProperty": [
"$event.payload"
]
},
"properties": {
"fd:dor": {
"dorExclusion": false
},
"fd:path": "/content/numberinput-with-custom-display-format"
},
":type": "core/fd/components/form/numberinput/v1/numberinput"
}
Original file line number Diff line number Diff line change
@@ -193,5 +193,22 @@
"sling:resourceType" : "core/fd/components/form/numberinput/v1/numberinput",
"name" : "abc",
"jcr:title" : "def"
},
"numberinput-with-custom-display-format" : {
"jcr:primaryType": "nt:unstructured",
"sling:resourceType" : "core/fd/components/form/numberinput/v1/numberinput",
"name" : "abc",
"jcr:title" : "def",
"fieldType": "number-input",
"fd:customDisplayFormat": "customCurrency"
},
"numberinput-with-both-display-formats" : {
"jcr:primaryType": "nt:unstructured",
"sling:resourceType" : "core/fd/components/form/numberinput/v1/numberinput",
"name" : "abc",
"jcr:title" : "def",
"fieldType": "number-input",
"displayFormat": "currency",
"fd:customDisplayFormat": "customCurrency"
}
}