Skip to content

Commit

Permalink
SITES-13771 Content Fragment List component : Property Name is gettin…
Browse files Browse the repository at this point in the history
…g displayed to users rather than Field Label (#2546)

* Content Fragment List component : Property Name is getting displayed to users rather than Field Label

For multi text field look for cfm-element key or fallback on the default value.

* fix tests
  • Loading branch information
HollywoodTonight authored Jul 14, 2023
1 parent 312e3d6 commit 530f26c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ protected void doGet(@NotNull SlingHttpServletRequest request, @NotNull SlingHtt
ValueMap valueMap = elementResource.getValueMap();
String valueValue = valueMap.get("name", "");
String textValue = valueMap.get("fieldLabel", valueValue);
if (textValue.equals(valueValue)) {
textValue = valueMap.get("cfm-element", valueValue);
}
if (isOrderBy && StringUtils.isNotEmpty(valueValue)) {
valueValue = "jcr:content/data/master/" + valueValue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public void verifyDataSourceWhenOrderByIsGivenV1() {
hasItem(resourceWithPropertiesTextAndValue("Created", "jcr:created")),
hasItem(resourceWithPropertiesTextAndValue("Last Modified", "jcr:content/jcr:lastModified")),
hasItem(resourceWithPropertiesTextAndValue("textFieldLabel", "jcr:content/data/master/textField")),
hasItem(resourceWithPropertiesTextAndValue("multiTextField", "jcr:content/data/master/multiTextField"))));
hasItem(resourceWithPropertiesTextAndValue("Multi Text Field", "jcr:content/data/master/multiTextField"))));
}

@Test
Expand All @@ -111,7 +111,7 @@ public void verifyDataSourceWhenOrderByIsGivenV2() {
hasItem(resourceWithPropertiesTextAndValue("Created", "jcr:created")),
hasItem(resourceWithPropertiesTextAndValue("Last Modified", "jcr:content/jcr:lastModified")),
hasItem(resourceWithPropertiesTextAndValue("textFieldLabel", "jcr:content/data/master/textField")),
hasItem(resourceWithPropertiesTextAndValue("multiTextField", "jcr:content/data/master/multiTextField")),
hasItem(resourceWithPropertiesTextAndValue("Multi Text Field", "jcr:content/data/master/multiTextField")),
hasItem(resourceWithPropertiesTextAndValue("dateAndTimeFieldLabel", "jcr:content/data/master/dateAndTimeField")),
hasItem(resourceWithPropertiesTextAndValue("numberFieldLabel", "jcr:content/data/master/numberField"))));
}
Expand All @@ -135,7 +135,7 @@ public void verifyDataSourceWhenModelParameterIsGiven() {
assertThat(resourceList, allOf(
hasItem(resourceWithPropertiesTextAndValue("textFieldLabel", "textField")),
// Multi text field doesn't have the 'fieldLabel' property, instead label is stored as 'cfm-element':
hasItem(resourceWithPropertiesTextAndValue("multiTextField", "multiTextField")),
hasItem(resourceWithPropertiesTextAndValue("Multi Text Field", "multiTextField")),
hasItem(resourceWithPropertiesTextAndValue("numberFieldLabel", "numberField")),
// Boolean field is a checkbox and therefore doesn't have a 'fieldLabel', instead there is a 'text' property
hasItem(resourceWithPropertiesTextAndValue("booleanField", "booleanField")),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"valueType": "string",
"showEmptyInReadOnly": "true",
"metaType": "text-multi",
"cfm-element": "multiTextFieldLabel",
"cfm-element": "Multi Text Field",
"name": "multiTextField",
"sling:resourceType": "dam/cfm/admin/components/authoring/contenteditor/multieditor",
"renderReadOnly": "false"
Expand Down

0 comments on commit 530f26c

Please sign in to comment.