mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
51 lines
2.2 KiB
TypeScript
51 lines
2.2 KiB
TypeScript
import { Component, Inject, Input } from '@angular/core';
|
|
import {
|
|
MetadataRepresentation,
|
|
MetadataRepresentationType
|
|
} from '../../core/shared/metadata-representation/metadata-representation.model';
|
|
import { METADATA_REPRESENTATION_COMPONENT_FACTORY } from './metadata-representation.decorator';
|
|
import { Context } from '../../core/shared/context.model';
|
|
import { GenericConstructor } from '../../core/shared/generic-constructor';
|
|
import { MetadataRepresentationListElementComponent } from '../object-list/metadata-representation-list-element/metadata-representation-list-element.component';
|
|
import { ThemeService } from '../theme-support/theme.service';
|
|
import { AbstractComponentLoaderComponent } from '../abstract-component-loader/abstract-component-loader.component';
|
|
|
|
@Component({
|
|
selector: 'ds-metadata-representation-loader',
|
|
templateUrl: '../abstract-component-loader/abstract-component-loader.component.html',
|
|
})
|
|
/**
|
|
* Component for determining what component to use depending on the item's entity type (dspace.entity.type), its metadata representation and, optionally, its context
|
|
*/
|
|
export class MetadataRepresentationLoaderComponent extends AbstractComponentLoaderComponent<MetadataRepresentationListElementComponent> {
|
|
|
|
@Input() context: Context;
|
|
|
|
/**
|
|
* The item or metadata to determine the component for
|
|
*/
|
|
@Input() mdRepresentation: MetadataRepresentation;
|
|
|
|
protected inputNamesDependentForComponent: (keyof this & string)[] = [
|
|
'context',
|
|
'mdRepresentation',
|
|
];
|
|
|
|
protected inputNames: (keyof this & string)[] = [
|
|
'context',
|
|
'mdRepresentation',
|
|
];
|
|
|
|
constructor(
|
|
protected themeService: ThemeService,
|
|
@Inject(METADATA_REPRESENTATION_COMPONENT_FACTORY) private getMetadataRepresentationComponent: (entityType: string, mdRepresentationType: MetadataRepresentationType, context: Context, theme: string) => GenericConstructor<any>,
|
|
) {
|
|
super(themeService);
|
|
}
|
|
|
|
public getComponent(): GenericConstructor<MetadataRepresentationListElementComponent> {
|
|
return this.getMetadataRepresentationComponent(this.mdRepresentation.itemType, this.mdRepresentation.representationType, this.context, this.themeService.getThemeName());
|
|
}
|
|
|
|
}
|