Skip to content

Commit 4f1013a

Browse files
committed
Fix small issues
1 parent cb4a7b3 commit 4f1013a

6 files changed

Lines changed: 23 additions & 12 deletions

File tree

src/app/app.menus.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ export const MENUS = buildMenuStructure({
7373
ClaimMenuProvider.onRoute(
7474
MenuRoute.SIMPLE_ITEM_PAGE,
7575
MenuRoute.FULL_ITEM_PAGE,
76-
MenuRoute.SIMPLE_COLLECTION_PAGE,
7776
),
7877
]),
7978
],

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ export interface PartialMenuSection {
2222
visible: boolean;
2323
model: MenuItemModels;
2424
parentID?: string;
25-
index?: number;
2625
active?: boolean;
2726
shouldPersistOnRouteChange?: boolean;
2827
icon?: string;
@@ -65,7 +64,7 @@ export abstract class AbstractMenuProvider implements MenuProvider {
6564

6665
/**
6766
* ID of the menu this provider is part of
68-
* If not set up, this will be set based on the provider class name
67+
* This will be set to the menu ID of the menu in which it is present in the app.menus.ts file
6968
*/
7069
menuID?: MenuID;
7170

@@ -144,6 +143,10 @@ export abstract class AbstractMenuProvider implements MenuProvider {
144143
*/
145144
abstract getSections(route?: ActivatedRouteSnapshot, state?: RouterStateSnapshot): Observable<PartialMenuSection[]>;
146145

146+
protected getAutomatedSectionId(indexOfSectionInProvider: number): string {
147+
return `${this.menuProviderId}_${indexOfSectionInProvider};`
148+
}
149+
147150
}
148151

149152

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ export class MenuProviderService {
9292
provider: AbstractMenuProvider,
9393
sections: PartialMenuSection[]
9494
}, sectionIndex) => {
95-
providerWithSection.sections.forEach((section) => {
96-
this.addSection(providerWithSection.provider, section);
95+
providerWithSection.sections.forEach((section, index) => {
96+
this.addSection(providerWithSection.provider, section, index);
9797
});
9898
return this.waitForMenu$(providerWithSection.provider.menuID);
9999
});
@@ -156,8 +156,8 @@ export class MenuProviderService {
156156
provider: AbstractMenuProvider,
157157
sections: PartialMenuSection[]
158158
}) => {
159-
providerWithSection.sections.forEach((section) => {
160-
this.addSection(providerWithSection.provider, section);
159+
providerWithSection.sections.forEach((section, index) => {
160+
this.addSection(providerWithSection.provider, section, index);
161161
});
162162
return this.waitForMenu$(providerWithSection.provider.menuID);
163163
});
@@ -172,12 +172,13 @@ export class MenuProviderService {
172172
* @param provider - The provider of the section which will be used to provide extra data to the section
173173
* @param section - The partial section to be added to the menus
174174
*/
175-
private addSection(provider: AbstractMenuProvider, section: PartialMenuSection) {
175+
private addSection(provider: AbstractMenuProvider, section: PartialMenuSection, index: number) {
176176
this.menuService.addSection(provider.menuID, {
177177
...section,
178-
id: section.id ?? `${provider.menuProviderId}`,
178+
id: section.id ?? `${provider.menuProviderId}_${index}`,
179179
parentID: section.parentID ?? provider.parentID,
180-
index: section.index ?? provider.index,
180+
index: provider.index,
181+
active: section.active ?? true,
181182
shouldPersistOnRouteChange: section.shouldPersistOnRouteChange ?? provider.shouldPersistOnRouteChange,
182183
alwaysRenderExpandable: section.alwaysRenderExpandable ?? provider.alwaysRenderExpandable,
183184
});

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function processProviderType(providers: Provider[], menuID: string, providerType
5353
const childProviderTypes = (providerType as any).childProviderTypes;
5454

5555
childProviderTypes.forEach((childProviderType, childIndex: number) => {
56-
processProviderType(providers, menuID, childProviderType, childIndex, `${menuID}_${index}`, hasSubProviders);
56+
processProviderType(providers, menuID, childProviderType, childIndex, `${menuID}_${index}_0`, hasSubProviders);
5757
});
5858
processProviderType(providers, menuID, providerPart, index, parentID, true);
5959

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,12 @@ export abstract class AbstractExpandableMenuProvider extends AbstractMenuProvide
5858
})
5959
);
6060
}
61+
62+
protected getAutomatedSectionIdForTopSection(): string {
63+
return this.getAutomatedSectionId(0);
64+
}
65+
protected getAutomatedSectionIdForSubsection(indexOfSubSectionInProvider: number): string {
66+
return `${this.menuProviderId}_0_${indexOfSubSectionInProvider};`
67+
}
68+
6169
}

src/app/shared/menu/providers/item-claim.menu.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export class ClaimMenuProvider extends DSpaceObjectPageMenuProvider {
8181
this.translate.get('researcherprofile.success.claim.body'),
8282
);
8383
this.authorizationService.invalidateAuthorizationsRequestCache();
84-
this.menuService.hideMenuSection(MenuID.DSO_EDIT, this.menuProviderId);
84+
this.menuService.hideMenuSection(MenuID.DSO_EDIT, this.getAutomatedSectionId(0));
8585
} else {
8686
this.notificationsService.error(
8787
this.translate.get('researcherprofile.error.claim.title'),

0 commit comments

Comments
 (0)