mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-10 19:43:04 +00:00
refactoring
This commit is contained in:
@@ -65,7 +65,7 @@
|
||||
"id": "ID",
|
||||
"expectedcompletion": "Expected Completion",
|
||||
"description": "Description",
|
||||
"keywords": "Keywords"
|
||||
"keyword": "Keywords"
|
||||
}
|
||||
},
|
||||
"orgunit": {
|
||||
|
@@ -19,11 +19,11 @@ import { FileSectionComponent } from './simple/field-components/file-section/fil
|
||||
import { CollectionsComponent } from './field-components/collections/collections.component';
|
||||
import { FullItemPageComponent } from './full/full-item-page.component';
|
||||
import { FullFileSectionComponent } from './full/field-components/file-section/full-file-section.component';
|
||||
import { ItemPageFieldsComponent } from './simple/relationship-types/item/item-page-fields.component';
|
||||
import { OrgUnitPageFieldsComponent } from './simple/relationship-types/orgunit/orgunit-page-fields.component';
|
||||
import { PersonPageFieldsComponent } from './simple/relationship-types/person/person-page-fields.component';
|
||||
import { ProjectPageFieldsComponent } from './simple/relationship-types/project/project-page-fields.component';
|
||||
import { RelationshipTypeSwitcherComponent } from './simple/relationship-types/switcher/relationship-type-switcher.component';
|
||||
import { ItemPageFieldsComponent } from './simple/entity-types/item/item-page-fields.component';
|
||||
import { OrgUnitPageFieldsComponent } from './simple/entity-types/orgunit/orgunit-page-fields.component';
|
||||
import { PersonPageFieldsComponent } from './simple/entity-types/person/person-page-fields.component';
|
||||
import { ProjectPageFieldsComponent } from './simple/entity-types/project/project-page-fields.component';
|
||||
import { EntityTypeSwitcherComponent } from './simple/entity-types/switcher/entity-type-switcher.component';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
@@ -46,7 +46,7 @@ import { RelationshipTypeSwitcherComponent } from './simple/relationship-types/s
|
||||
FileSectionComponent,
|
||||
CollectionsComponent,
|
||||
FullFileSectionComponent,
|
||||
RelationshipTypeSwitcherComponent,
|
||||
EntityTypeSwitcherComponent,
|
||||
ItemPageFieldsComponent,
|
||||
ProjectPageFieldsComponent,
|
||||
OrgUnitPageFieldsComponent,
|
||||
|
@@ -1,14 +1,14 @@
|
||||
import { ChangeDetectionStrategy, Component, Inject } from '@angular/core';
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import {
|
||||
DEFAULT_RELATIONSHIP_TYPE,
|
||||
rendersRelationshipType
|
||||
} from '../../../../shared/entities/relationship-type-decorator';
|
||||
DEFAULT_ENTITY_TYPE,
|
||||
rendersEntityType
|
||||
} from '../../../../shared/entities/entity-type-decorator';
|
||||
import { ElementViewMode } from '../../../../shared/view-mode';
|
||||
import { ITEM } from '../switcher/relationship-type-switcher.component';
|
||||
import { ITEM } from '../switcher/entity-type-switcher.component';
|
||||
|
||||
@rendersRelationshipType('Item', ElementViewMode.Full)
|
||||
@rendersRelationshipType(DEFAULT_RELATIONSHIP_TYPE, ElementViewMode.Full)
|
||||
@rendersEntityType('Item', ElementViewMode.Full)
|
||||
@rendersEntityType(DEFAULT_ENTITY_TYPE, ElementViewMode.Full)
|
||||
@Component({
|
||||
selector: 'ds-item-page-fields',
|
||||
styleUrls: ['./item-page-fields.component.scss'],
|
@@ -1,10 +1,10 @@
|
||||
import { Component, Inject } from '@angular/core';
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { rendersRelationshipType } from '../../../../shared/entities/relationship-type-decorator';
|
||||
import { rendersEntityType } from '../../../../shared/entities/entity-type-decorator';
|
||||
import { ElementViewMode } from '../../../../shared/view-mode';
|
||||
import { ITEM } from '../switcher/relationship-type-switcher.component';
|
||||
import { ITEM } from '../switcher/entity-type-switcher.component';
|
||||
|
||||
@rendersRelationshipType('OrgUnit', ElementViewMode.Full)
|
||||
@rendersEntityType('OrgUnit', ElementViewMode.Full)
|
||||
@Component({
|
||||
selector: 'ds-orgunit-page-fields',
|
||||
styleUrls: ['./orgunit-page-fields.component.scss'],
|
@@ -1,10 +1,10 @@
|
||||
import { Component, Inject } from '@angular/core';
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { rendersRelationshipType } from '../../../../shared/entities/relationship-type-decorator';
|
||||
import { rendersEntityType } from '../../../../shared/entities/entity-type-decorator';
|
||||
import { ElementViewMode } from '../../../../shared/view-mode';
|
||||
import { ITEM } from '../switcher/relationship-type-switcher.component';
|
||||
import { ITEM } from '../switcher/entity-type-switcher.component';
|
||||
|
||||
@rendersRelationshipType('Person', ElementViewMode.Full)
|
||||
@rendersEntityType('Person', ElementViewMode.Full)
|
||||
@Component({
|
||||
selector: 'ds-person-page-fields',
|
||||
styleUrls: ['./person-page-fields.component.scss'],
|
@@ -25,8 +25,8 @@
|
||||
[label]="'project.page.description'">
|
||||
</ds-generic-item-page-field>
|
||||
<ds-generic-item-page-field [item]="item"
|
||||
[fields]="['project.identifier.keywords']"
|
||||
[label]="'project.page.keywords'">
|
||||
[fields]="['project.identifier.keyword']"
|
||||
[label]="'project.page.keyword'">
|
||||
</ds-generic-item-page-field>
|
||||
</div>
|
||||
</div>
|
@@ -1,10 +1,10 @@
|
||||
import { Component, Inject } from '@angular/core';
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { rendersRelationshipType } from '../../../../shared/entities/relationship-type-decorator';
|
||||
import { rendersEntityType } from '../../../../shared/entities/entity-type-decorator';
|
||||
import { ElementViewMode } from '../../../../shared/view-mode';
|
||||
import { ITEM } from '../switcher/relationship-type-switcher.component';
|
||||
import { ITEM } from '../switcher/entity-type-switcher.component';
|
||||
|
||||
@rendersRelationshipType('Project', ElementViewMode.Full)
|
||||
@rendersEntityType('Project', ElementViewMode.Full)
|
||||
@Component({
|
||||
selector: 'ds-project-page-fields',
|
||||
styleUrls: ['./project-page-fields.component.scss'],
|
@@ -1,7 +1,7 @@
|
||||
import { Component, InjectionToken, Injector, Input, OnInit } from '@angular/core';
|
||||
import { GenericConstructor } from '../../../../core/shared/generic-constructor';
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { getComponentByRelationshipType } from '../../../../shared/entities/relationship-type-decorator';
|
||||
import { getComponentByEntityType } from '../../../../shared/entities/entity-type-decorator';
|
||||
import { rendersDSOType } from '../../../../shared/object-collection/shared/dso-element-decorator';
|
||||
import { ListableObject } from '../../../../shared/object-collection/shared/listable-object.model';
|
||||
import { ElementViewMode, SetViewMode } from '../../../../shared/view-mode';
|
||||
@@ -9,11 +9,11 @@ import { ElementViewMode, SetViewMode } from '../../../../shared/view-mode';
|
||||
export const ITEM: InjectionToken<string> = new InjectionToken<string>('item');
|
||||
|
||||
@Component({
|
||||
selector: 'ds-relationship-type-switcher',
|
||||
styleUrls: ['./relationship-type-switcher.component.scss'],
|
||||
templateUrl: './relationship-type-switcher.component.html'
|
||||
selector: 'ds-entity-type-switcher',
|
||||
styleUrls: ['./entity-type-switcher.component.scss'],
|
||||
templateUrl: './entity-type-switcher.component.html'
|
||||
})
|
||||
export class RelationshipTypeSwitcherComponent implements OnInit {
|
||||
export class EntityTypeSwitcherComponent implements OnInit {
|
||||
@Input() item: Item;
|
||||
@Input() viewMode: ElementViewMode;
|
||||
objectInjector: Injector;
|
||||
@@ -31,6 +31,6 @@ export class RelationshipTypeSwitcherComponent implements OnInit {
|
||||
|
||||
getComponent(): string {
|
||||
const type = this.item.findMetadata('relationship.type');
|
||||
return getComponentByRelationshipType(type, this.viewMode);
|
||||
return getComponentByEntityType(type, this.viewMode);
|
||||
}
|
||||
}
|
@@ -1,7 +1,7 @@
|
||||
<div class="container" *ngVar="(itemRDObs | async) as itemRD">
|
||||
<div class="item-page" *ngIf="itemRD?.hasSucceeded" @fadeInOut>
|
||||
<div *ngIf="itemRD?.payload as item">
|
||||
<ds-relationship-type-switcher [item]="item" [viewMode]="ElementViewMode.Full"></ds-relationship-type-switcher>
|
||||
<ds-entity-type-switcher [item]="item" [viewMode]="ElementViewMode.Full"></ds-entity-type-switcher>
|
||||
</div>
|
||||
</div>
|
||||
<ds-error *ngIf="itemRD?.hasFailed" message="{{'error.item' | translate}}"></ds-error>
|
||||
|
@@ -1,10 +1,10 @@
|
||||
import { hasNoValue, hasValue } from '../empty.util';
|
||||
import { ElementViewMode } from '../view-mode';
|
||||
|
||||
export const DEFAULT_RELATIONSHIP_TYPE = 'Default';
|
||||
export const DEFAULT_ENTITY_TYPE = 'Default';
|
||||
|
||||
const map = new Map();
|
||||
export function rendersRelationshipType(type: string, viewMode: ElementViewMode) {
|
||||
export function rendersEntityType(type: string, viewMode: ElementViewMode) {
|
||||
return function decorator(component: any) {
|
||||
if (hasNoValue(map.get(viewMode))) {
|
||||
map.set(viewMode, new Map());
|
||||
@@ -16,10 +16,10 @@ export function rendersRelationshipType(type: string, viewMode: ElementViewMode)
|
||||
};
|
||||
}
|
||||
|
||||
export function getComponentByRelationshipType(type: string, viewMode: ElementViewMode) {
|
||||
export function getComponentByEntityType(type: string, viewMode: ElementViewMode) {
|
||||
let component = map.get(viewMode).get(type);
|
||||
if (hasNoValue(component)) {
|
||||
component = map.get(viewMode).get(DEFAULT_RELATIONSHIP_TYPE);
|
||||
component = map.get(viewMode).get(DEFAULT_ENTITY_TYPE);
|
||||
}
|
||||
return component;
|
||||
}
|
Reference in New Issue
Block a user