Skip to content

Commit e6fa8bb

Browse files
Hamburger menu core component (#1331)
* initial commit * hamburger menu enhanced * code enhancement * test case fixed * sorting issue fixed * hamburger menu enhancements * test cases added * nesting support till level 3 * breadcrumbs and two way sync added * test cases fixes * nesting level changed and commented code removed * text changed * test case added * code refactored * test cases fixed * accessibility improvements * custom nesting level support added * nesting n level addded * nesting support removed along with css cleanup * test cases fixed * cases fixed * SOC implemented * hamburger menu code restructured * BEM fixed * review comments incorporated * java doc version update * review comments incorporated II * review comments incorporated II * review comments incorporated II * code refactoring * code refactoring * test cases fixes after bem change * test cases fixes after bem change --------- Co-authored-by: Rajat Khurana <rajatkhurana@adobe.com>
1 parent 207226c commit e6fa8bb

File tree

17 files changed

+1718
-6
lines changed

17 files changed

+1718
-6
lines changed

bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v2/form/FormContainerImpl.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ public class FormContainerImpl extends AbstractContainerImpl implements FormCont
7676
private static final String DOR_TEMPLATE_TYPE = "dorTemplateType";
7777
private static final String FD_SCHEMA_TYPE = "fd:schemaType";
7878
private static final String FD_SCHEMA_REF = "fd:schemaRef";
79+
private static final String FD_IS_HAMBURGER_MENU_ENABLED = "fd:isHamburgerMenuEnabled";
7980
public static final String FD_FORM_DATA_ENABLED = "fd:formDataEnabled";
8081
public static final String FD_ROLE_ATTRIBUTE = "fd:roleAttribute";
8182

@@ -95,6 +96,9 @@ public class FormContainerImpl extends AbstractContainerImpl implements FormCont
9596
@Nullable
9697
private String clientLibRef;
9798

99+
@ValueMapValue(name = FD_IS_HAMBURGER_MENU_ENABLED, injectionStrategy = InjectionStrategy.OPTIONAL)
100+
private Boolean isHamburgerMenuEnabled = false;
101+
98102
protected String contextPath = StringUtils.EMPTY;
99103
private boolean formDataEnabled = false;
100104

@@ -257,6 +261,10 @@ public String getPrefillService() {
257261
return prefillService;
258262
}
259263

264+
public Boolean getIsHamburgerMenuEnabled() {
265+
return isHamburgerMenuEnabled;
266+
}
267+
260268
@Override
261269
public String getRoleAttribute() {
262270
return roleAttribute;
@@ -317,6 +325,7 @@ public String getLanguageDirection() {
317325
if (StringUtils.isNotBlank(getSchemaRef())) {
318326
properties.put(FD_SCHEMA_REF, getSchemaRef());
319327
}
328+
properties.put(FD_IS_HAMBURGER_MENU_ENABLED, getIsHamburgerMenuEnabled());
320329
// adding a custom property to know if form data is enabled
321330
// this is done so that an extra API call from the client can be avoided
322331
if (StringUtils.isNotBlank(getPrefillService()) ||

bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/FormContainer.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,17 @@ default Boolean isEnabled() {
145145
return true;
146146
}
147147

148+
/**
149+
* Returns the hamburger menu support
150+
*
151+
* @return the hamburger menu support of the form
152+
* @since com.adobe.cq.forms.core.components.models.form 5.7.5
153+
*/
154+
@JsonIgnore
155+
default Boolean getIsHamburgerMenuEnabled() {
156+
return false;
157+
}
158+
148159
@Override
149160
@JsonIgnore
150161
default Label getLabel() {

bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/package-info.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
* </p>
3636
*/
3737

38-
@Version("5.7.4")
38+
@Version("5.7.5")
3939
package com.adobe.cq.forms.core.components.models.form;
4040

4141
import org.osgi.annotation.versioning.Version;

bundles/af-core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/FormContainerTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,11 @@ void testGetLanguageDirection() {
9898
assertEquals("ltr", formContainerMock.getLanguageDirection());
9999
}
100100

101+
@Test
102+
void testIsHamburgerMenuEnabled() {
103+
FormContainer formContainerMock = Mockito.mock(FormContainer.class);
104+
Mockito.when(formContainerMock.getIsHamburgerMenuEnabled()).thenCallRealMethod();
105+
assertEquals(false, formContainerMock.getIsHamburgerMenuEnabled());
106+
}
107+
101108
}

bundles/af-core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v2/form/FormContainerImplTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,4 +484,10 @@ void testNoFieldType() {
484484
FormContainer formContainer = Utils.getComponentUnderTest(PATH_FORM_WITHOUT_FIELDTYPE, FormContainer.class, context);
485485
assertEquals(FieldType.FORM.getValue(), formContainer.getFieldType());
486486
}
487+
488+
@Test
489+
public void testGetIsHamburgerMenuEnabled() {
490+
FormContainer formContainer = Utils.getComponentUnderTest(PATH_FORM_1, FormContainer.class, context);
491+
assertFalse(Boolean.valueOf(formContainer.getIsHamburgerMenuEnabled().toString()));
492+
}
487493
}

bundles/af-core/src/test/resources/form/formcontainer/exporter-formcontainerv2.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"fd:enableAutoSave":false
1313
},
1414
"fd:path": "/content/forms/af/demo/jcr:content/formcontainerv2",
15+
"fd:isHamburgerMenuEnabled": false,
1516
"fd:schemaType": "BASIC",
1617
"fd:formDataEnabled": true,
1718
"customProp": "customPropValue",
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:rep="internal"
3+
jcr:mixinTypes="[rep:AccessControllable]"
4+
jcr:primaryType="sling:Folder"
5+
hidden="true"/>

it/content/src/main/content/jcr_root/content/forms/af/core-components-it/samples/formcontainer/basic/.content.xml

Lines changed: 947 additions & 0 deletions
Large diffs are not rendered by default.

ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/container/v2/container/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,15 @@ This approach is implemented to optimize performance by avoiding additional netw
6161
```
6262
BLOCK cmp-adaptiveform-container
6363
ELEMENT cmp-adaptiveform-container__wrapper
64+
ELEMENT cmp-adaptiveform-container__hamburger-menu
65+
ELEMENT cmp-adaptiveform-container__hamburger-menu-top
66+
ELEMENT cmp-adaptiveform-container__hamburger-menu-icon-container
67+
ELEMENT cmp-adaptiveform-container__hamburger-menu-icon
68+
ELEMENT cmp-adaptiveform-container__hamburger-menu-middle
69+
ELEMENT cmp-adaptiveform-container__hamburger-menu-bottom
70+
ELEMENT cmp-adaptiveform-container__hamburger-menu-active-item-title
71+
MODIFIER cmp-adaptiveform-container__hamburger-menu-button--prev
72+
MODIFIER cmp-adaptiveform-container__hamburger-menu-button--next
6473
```
6574

6675
In edit mode, the BEM structure includes a modifier for the cmp-adaptiveform-container block,

ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/container/v2/container/_cq_dialog/.content.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,14 @@
8484
ignoreData="{Boolean}true"
8585
name="./specVersion"
8686
value="0.14.2"/>
87+
<hamburgerMenu
88+
jcr:primaryType="nt:unstructured"
89+
granite:class="cmp-adaptiveform-container__hamburger-toggle"
90+
sling:resourceType="granite/ui/components/coral/foundation/form/checkbox"
91+
name="./fd:isHamburgerMenuEnabled"
92+
text="Enable the hamburger menu for mobile view"
93+
fieldDescription="Select the option to display the hamburger menu for efficient navigation on mobile devices."
94+
value="{Boolean}true"/>
8795
</items>
8896
</container>
8997
</items>

0 commit comments

Comments
 (0)