Merge branch 'refactor-menu-resolvers-7.6' into refactor-menu-resolvers-9.0

This commit is contained in:
Yana De Pauw
2025-02-21 13:36:23 +01:00
6 changed files with 22 additions and 11 deletions

View File

@@ -23,6 +23,7 @@ import { MenuItemModels } from './menu-section.model';
*/
export interface PartialMenuSection {
id?: string;
accessibilityHandle?: string;
visible: boolean;
model: MenuItemModels;
parentID?: string;

View File

@@ -19,6 +19,11 @@ export interface MenuSection {
*/
id: string;
/**
* Accessibility handle that can be used to find a specific menu in the html
*/
accessibilityHandle?: string;
/**
* Whether this section should be visible.
*/

View File

@@ -94,7 +94,11 @@ function addProviderToList(providers: Provider[], providerType: Type<AbstractMen
provider.index = provider.index ?? index;
if (hasValue(parentID)) {
provider.menuProviderId = provider.menuProviderId ?? `${parentID}_${index}`;
provider.parentID = provider.parentID ?? parentID;
let providerParentID = provider.parentID;
if (hasValue(providerParentID)) {
providerParentID = `${providerParentID}_0`;
}
provider.parentID = providerParentID ?? parentID;
} else {
provider.menuProviderId = provider.menuProviderId ?? `${menuID}_${index}`;
}

View File

@@ -62,8 +62,8 @@ describe('AbstractExpandableMenuProvider', () => {
type: MenuItemType.TEXT,
text: 'sub.section.test.1',
},
id: `${MenuID.ADMIN}_1_0`,
parentID: `${MenuID.ADMIN}_1`,
id: `${MenuID.ADMIN}_1_0_0`,
parentID: `${MenuID.ADMIN}_1_0`,
alwaysRenderExpandable: false,
},
{
@@ -72,8 +72,8 @@ describe('AbstractExpandableMenuProvider', () => {
type: MenuItemType.TEXT,
text: 'sub.section.test.2',
},
id: `${MenuID.ADMIN}_1_1`,
parentID: `${MenuID.ADMIN}_1`,
id: `${MenuID.ADMIN}_1_0_1`,
parentID: `${MenuID.ADMIN}_1_0`,
alwaysRenderExpandable: false,
},
{
@@ -83,7 +83,7 @@ describe('AbstractExpandableMenuProvider', () => {
text: 'top.section.test',
},
icon: 'file-import',
id: `${MenuID.ADMIN}_1`,
id: `${MenuID.ADMIN}_1_0`,
alwaysRenderExpandable: true,
},
];

View File

@@ -45,11 +45,12 @@ export abstract class AbstractExpandableMenuProvider extends AbstractMenuProvide
map((
[partialTopSection, partialSubSections]: [PartialMenuSection, PartialMenuSection[]],
) => {
const parentID = partialTopSection.id ?? this.getAutomatedSectionIdForTopSection();
const subSections = partialSubSections.map((partialSub, index) => {
return {
...partialSub,
id: partialSub.id ?? `${this.menuProviderId}_${index}`,
parentID: this.menuProviderId,
id: partialSub.id ?? this.getAutomatedSectionIdForSubsection(index),
parentID: parentID,
alwaysRenderExpandable: false,
};
});
@@ -58,7 +59,7 @@ export abstract class AbstractExpandableMenuProvider extends AbstractMenuProvide
...subSections,
{
...partialTopSection,
id: this.menuProviderId,
id: parentID,
alwaysRenderExpandable: this.alwaysRenderExpandable,
},
];
@@ -70,7 +71,7 @@ export abstract class AbstractExpandableMenuProvider extends AbstractMenuProvide
return this.getAutomatedSectionId(0);
}
protected getAutomatedSectionIdForSubsection(indexOfSubSectionInProvider: number): string {
return `${this.menuProviderId}_0_${indexOfSubSectionInProvider}`;
return `${this.getAutomatedSectionIdForTopSection()}_${indexOfSubSectionInProvider}`;
}
}

View File

@@ -22,7 +22,7 @@ import { MenuItemType } from '../../menu-item-type.model';
import { PartialMenuSection } from '../../menu-provider.model';
import { AbstractRouteContextMenuProvider } from './route-context.menu';
describe('AbstractExpandableMenuProvider', () => {
describe('AbstractRouteContextMenuProvider', () => {
class TestClass extends AbstractRouteContextMenuProvider<CacheableObject> {
getRouteContext(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<CacheableObject> {