Skip to content

Commit 4a2158a

Browse files
committed
Merge branch 'refactor-menu-resolvers-7.6' into refactor-menu-resolvers-9.0
2 parents 174d185 + bb02acf commit 4a2158a

6 files changed

Lines changed: 22 additions & 11 deletions

File tree

src/app/shared/menu/menu-provider.model.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { MenuItemModels } from './menu-section.model';
2323
*/
2424
export interface PartialMenuSection {
2525
id?: string;
26+
accessibilityHandle?: string;
2627
visible: boolean;
2728
model: MenuItemModels;
2829
parentID?: string;

src/app/shared/menu/menu-section.model.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ export interface MenuSection {
1919
*/
2020
id: string;
2121

22+
/**
23+
* Accessibility handle that can be used to find a specific menu in the html
24+
*/
25+
accessibilityHandle?: string;
26+
2227
/**
2328
* Whether this section should be visible.
2429
*/

src/app/shared/menu/menu.structure.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,11 @@ function addProviderToList(providers: Provider[], providerType: Type<AbstractMen
9494
provider.index = provider.index ?? index;
9595
if (hasValue(parentID)) {
9696
provider.menuProviderId = provider.menuProviderId ?? `${parentID}_${index}`;
97-
provider.parentID = provider.parentID ?? parentID;
97+
let providerParentID = provider.parentID;
98+
if (hasValue(providerParentID)) {
99+
providerParentID = `${providerParentID}_0`;
100+
}
101+
provider.parentID = providerParentID ?? parentID;
98102
} else {
99103
provider.menuProviderId = provider.menuProviderId ?? `${menuID}_${index}`;
100104
}

src/app/shared/menu/providers/helper-providers/expandable-menu-provider.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ describe('AbstractExpandableMenuProvider', () => {
6262
type: MenuItemType.TEXT,
6363
text: 'sub.section.test.1',
6464
},
65-
id: `${MenuID.ADMIN}_1_0`,
66-
parentID: `${MenuID.ADMIN}_1`,
65+
id: `${MenuID.ADMIN}_1_0_0`,
66+
parentID: `${MenuID.ADMIN}_1_0`,
6767
alwaysRenderExpandable: false,
6868
},
6969
{
@@ -72,8 +72,8 @@ describe('AbstractExpandableMenuProvider', () => {
7272
type: MenuItemType.TEXT,
7373
text: 'sub.section.test.2',
7474
},
75-
id: `${MenuID.ADMIN}_1_1`,
76-
parentID: `${MenuID.ADMIN}_1`,
75+
id: `${MenuID.ADMIN}_1_0_1`,
76+
parentID: `${MenuID.ADMIN}_1_0`,
7777
alwaysRenderExpandable: false,
7878
},
7979
{
@@ -83,7 +83,7 @@ describe('AbstractExpandableMenuProvider', () => {
8383
text: 'top.section.test',
8484
},
8585
icon: 'file-import',
86-
id: `${MenuID.ADMIN}_1`,
86+
id: `${MenuID.ADMIN}_1_0`,
8787
alwaysRenderExpandable: true,
8888
},
8989
];

src/app/shared/menu/providers/helper-providers/expandable-menu-provider.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,12 @@ export abstract class AbstractExpandableMenuProvider extends AbstractMenuProvide
4545
map((
4646
[partialTopSection, partialSubSections]: [PartialMenuSection, PartialMenuSection[]],
4747
) => {
48+
const parentID = partialTopSection.id ?? this.getAutomatedSectionIdForTopSection();
4849
const subSections = partialSubSections.map((partialSub, index) => {
4950
return {
5051
...partialSub,
51-
id: partialSub.id ?? `${this.menuProviderId}_${index}`,
52-
parentID: this.menuProviderId,
52+
id: partialSub.id ?? this.getAutomatedSectionIdForSubsection(index),
53+
parentID: parentID,
5354
alwaysRenderExpandable: false,
5455
};
5556
});
@@ -58,7 +59,7 @@ export abstract class AbstractExpandableMenuProvider extends AbstractMenuProvide
5859
...subSections,
5960
{
6061
...partialTopSection,
61-
id: this.menuProviderId,
62+
id: parentID,
6263
alwaysRenderExpandable: this.alwaysRenderExpandable,
6364
},
6465
];
@@ -70,7 +71,7 @@ export abstract class AbstractExpandableMenuProvider extends AbstractMenuProvide
7071
return this.getAutomatedSectionId(0);
7172
}
7273
protected getAutomatedSectionIdForSubsection(indexOfSubSectionInProvider: number): string {
73-
return `${this.menuProviderId}_0_${indexOfSubSectionInProvider}`;
74+
return `${this.getAutomatedSectionIdForTopSection()}_${indexOfSubSectionInProvider}`;
7475
}
7576

7677
}

src/app/shared/menu/providers/helper-providers/route-context.menu.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { MenuItemType } from '../../menu-item-type.model';
2222
import { PartialMenuSection } from '../../menu-provider.model';
2323
import { AbstractRouteContextMenuProvider } from './route-context.menu';
2424

25-
describe('AbstractExpandableMenuProvider', () => {
25+
describe('AbstractRouteContextMenuProvider', () => {
2626

2727
class TestClass extends AbstractRouteContextMenuProvider<CacheableObject> {
2828
getRouteContext(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<CacheableObject> {

0 commit comments

Comments
 (0)