mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-17 15:03:07 +00:00
[DURACOM-191] set static map for menu-item decorator
This commit is contained in:
@@ -1,20 +1,12 @@
|
||||
import { MenuItemType } from './menu-item-type.model';
|
||||
import { defer } from 'rxjs';
|
||||
|
||||
const menuMenuItemComponentMap = new Map();
|
||||
|
||||
/**
|
||||
* Decorator function to link a MenuItemType to a Component
|
||||
* @param {MenuItemType} type The MenuItemType of the MenuSection's model
|
||||
* @returns {(sectionComponent: GenericContructor) => void}
|
||||
*/
|
||||
export function rendersMenuItemForType(type: MenuItemType) {
|
||||
return function decorator(sectionComponent: any) {
|
||||
if (!sectionComponent) {
|
||||
return;
|
||||
}
|
||||
menuMenuItemComponentMap.set(type, sectionComponent);
|
||||
};
|
||||
}
|
||||
const menuMenuItemComponentMap = {
|
||||
[MenuItemType.EXTERNAL]: defer(() => import('./menu-item/external-link-menu-item.component').then(m => m.ExternalLinkMenuItemComponent)),
|
||||
[MenuItemType.LINK]: defer(() => import('./menu-item/link-menu-item.component').then(m => m.LinkMenuItemComponent)),
|
||||
[MenuItemType.ONCLICK]: defer(() => import('./menu-item/onclick-menu-item.component').then(m => m.OnClickMenuItemComponent)),
|
||||
[MenuItemType.TEXT]: defer(() => import('./menu-item/text-menu-item.component').then(m => m.TextMenuItemComponent))
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves the Component matching a given MenuItemType
|
||||
@@ -22,5 +14,5 @@ export function rendersMenuItemForType(type: MenuItemType) {
|
||||
* @returns {GenericConstructor} The constructor of the Component that matches the MenuItemType
|
||||
*/
|
||||
export function getComponentForMenuItemType(type: MenuItemType) {
|
||||
return menuMenuItemComponentMap.get(type);
|
||||
return menuMenuItemComponentMap[type];
|
||||
}
|
||||
|
Reference in New Issue
Block a user