Fix small issues

This commit is contained in:
Yana De Pauw
2025-01-20 13:27:36 +01:00
parent cb4a7b31f0
commit 4f1013a20d
6 changed files with 23 additions and 12 deletions

View File

@@ -73,7 +73,6 @@ export const MENUS = buildMenuStructure({
ClaimMenuProvider.onRoute(
MenuRoute.SIMPLE_ITEM_PAGE,
MenuRoute.FULL_ITEM_PAGE,
MenuRoute.SIMPLE_COLLECTION_PAGE,
),
]),
],

View File

@@ -22,7 +22,6 @@ export interface PartialMenuSection {
visible: boolean;
model: MenuItemModels;
parentID?: string;
index?: number;
active?: boolean;
shouldPersistOnRouteChange?: boolean;
icon?: string;
@@ -65,7 +64,7 @@ export abstract class AbstractMenuProvider implements MenuProvider {
/**
* ID of the menu this provider is part of
* If not set up, this will be set based on the provider class name
* This will be set to the menu ID of the menu in which it is present in the app.menus.ts file
*/
menuID?: MenuID;
@@ -144,6 +143,10 @@ export abstract class AbstractMenuProvider implements MenuProvider {
*/
abstract getSections(route?: ActivatedRouteSnapshot, state?: RouterStateSnapshot): Observable<PartialMenuSection[]>;
protected getAutomatedSectionId(indexOfSectionInProvider: number): string {
return `${this.menuProviderId}_${indexOfSectionInProvider};`
}
}

View File

@@ -92,8 +92,8 @@ export class MenuProviderService {
provider: AbstractMenuProvider,
sections: PartialMenuSection[]
}, sectionIndex) => {
providerWithSection.sections.forEach((section) => {
this.addSection(providerWithSection.provider, section);
providerWithSection.sections.forEach((section, index) => {
this.addSection(providerWithSection.provider, section, index);
});
return this.waitForMenu$(providerWithSection.provider.menuID);
});
@@ -156,8 +156,8 @@ export class MenuProviderService {
provider: AbstractMenuProvider,
sections: PartialMenuSection[]
}) => {
providerWithSection.sections.forEach((section) => {
this.addSection(providerWithSection.provider, section);
providerWithSection.sections.forEach((section, index) => {
this.addSection(providerWithSection.provider, section, index);
});
return this.waitForMenu$(providerWithSection.provider.menuID);
});
@@ -172,12 +172,13 @@ export class MenuProviderService {
* @param provider - The provider of the section which will be used to provide extra data to the section
* @param section - The partial section to be added to the menus
*/
private addSection(provider: AbstractMenuProvider, section: PartialMenuSection) {
private addSection(provider: AbstractMenuProvider, section: PartialMenuSection, index: number) {
this.menuService.addSection(provider.menuID, {
...section,
id: section.id ?? `${provider.menuProviderId}`,
id: section.id ?? `${provider.menuProviderId}_${index}`,
parentID: section.parentID ?? provider.parentID,
index: section.index ?? provider.index,
index: provider.index,
active: section.active ?? true,
shouldPersistOnRouteChange: section.shouldPersistOnRouteChange ?? provider.shouldPersistOnRouteChange,
alwaysRenderExpandable: section.alwaysRenderExpandable ?? provider.alwaysRenderExpandable,
});

View File

@@ -53,7 +53,7 @@ function processProviderType(providers: Provider[], menuID: string, providerType
const childProviderTypes = (providerType as any).childProviderTypes;
childProviderTypes.forEach((childProviderType, childIndex: number) => {
processProviderType(providers, menuID, childProviderType, childIndex, `${menuID}_${index}`, hasSubProviders);
processProviderType(providers, menuID, childProviderType, childIndex, `${menuID}_${index}_0`, hasSubProviders);
});
processProviderType(providers, menuID, providerPart, index, parentID, true);

View File

@@ -58,4 +58,12 @@ export abstract class AbstractExpandableMenuProvider extends AbstractMenuProvide
})
);
}
protected getAutomatedSectionIdForTopSection(): string {
return this.getAutomatedSectionId(0);
}
protected getAutomatedSectionIdForSubsection(indexOfSubSectionInProvider: number): string {
return `${this.menuProviderId}_0_${indexOfSubSectionInProvider};`
}
}

View File

@@ -81,7 +81,7 @@ export class ClaimMenuProvider extends DSpaceObjectPageMenuProvider {
this.translate.get('researcherprofile.success.claim.body'),
);
this.authorizationService.invalidateAuthorizationsRequestCache();
this.menuService.hideMenuSection(MenuID.DSO_EDIT, this.menuProviderId);
this.menuService.hideMenuSection(MenuID.DSO_EDIT, this.getAutomatedSectionId(0));
} else {
this.notificationsService.error(
this.translate.get('researcherprofile.error.claim.title'),