mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
[DURACOM-191] remove provide-render-browse-by, use exported const instead
This commit is contained in:
@@ -33,10 +33,10 @@ import { ThemedRootComponent } from './root/themed-root.component';
|
||||
import { workflowTasks } from './core/provide-workflow-tasks';
|
||||
import { metadataRepresentations } from './core/provide-metadata-representation';
|
||||
import { renderStartsWith } from './core/provide-render-starts-with';
|
||||
import { renderBrowseBy } from './core/provide-render-browse-by';
|
||||
import { renderAuthMethod } from './core/provide-render-auth-method';
|
||||
import { NgxMaskModule } from 'ngx-mask';
|
||||
import { ListableModule } from './core/shared/listable.module';
|
||||
import { BROWSE_BY_DECORATOR_MAP } from './browse-by/browse-by-switcher/browse-by-decorator';
|
||||
|
||||
export function getConfig() {
|
||||
return environment;
|
||||
@@ -137,6 +137,6 @@ export class AppModule {
|
||||
workflowTasks = workflowTasks;
|
||||
metadataRepresentations = metadataRepresentations;
|
||||
renderStartsWith = renderStartsWith;
|
||||
renderBrowseBy = renderBrowseBy;
|
||||
browseByDecoratorMap = BROWSE_BY_DECORATOR_MAP;
|
||||
renderAuthMethod = renderAuthMethod;
|
||||
}
|
||||
|
@@ -17,7 +17,8 @@ import { ThemedBrowseByTitlePageComponent } from '../browse-by-title-page/themed
|
||||
export enum BrowseByDataType {
|
||||
Title = 'title',
|
||||
Metadata = 'text',
|
||||
Date = 'date'
|
||||
Date = 'date',
|
||||
Hierarchy = 'hierarchy'
|
||||
}
|
||||
|
||||
export const DEFAULT_BROWSE_BY_TYPE = BrowseByDataType.Metadata;
|
||||
@@ -27,28 +28,32 @@ export const BROWSE_BY_COMPONENT_FACTORY = new InjectionToken<(browseByType, the
|
||||
factory: () => getComponentByBrowseByType
|
||||
});
|
||||
|
||||
const map = new Map();
|
||||
map.set(BrowseByDataType.Date, new Map());
|
||||
map.get(BrowseByDataType.Date).set(DEFAULT_THEME, ThemedBrowseByDatePageComponent);
|
||||
map.set(BrowseByDataType.Metadata, new Map());
|
||||
map.get(BrowseByDataType.Metadata).set(DEFAULT_THEME, ThemedBrowseByMetadataPageComponent);
|
||||
map.set('hierarchy', new Map());
|
||||
map.get('hierarchy').set(DEFAULT_THEME, ThemedBrowseByTaxonomyPageComponent);
|
||||
map.set(BrowseByDataType.Title, new Map());
|
||||
map.get(BrowseByDataType.Title).set(DEFAULT_THEME, ThemedBrowseByTitlePageComponent);
|
||||
type BrowseByComponentType =
|
||||
typeof ThemedBrowseByTitlePageComponent |
|
||||
typeof ThemedBrowseByMetadataPageComponent |
|
||||
typeof ThemedBrowseByDatePageComponent |
|
||||
typeof ThemedBrowseByTaxonomyPageComponent;
|
||||
|
||||
export const BROWSE_BY_DECORATOR_MAP =
|
||||
new Map<BrowseByDataType, Map<string, BrowseByComponentType>>([
|
||||
[BrowseByDataType.Date, new Map([[DEFAULT_THEME, ThemedBrowseByDatePageComponent]])],
|
||||
[BrowseByDataType.Metadata, new Map([[DEFAULT_THEME, ThemedBrowseByMetadataPageComponent]])],
|
||||
[BrowseByDataType.Hierarchy, new Map([[DEFAULT_THEME, ThemedBrowseByTaxonomyPageComponent]])],
|
||||
[BrowseByDataType.Title, new Map([[DEFAULT_THEME, ThemedBrowseByTitlePageComponent]])]
|
||||
]);
|
||||
|
||||
/**
|
||||
* Decorator used for rendering Browse-By pages by type
|
||||
* @param browseByType The type of page
|
||||
* @param theme The optional theme for the component
|
||||
*/
|
||||
export function rendersBrowseBy(browseByType: string, theme = DEFAULT_THEME) {
|
||||
export function rendersBrowseBy(browseByType: BrowseByDataType, theme = DEFAULT_THEME) {
|
||||
return function decorator(component: any) {
|
||||
if (hasNoValue(map.get(browseByType))) {
|
||||
map.set(browseByType, new Map());
|
||||
if (hasNoValue(BROWSE_BY_DECORATOR_MAP.get(browseByType))) {
|
||||
BROWSE_BY_DECORATOR_MAP.set(browseByType, new Map());
|
||||
}
|
||||
if (hasNoValue(map.get(browseByType).get(theme))) {
|
||||
map.get(browseByType).set(theme, component);
|
||||
if (hasNoValue(BROWSE_BY_DECORATOR_MAP.get(browseByType).get(theme))) {
|
||||
BROWSE_BY_DECORATOR_MAP.get(browseByType).set(theme, component);
|
||||
} else {
|
||||
throw new Error(`There can't be more than one component to render Browse-By of type "${browseByType}" and theme "${theme}"`);
|
||||
}
|
||||
@@ -61,9 +66,9 @@ export function rendersBrowseBy(browseByType: string, theme = DEFAULT_THEME) {
|
||||
* @param theme the theme to match
|
||||
*/
|
||||
export function getComponentByBrowseByType(browseByType, theme) {
|
||||
let themeMap = map.get(browseByType);
|
||||
let themeMap = BROWSE_BY_DECORATOR_MAP.get(browseByType);
|
||||
if (hasNoValue(themeMap)) {
|
||||
themeMap = map.get(DEFAULT_BROWSE_BY_TYPE);
|
||||
themeMap = BROWSE_BY_DECORATOR_MAP.get(DEFAULT_BROWSE_BY_TYPE);
|
||||
}
|
||||
const comp = resolveTheme(themeMap, theme);
|
||||
if (hasNoValue(comp)) {
|
||||
|
@@ -1,22 +0,0 @@
|
||||
import {
|
||||
ThemedBrowseByMetadataPageComponent
|
||||
} from '../browse-by/browse-by-metadata-page/themed-browse-by-metadata-page.component';
|
||||
import { ThemedBrowseByDatePageComponent } from '../browse-by/browse-by-date-page/themed-browse-by-date-page.component';
|
||||
import {
|
||||
ThemedBrowseByTitlePageComponent
|
||||
} from '../browse-by/browse-by-title-page/themed-browse-by-title-page.component';
|
||||
import {
|
||||
ThemedBrowseByTaxonomyPageComponent
|
||||
} from '../browse-by/browse-by-taxonomy-page/themed-browse-by-taxonomy-page.component';
|
||||
|
||||
|
||||
/**
|
||||
* Declaration needed to make sure all decorator functions are called in time
|
||||
*/
|
||||
export const renderBrowseBy =
|
||||
[
|
||||
ThemedBrowseByMetadataPageComponent,
|
||||
ThemedBrowseByDatePageComponent,
|
||||
ThemedBrowseByTitlePageComponent,
|
||||
ThemedBrowseByTaxonomyPageComponent,
|
||||
];
|
Reference in New Issue
Block a user