Skip to content
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

Hamburger menu core component #1331

Merged
merged 33 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
0f89f75
initial commit
rajatkhurana-adobe Jul 16, 2024
2e0e805
hamburger menu enhanced
rajatkhurana-adobe Jul 23, 2024
9a5dfb0
code enhancement
rajatkhurana-adobe Jul 24, 2024
6ba6e0f
test case fixed
rajatkhurana-adobe Jul 24, 2024
c198674
sorting issue fixed
rajatkhurana-adobe Jul 24, 2024
34bdcf8
hamburger menu enhancements
rajatkhurana-adobe Aug 24, 2024
1f1e282
test cases added
rajatkhurana-adobe Aug 28, 2024
fa5766d
nesting support till level 3
rajatkhurana-adobe Aug 28, 2024
c34b1be
breadcrumbs and two way sync added
rajatkhurana-adobe Sep 6, 2024
27308bb
test cases fixes
rajatkhurana-adobe Sep 11, 2024
f46e3e3
nesting level changed and commented code removed
rajatkhurana-adobe Sep 12, 2024
aaea659
text changed
rajatkhurana-adobe Sep 12, 2024
73a28a1
test case added
rajatkhurana-adobe Sep 12, 2024
61450be
code refactored
rajatkhurana-adobe Sep 16, 2024
d8d7245
test cases fixed
rajatkhurana-adobe Sep 16, 2024
5297fe2
accessibility improvements
rajatkhurana-adobe Sep 18, 2024
9726220
custom nesting level support added
rajatkhurana-adobe Sep 24, 2024
a7d5673
nesting n level addded
rajatkhurana-adobe Sep 24, 2024
2f04e02
nesting support removed along with css cleanup
rajatkhurana-adobe Sep 24, 2024
318d3c7
test cases fixed
rajatkhurana-adobe Sep 24, 2024
6064805
cases fixed
rajatkhurana-adobe Sep 25, 2024
c37b0f5
SOC implemented
rajatkhurana-adobe Oct 9, 2024
034f252
hamburger menu code restructured
rajatkhurana-adobe Oct 9, 2024
7e86b94
BEM fixed
rajatkhurana-adobe Oct 10, 2024
ec0d64d
review comments incorporated
rajatkhurana-adobe Oct 10, 2024
4d8aca8
java doc version update
rajatkhurana-adobe Oct 10, 2024
f4d5c6a
review comments incorporated II
rajatkhurana-adobe Oct 14, 2024
4c3ab7a
review comments incorporated II
rajatkhurana-adobe Oct 14, 2024
9f052be
review comments incorporated II
rajatkhurana-adobe Oct 14, 2024
ecc41c3
code refactoring
rajatkhurana-adobe Oct 16, 2024
8e464e2
code refactoring
rajatkhurana-adobe Oct 16, 2024
7f16a08
test cases fixes after bem change
rajatkhurana-adobe Oct 17, 2024
381d55b
test cases fixes after bem change
rajatkhurana-adobe Oct 17, 2024
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 @@ -76,6 +76,7 @@ public class FormContainerImpl extends AbstractContainerImpl implements FormCont
private static final String DOR_TEMPLATE_TYPE = "dorTemplateType";
private static final String FD_SCHEMA_TYPE = "fd:schemaType";
private static final String FD_SCHEMA_REF = "fd:schemaRef";
private static final String FD_IS_HAMBURGER_MENU_ENABLED = "fd:isHamburgerMenuEnabled";
public static final String FD_FORM_DATA_ENABLED = "fd:formDataEnabled";
public static final String FD_ROLE_ATTRIBUTE = "fd:roleAttribute";

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

@ValueMapValue(name = FD_IS_HAMBURGER_MENU_ENABLED, injectionStrategy = InjectionStrategy.OPTIONAL)
private Boolean isHamburgerMenuEnabled = false;

protected String contextPath = StringUtils.EMPTY;
private boolean formDataEnabled = false;

Expand Down Expand Up @@ -257,6 +261,10 @@ public String getPrefillService() {
return prefillService;
}

public Boolean getIsHamburgerMenuEnabled() {
return isHamburgerMenuEnabled;
}

