mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +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 { workflowTasks } from './core/provide-workflow-tasks';
|
||||||
import { metadataRepresentations } from './core/provide-metadata-representation';
|
import { metadataRepresentations } from './core/provide-metadata-representation';
|
||||||
import { renderStartsWith } from './core/provide-render-starts-with';
|
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 { renderAuthMethod } from './core/provide-render-auth-method';
|
||||||
import { NgxMaskModule } from 'ngx-mask';
|
import { NgxMaskModule } from 'ngx-mask';
|
||||||
import { ListableModule } from './core/shared/listable.module';
|
import { ListableModule } from './core/shared/listable.module';
|
||||||
|
import { BROWSE_BY_DECORATOR_MAP } from './browse-by/browse-by-switcher/browse-by-decorator';
|
||||||
|
|
||||||
export function getConfig() {
|
export function getConfig() {
|
||||||
return environment;
|
return environment;
|
||||||
@@ -137,6 +137,6 @@ export class AppModule {
|
|||||||
workflowTasks = workflowTasks;
|
workflowTasks = workflowTasks;
|
||||||
metadataRepresentations = metadataRepresentations;
|
metadataRepresentations = metadataRepresentations;
|
||||||
renderStartsWith = renderStartsWith;
|
renderStartsWith = renderStartsWith;
|
||||||
renderBrowseBy = renderBrowseBy;
|
browseByDecoratorMap = BROWSE_BY_DECORATOR_MAP;
|
||||||
renderAuthMethod = renderAuthMethod;
|
renderAuthMethod = renderAuthMethod;
|
||||||
}
|
}
|
||||||
|
@@ -17,7 +17,8 @@ import { ThemedBrowseByTitlePageComponent } from '../browse-by-title-page/themed
|
|||||||
export enum BrowseByDataType {
|
export enum BrowseByDataType {
|
||||||
Title = 'title',
|
Title = 'title',
|
||||||
Metadata = 'text',
|
Metadata = 'text',
|
||||||
Date = 'date'
|
Date = 'date',
|
||||||
|
Hierarchy = 'hierarchy'
|
||||||
}
|
}
|
||||||
|
|
||||||
export const DEFAULT_BROWSE_BY_TYPE = BrowseByDataType.Metadata;
|
export const DEFAULT_BROWSE_BY_TYPE = BrowseByDataType.Metadata;
|
||||||
@@ -27,28 +28,32 @@ export const BROWSE_BY_COMPONENT_FACTORY = new InjectionToken<(browseByType, the
|
|||||||
factory: () => getComponentByBrowseByType
|
factory: () => getComponentByBrowseByType
|
||||||
});
|
});
|
||||||
|
|
||||||
const map = new Map();
|
type BrowseByComponentType =
|
||||||
map.set(BrowseByDataType.Date, new Map());
|
typeof ThemedBrowseByTitlePageComponent |
|
||||||
map.get(BrowseByDataType.Date).set(DEFAULT_THEME, ThemedBrowseByDatePageComponent);
|
typeof ThemedBrowseByMetadataPageComponent |
|
||||||
map.set(BrowseByDataType.Metadata, new Map());
|
typeof ThemedBrowseByDatePageComponent |
|
||||||
map.get(BrowseByDataType.Metadata).set(DEFAULT_THEME, ThemedBrowseByMetadataPageComponent);
|
typeof ThemedBrowseByTaxonomyPageComponent;
|
||||||
map.set('hierarchy', new Map());
|
|
||||||
map.get('hierarchy').set(DEFAULT_THEME, ThemedBrowseByTaxonomyPageComponent);
|
export const BROWSE_BY_DECORATOR_MAP =
|
||||||
map.set(BrowseByDataType.Title, new Map());
|
new Map<BrowseByDataType, Map<string, BrowseByComponentType>>([
|
||||||
map.get(BrowseByDataType.Title).set(DEFAULT_THEME, ThemedBrowseByTitlePageComponent);
|
[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
|
* Decorator used for rendering Browse-By pages by type
|
||||||
* @param browseByType The type of page
|
* @param browseByType The type of page
|
||||||
* @param theme The optional theme for the component
|
* @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) {
|
return function decorator(component: any) {
|
||||||
if (hasNoValue(map.get(browseByType))) {
|
if (hasNoValue(BROWSE_BY_DECORATOR_MAP.get(browseByType))) {
|
||||||
map.set(browseByType, new Map());
|
BROWSE_BY_DECORATOR_MAP.set(browseByType, new Map());
|
||||||
}
|
}
|
||||||
if (hasNoValue(map.get(browseByType).get(theme))) {
|
if (hasNoValue(BROWSE_BY_DECORATOR_MAP.get(browseByType).get(theme))) {
|
||||||
map.get(browseByType).set(theme, component);
|
BROWSE_BY_DECORATOR_MAP.get(browseByType).set(theme, component);
|
||||||
} else {
|
} else {
|
||||||
throw new Error(`There can't be more than one component to render Browse-By of type "${browseByType}" and theme "${theme}"`);
|
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
|
* @param theme the theme to match
|
||||||
*/
|
*/
|
||||||
export function getComponentByBrowseByType(browseByType, theme) {
|
export function getComponentByBrowseByType(browseByType, theme) {
|
||||||
let themeMap = map.get(browseByType);
|
let themeMap = BROWSE_BY_DECORATOR_MAP.get(browseByType);
|
||||||
if (hasNoValue(themeMap)) {
|
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);
|
const comp = resolveTheme(themeMap, theme);
|
||||||
if (hasNoValue(comp)) {
|
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