@Override
public String getRoleAttribute() {
return roleAttribute;
Expand Down Expand Up @@ -317,6 +325,7 @@ public String getLanguageDirection() {
if (StringUtils.isNotBlank(getSchemaRef())) {
properties.put(FD_SCHEMA_REF, getSchemaRef());
}
properties.put(FD_IS_HAMBURGER_MENU_ENABLED, getIsHamburgerMenuEnabled());
// adding a custom property to know if form data is enabled
// this is done so that an extra API call from the client can be avoided
if (StringUtils.isNotBlank(getPrefillService()) ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,17 @@ default Boolean isEnabled() {
return true;
}

/**
* Returns the hamburger menu support
*
* @return the hamburger menu support of the form
* @since com.adobe.cq.forms.core.components.models.form 5.7.5
*/
@JsonIgnore
default Boolean getIsHamburgerMenuEnabled() {
return false;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add test cases for all files reported by codecov

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added all.

}

@Override
@JsonIgnore
default Label getLabel() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* </p>
*/

@Version("5.7.4")
@Version("5.7.5")
package com.adobe.cq.forms.core.components.models.form;

import org.osgi.annotation.versioning.Version;
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,11 @@ void testGetLanguageDirection() {
assertEquals("ltr", formContainerMock.getLanguageDirection());
}

@Test
void testIsHamburgerMenuEnabled() {
FormContainer formContainerMock = Mockito.mock(FormContainer.class);
Mockito.when(formContainerMock.getIsHamburgerMenuEnabled()).thenCallRealMethod();
assertEquals(false, formContainerMock.getIsHamburgerMenuEnabled());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -484,4 +484,10 @@ void testNoFieldType() {
FormContainer formContainer = Utils.getComponentUnderTest(PATH_FORM_WITHOUT_FIELDTYPE, FormContainer.class, context);
assertEquals(FieldType.FORM.getValue(), formContainer.getFieldType());
}

@Test
public void testGetIsHamburgerMenuEnabled() {
FormContainer formContainer = Utils.getComponentUnderTest(PATH_FORM_1, FormContainer.class, context);
assertFalse(Boolean.valueOf(formContainer.getIsHamburgerMenuEnabled().toString()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"fd:enableAutoSave":false
},
"fd:path": "/content/forms/af/demo/jcr:content/formcontainerv2",
"fd:isHamburgerMenuEnabled": false,
"fd:schemaType": "BASIC",
"fd:formDataEnabled": true,
"customProp": "customPropValue",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:rep="internal"
jcr:mixinTypes="[rep:AccessControllable]"
jcr:primaryType="sling:Folder"
hidden="true"/>

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@ This approach is implemented to optimize performance by avoiding additional netw
```
BLOCK cmp-adaptiveform-container
ELEMENT cmp-adaptiveform-container__wrapper
ELEMENT cmp-adaptiveform-container__hamburger-menu
ELEMENT cmp-adaptiveform-container__hamburger-menu-top
ELEMENT cmp-adaptiveform-container__hamburger-menu-icon-container
ELEMENT cmp-adaptiveform-container__hamburger-menu-icon
ELEMENT cmp-adaptiveform-container__hamburger-menu-middle
ELEMENT cmp-adaptiveform-container__hamburger-menu-bottom
ELEMENT cmp-adaptiveform-container__hamburger-menu-active-item-title
MODIFIER cmp-adaptiveform-container__hamburger-menu-button--prev
MODIFIER cmp-adaptiveform-container__hamburger-menu-button--next
```

In edit mode, the BEM structure includes a modifier for the cmp-adaptiveform-container block,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@
ignoreData="{Boolean}true"
name="./specVersion"
value="0.14.2"/>
<hamburgerMenu
jcr:primaryType="nt:unstructured"
granite:class="cmp-adaptiveform-container__hamburger-toggle"
sling:resourceType="granite/ui/components/coral/foundation/form/checkbox"
name="./fd:isHamburgerMenuEnabled"
text="Enable the hamburger menu for mobile view"
fieldDescription="Select the option to display the hamburger menu for efficient navigation on mobile devices."
value="{Boolean}true"/>
</items>
</container>
</items>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
(function($, channel, Coral) {
"use strict";

})(jQuery, jQuery(document), Coral);
})(jQuery, jQuery(document), Coral);
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/

form:not(.cmp-adaptiveform-container--edit) [data-cmp-visible="false"] {
display: none !important;
}
.cmp-adaptiveform-container--loading{

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@
###############################################################################

#base=js
hamburgerMenu.js
formcontainerview.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright 2022 Adobe
* Copyright 2024 Adobe
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -25,9 +25,12 @@
self: "[data-" + this.NS + '-is="' + this.IS + '"]',
};
static loadingClass = `${FormContainerV2.bemBlock}--loading`;
#hamburgerMenuInstance = '';

constructor(params) {
super(params);
let self = this;
this.#hamburgerMenuInstance = new HamburgerMenu(this);
this._model.subscribe((action) => {
let state = action.target.getState();
// execute the handler only if there are no rules configured on submitSuccess event.
Expand Down Expand Up @@ -75,6 +78,10 @@
this.#setupAutoSave(self.getModel());
}

initialiseHamburgerMenu() {
this.#hamburgerMenuInstance.init();
}

/**
* Register time based auto save
* @param formModel.
Expand All @@ -101,6 +108,7 @@
async function onDocumentReady() {
const startTime = new Date().getTime();
let elements = document.querySelectorAll(FormContainerV2.selectors.self);

for (let i = 0; i < elements.length; i++) {
let loaderToAdd = document.querySelector("[data-cmp-adaptiveform-container-loader='"+ elements[i].id + "']");
if(loaderToAdd){
Expand All @@ -111,6 +119,7 @@
function onInit(e) {
let formContainer = e.detail;
let formEl = formContainer.getFormElement();
formContainer.initialiseHamburgerMenu();
setTimeout(() => {
let loaderToRemove = document.querySelector("[data-cmp-adaptiveform-container-loader='"+ formEl.id + "']");
if(loaderToRemove){
Expand Down Expand Up @@ -144,5 +153,4 @@
} else {
document.addEventListener("DOMContentLoaded", onDocumentReady);
}

})();
Loading