1
0

rename 'entity' to 'item'

This commit is contained in:
Art Lowel
2019-01-16 15:34:01 +01:00
parent 593dcf7d06
commit 8c1874c584
97 changed files with 394 additions and 412 deletions

View File

@@ -19,16 +19,16 @@ import { FileSectionComponent } from './simple/field-components/file-section/fil
import { CollectionsComponent } from './field-components/collections/collections.component'; import { CollectionsComponent } from './field-components/collections/collections.component';
import { FullItemPageComponent } from './full/full-item-page.component'; import { FullItemPageComponent } from './full/full-item-page.component';
import { FullFileSectionComponent } from './full/field-components/file-section/full-file-section.component'; import { FullFileSectionComponent } from './full/field-components/file-section/full-file-section.component';
import { RelatedEntitiesComponent } from './simple/related-entities/related-entities-component'; import { RelatedItemsComponent } from './simple/related-items/related-items-component';
import { SearchPageModule } from '../+search-page/search-page.module'; import { SearchPageModule } from '../+search-page/search-page.module';
import { PublicationComponent } from './simple/entity-types/publication/publication.component'; import { PublicationComponent } from './simple/item-types/publication/publication.component';
import { PersonComponent } from './simple/entity-types/person/person.component'; import { PersonComponent } from './simple/item-types/person/person.component';
import { OrgunitComponent } from './simple/entity-types/orgunit/orgunit.component'; import { OrgunitComponent } from './simple/item-types/orgunit/orgunit.component';
import { ProjectComponent } from './simple/entity-types/project/project.component'; import { ProjectComponent } from './simple/item-types/project/project.component';
import { JournalComponent } from './simple/entity-types/journal/journal.component'; import { JournalComponent } from './simple/item-types/journal/journal.component';
import { JournalVolumeComponent } from './simple/entity-types/journal-volume/journal-volume.component'; import { JournalVolumeComponent } from './simple/item-types/journal-volume/journal-volume.component';
import { JournalIssueComponent } from './simple/entity-types/journal-issue/journal-issue.component'; import { JournalIssueComponent } from './simple/item-types/journal-issue/journal-issue.component';
import { EntityComponent } from './simple/entity-types/shared/entity.component'; import { ItemComponent } from './simple/item-types/shared/item.component';
@NgModule({ @NgModule({
imports: [ imports: [
@@ -56,8 +56,8 @@ import { EntityComponent } from './simple/entity-types/shared/entity.component';
ProjectComponent, ProjectComponent,
OrgunitComponent, OrgunitComponent,
PersonComponent, PersonComponent,
RelatedEntitiesComponent, RelatedItemsComponent,
EntityComponent, ItemComponent,
GenericItemPageFieldComponent, GenericItemPageFieldComponent,
JournalComponent, JournalComponent,
JournalIssueComponent, JournalIssueComponent,

View File

@@ -1,7 +1,7 @@
<div class="container" *ngVar="(itemRD$ | async) as itemRD"> <div class="container" *ngVar="(itemRD$ | async) as itemRD">
<div class="item-page" *ngIf="itemRD?.hasSucceeded" @fadeInOut> <div class="item-page" *ngIf="itemRD?.hasSucceeded" @fadeInOut>
<div *ngIf="itemRD?.payload as item"> <div *ngIf="itemRD?.payload as item">
<ds-entity-type-switcher [object]="item" [viewMode]="ElementViewMode.Full"></ds-entity-type-switcher> <ds-item-type-switcher [object]="item" [viewMode]="ElementViewMode.Full"></ds-item-type-switcher>
</div> </div>
</div> </div>
<ds-error *ngIf="itemRD?.hasFailed" message="{{'error.item' | translate}}"></ds-error> <ds-error *ngIf="itemRD?.hasFailed" message="{{'error.item' | translate}}"></ds-error>

View File

@@ -8,14 +8,13 @@ import { ActivatedRoute } from '@angular/router';
import { ActivatedRouteStub } from '../../shared/testing/active-router-stub'; import { ActivatedRouteStub } from '../../shared/testing/active-router-stub';
import { MetadataService } from '../../core/metadata/metadata.service'; import { MetadataService } from '../../core/metadata/metadata.service';
import { VarDirective } from '../../shared/utils/var.directive'; import { VarDirective } from '../../shared/utils/var.directive';
import { Observable } from 'rxjs';
import { RemoteData } from '../../core/data/remote-data'; import { RemoteData } from '../../core/data/remote-data';
import { Item } from '../../core/shared/item.model'; import { Item } from '../../core/shared/item.model';
import { PaginatedList } from '../../core/data/paginated-list'; import { PaginatedList } from '../../core/data/paginated-list';
import { PageInfo } from '../../core/shared/page-info.model'; import { PageInfo } from '../../core/shared/page-info.model';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { By } from '@angular/platform-browser'; import { By } from '@angular/platform-browser';
import { createRelationshipsObservable } from './entity-types/shared/entity.component.spec'; import { createRelationshipsObservable } from './item-types/shared/item.component.spec';
import { of as observableOf } from 'rxjs'; import { of as observableOf } from 'rxjs';
const mockItem: Item = Object.assign(new Item(), { const mockItem: Item = Object.assign(new Item(), {

View File

@@ -16,14 +16,14 @@
</ds-generic-item-page-field> </ds-generic-item-page-field>
</div> </div>
<div class="col-xs-12 col-md-6"> <div class="col-xs-12 col-md-6">
<ds-related-entities <ds-related-items
[entities]="volumes$ | async" [items]="volumes$ | async"
[label]="'relationships.isSingleVolumeOf' | translate"> [label]="'relationships.isSingleVolumeOf' | translate">
</ds-related-entities> </ds-related-items>
<ds-related-entities <ds-related-items
[entities]="publications$ | async" [items]="publications$ | async"
[label]="'relationships.isPublicationOfJournalIssue' | translate"> [label]="'relationships.isPublicationOfJournalIssue' | translate">
</ds-related-entities> </ds-related-items>
<ds-generic-item-page-field [item]="item" <ds-generic-item-page-field [item]="item"
[fields]="['journalissue.identifier.description']" [fields]="['journalissue.identifier.description']"
[label]="'journalissue.page.description'"> [label]="'journalissue.page.description'">

View File

@@ -1,9 +1,8 @@
import { Observable } from 'rxjs';
import { Item } from '../../../../core/shared/item.model'; import { Item } from '../../../../core/shared/item.model';
import { RemoteData } from '../../../../core/data/remote-data'; import { RemoteData } from '../../../../core/data/remote-data';
import { PaginatedList } from '../../../../core/data/paginated-list'; import { PaginatedList } from '../../../../core/data/paginated-list';
import { PageInfo } from '../../../../core/shared/page-info.model'; import { PageInfo } from '../../../../core/shared/page-info.model';
import { createRelationshipsObservable, getEntityPageFieldsTest } from '../shared/entity.component.spec'; import { createRelationshipsObservable, getItemPageFieldsTest } from '../shared/item.component.spec';
import { JournalIssueComponent } from './journal-issue.component'; import { JournalIssueComponent } from './journal-issue.component';
import { of as observableOf } from 'rxjs'; import { of as observableOf } from 'rxjs';
@@ -33,4 +32,4 @@ const mockItem: Item = Object.assign(new Item(), {
relationships: createRelationshipsObservable() relationships: createRelationshipsObservable()
}); });
describe('JournalIssueComponent', getEntityPageFieldsTest(mockItem, JournalIssueComponent)); describe('JournalIssueComponent', getItemPageFieldsTest(mockItem, JournalIssueComponent));

View File

@@ -2,22 +2,22 @@ import { Component, Inject } from '@angular/core';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { ItemDataService } from '../../../../core/data/item-data.service'; import { ItemDataService } from '../../../../core/data/item-data.service';
import { Item } from '../../../../core/shared/item.model'; import { Item } from '../../../../core/shared/item.model';
import { rendersEntityType } from '../../../../shared/entities/entity-type-decorator'; import { rendersItemType } from '../../../../shared/items/item-type-decorator';
import { ITEM } from '../../../../shared/entities/switcher/entity-type-switcher.component'; import { ITEM } from '../../../../shared/items/switcher/item-type-switcher.component';
import { ElementViewMode } from '../../../../shared/view-mode'; import { ElementViewMode } from '../../../../shared/view-mode';
import { isNotEmpty } from '../../../../shared/empty.util'; import { isNotEmpty } from '../../../../shared/empty.util';
import { EntityComponent, filterRelationsByTypeLabel, relationsToItems } from '../shared/entity.component'; import { ItemComponent, filterRelationsByTypeLabel, relationsToItems } from '../shared/item.component';
@rendersEntityType('JournalIssue', ElementViewMode.Full) @rendersItemType('JournalIssue', ElementViewMode.Full)
@Component({ @Component({
selector: 'ds-journal-issue', selector: 'ds-journal-issue',
styleUrls: ['./journal-issue.component.scss'], styleUrls: ['./journal-issue.component.scss'],
templateUrl: './journal-issue.component.html' templateUrl: './journal-issue.component.html'
}) })
/** /**
* The component for displaying metadata and relations of an item with entity type Journal Issue * The component for displaying metadata and relations of an item of the type Journal Issue
*/ */
export class JournalIssueComponent extends EntityComponent { export class JournalIssueComponent extends ItemComponent {
/** /**
* The volumes related to this journal issue * The volumes related to this journal issue
*/ */

View File

@@ -16,14 +16,14 @@
</ds-generic-item-page-field> </ds-generic-item-page-field>
</div> </div>
<div class="col-xs-12 col-md-6"> <div class="col-xs-12 col-md-6">
<ds-related-entities <ds-related-items
[entities]="journals$ | async" [items]="journals$ | async"
[label]="'relationships.isSingleJournalOf' | translate"> [label]="'relationships.isSingleJournalOf' | translate">
</ds-related-entities> </ds-related-items>
<ds-related-entities <ds-related-items
[entities]="issues$ | async" [items]="issues$ | async"
[label]="'relationships.isIssueOf' | translate"> [label]="'relationships.isIssueOf' | translate">
</ds-related-entities> </ds-related-items>
<ds-generic-item-page-field [item]="item" <ds-generic-item-page-field [item]="item"
[fields]="['journalvolume.identifier.description']" [fields]="['journalvolume.identifier.description']"
[label]="'journalvolume.page.description'"> [label]="'journalvolume.page.description'">

View File

@@ -1,9 +1,8 @@
import { Observable } from 'rxjs';
import { Item } from '../../../../core/shared/item.model'; import { Item } from '../../../../core/shared/item.model';
import { RemoteData } from '../../../../core/data/remote-data'; import { RemoteData } from '../../../../core/data/remote-data';
import { PaginatedList } from '../../../../core/data/paginated-list'; import { PaginatedList } from '../../../../core/data/paginated-list';
import { PageInfo } from '../../../../core/shared/page-info.model'; import { PageInfo } from '../../../../core/shared/page-info.model';
import { createRelationshipsObservable, getEntityPageFieldsTest } from '../shared/entity.component.spec'; import { createRelationshipsObservable, getItemPageFieldsTest } from '../shared/item.component.spec';
import { JournalVolumeComponent } from './journal-volume.component'; import { JournalVolumeComponent } from './journal-volume.component';
import { of as observableOf } from 'rxjs'; import { of as observableOf } from 'rxjs';
@@ -28,4 +27,4 @@ const mockItem: Item = Object.assign(new Item(), {
relationships: createRelationshipsObservable() relationships: createRelationshipsObservable()
}); });
describe('JournalVolumeComponent', getEntityPageFieldsTest(mockItem, JournalVolumeComponent)); describe('JournalVolumeComponent', getItemPageFieldsTest(mockItem, JournalVolumeComponent));

View File

@@ -2,22 +2,22 @@ import { Component, Inject } from '@angular/core';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { ItemDataService } from '../../../../core/data/item-data.service'; import { ItemDataService } from '../../../../core/data/item-data.service';
import { Item } from '../../../../core/shared/item.model'; import { Item } from '../../../../core/shared/item.model';
import { rendersEntityType } from '../../../../shared/entities/entity-type-decorator'; import { rendersItemType } from '../../../../shared/items/item-type-decorator';
import { ITEM } from '../../../../shared/entities/switcher/entity-type-switcher.component'; import { ITEM } from '../../../../shared/items/switcher/item-type-switcher.component';
import { ElementViewMode } from '../../../../shared/view-mode'; import { ElementViewMode } from '../../../../shared/view-mode';
import { isNotEmpty } from '../../../../shared/empty.util'; import { isNotEmpty } from '../../../../shared/empty.util';
import { EntityComponent, filterRelationsByTypeLabel, relationsToItems } from '../shared/entity.component'; import { ItemComponent, filterRelationsByTypeLabel, relationsToItems } from '../shared/item.component';
@rendersEntityType('JournalVolume', ElementViewMode.Full) @rendersItemType('JournalVolume', ElementViewMode.Full)
@Component({ @Component({
selector: 'ds-journal-volume', selector: 'ds-journal-volume',
styleUrls: ['./journal-volume.component.scss'], styleUrls: ['./journal-volume.component.scss'],
templateUrl: './journal-volume.component.html' templateUrl: './journal-volume.component.html'
}) })
/** /**
* The component for displaying metadata and relations of an item with entity type Journal Volume * The component for displaying metadata and relations of an item of the type Journal Volume
*/ */
export class JournalVolumeComponent extends EntityComponent { export class JournalVolumeComponent extends ItemComponent {
/** /**
* The journals related to this journal volume * The journals related to this journal volume
*/ */

View File

@@ -16,10 +16,10 @@
</ds-generic-item-page-field> </ds-generic-item-page-field>
</div> </div>
<div class="col-xs-12 col-md-6"> <div class="col-xs-12 col-md-6">
<ds-related-entities <ds-related-items
[entities]="volumes$ | async" [items]="volumes$ | async"
[label]="'relationships.isVolumeOf' | translate"> [label]="'relationships.isVolumeOf' | translate">
</ds-related-entities> </ds-related-items>
<ds-generic-item-page-field class="item-page-fields" [item]="item" <ds-generic-item-page-field class="item-page-fields" [item]="item"
[fields]="['journal.identifier.description']" [fields]="['journal.identifier.description']"
[label]="'journal.page.description'"> [label]="'journal.page.description'">

View File

@@ -1,10 +1,9 @@
import { ChangeDetectionStrategy, DebugElement, NO_ERRORS_SCHEMA } from '@angular/core'; import { ChangeDetectionStrategy, DebugElement, NO_ERRORS_SCHEMA } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { TruncatableService } from '../../../../shared/truncatable/truncatable.service'; import { TruncatableService } from '../../../../shared/truncatable/truncatable.service';
import { ITEM } from '../../../../shared/entities/switcher/entity-type-switcher.component'; import { ITEM } from '../../../../shared/items/switcher/item-type-switcher.component';
import { TruncatePipe } from '../../../../shared/utils/truncate.pipe'; import { TruncatePipe } from '../../../../shared/utils/truncate.pipe';
import { ItemDataService } from '../../../../core/data/item-data.service'; import { ItemDataService } from '../../../../core/data/item-data.service';
import { Observable } from 'rxjs';
import { Item } from '../../../../core/shared/item.model'; import { Item } from '../../../../core/shared/item.model';
import { By } from '@angular/platform-browser'; import { By } from '@angular/platform-browser';
import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; import { TranslateLoader, TranslateModule } from '@ngx-translate/core';

View File

@@ -2,22 +2,22 @@ import { Component, Inject } from '@angular/core';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { ItemDataService } from '../../../../core/data/item-data.service'; import { ItemDataService } from '../../../../core/data/item-data.service';
import { Item } from '../../../../core/shared/item.model'; import { Item } from '../../../../core/shared/item.model';
import { rendersEntityType } from '../../../../shared/entities/entity-type-decorator'; import { rendersItemType } from '../../../../shared/items/item-type-decorator';
import { ITEM } from '../../../../shared/entities/switcher/entity-type-switcher.component'; import { ITEM } from '../../../../shared/items/switcher/item-type-switcher.component';
import { ElementViewMode } from '../../../../shared/view-mode'; import { ElementViewMode } from '../../../../shared/view-mode';
import { isNotEmpty } from '../../../../shared/empty.util'; import { isNotEmpty } from '../../../../shared/empty.util';
import { EntityComponent, filterRelationsByTypeLabel, relationsToItems } from '../shared/entity.component'; import { ItemComponent, filterRelationsByTypeLabel, relationsToItems } from '../shared/item.component';
@rendersEntityType('Journal', ElementViewMode.Full) @rendersItemType('Journal', ElementViewMode.Full)
@Component({ @Component({
selector: 'ds-journal', selector: 'ds-journal',
styleUrls: ['./journal.component.scss'], styleUrls: ['./journal.component.scss'],
templateUrl: './journal.component.html' templateUrl: './journal.component.html'
}) })
/** /**
* The component for displaying metadata and relations of an item with entity type Journal * The component for displaying metadata and relations of an item of the type Journal
*/ */
export class JournalComponent extends EntityComponent { export class JournalComponent extends ItemComponent {
/** /**
* The volumes related to this journal * The volumes related to this journal
*/ */

View File

@@ -24,18 +24,18 @@
</ds-generic-item-page-field> </ds-generic-item-page-field>
</div> </div>
<div class="col-xs-12 col-md-6"> <div class="col-xs-12 col-md-6">
<ds-related-entities <ds-related-items
[entities]="people$ | async" [items]="people$ | async"
[label]="'relationships.isPersonOf' | translate"> [label]="'relationships.isPersonOf' | translate">
</ds-related-entities> </ds-related-items>
<ds-related-entities <ds-related-items
[entities]="projects$ | async" [items]="projects$ | async"
[label]="'relationships.isProjectOf' | translate"> [label]="'relationships.isProjectOf' | translate">
</ds-related-entities> </ds-related-items>
<ds-related-entities <ds-related-items
[entities]="publications$ | async" [items]="publications$ | async"
[label]="'relationships.isPublicationOf' | translate"> [label]="'relationships.isPublicationOf' | translate">
</ds-related-entities> </ds-related-items>
<ds-generic-item-page-field [item]="item" <ds-generic-item-page-field [item]="item"
[fields]="['orgunit.identifier.description']" [fields]="['orgunit.identifier.description']"
[label]="'orgunit.page.description'"> [label]="'orgunit.page.description'">

View File

@@ -1,9 +1,8 @@
import { Observable } from 'rxjs';
import { Item } from '../../../../core/shared/item.model'; import { Item } from '../../../../core/shared/item.model';
import { RemoteData } from '../../../../core/data/remote-data'; import { RemoteData } from '../../../../core/data/remote-data';
import { PaginatedList } from '../../../../core/data/paginated-list'; import { PaginatedList } from '../../../../core/data/paginated-list';
import { PageInfo } from '../../../../core/shared/page-info.model'; import { PageInfo } from '../../../../core/shared/page-info.model';
import { createRelationshipsObservable, getEntityPageFieldsTest } from '../shared/entity.component.spec'; import { createRelationshipsObservable, getItemPageFieldsTest } from '../shared/item.component.spec';
import { OrgunitComponent } from './orgunit.component'; import { OrgunitComponent } from './orgunit.component';
import { of as observableOf } from 'rxjs'; import { of as observableOf } from 'rxjs';
@@ -38,4 +37,4 @@ const mockItem: Item = Object.assign(new Item(), {
relationships: createRelationshipsObservable() relationships: createRelationshipsObservable()
}); });
describe('OrgUnitComponent', getEntityPageFieldsTest(mockItem, OrgunitComponent)); describe('OrgUnitComponent', getItemPageFieldsTest(mockItem, OrgunitComponent));

View File

@@ -2,22 +2,22 @@ import { Component, Inject, OnInit } from '@angular/core';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { ItemDataService } from '../../../../core/data/item-data.service'; import { ItemDataService } from '../../../../core/data/item-data.service';
import { Item } from '../../../../core/shared/item.model'; import { Item } from '../../../../core/shared/item.model';
import { rendersEntityType } from '../../../../shared/entities/entity-type-decorator'; import { rendersItemType } from '../../../../shared/items/item-type-decorator';
import { ElementViewMode } from '../../../../shared/view-mode'; import { ElementViewMode } from '../../../../shared/view-mode';
import { ITEM } from '../../../../shared/entities/switcher/entity-type-switcher.component'; import { ITEM } from '../../../../shared/items/switcher/item-type-switcher.component';
import { isNotEmpty } from '../../../../shared/empty.util'; import { isNotEmpty } from '../../../../shared/empty.util';
import { EntityComponent, filterRelationsByTypeLabel, relationsToItems } from '../shared/entity.component'; import { ItemComponent, filterRelationsByTypeLabel, relationsToItems } from '../shared/item.component';
@rendersEntityType('OrgUnit', ElementViewMode.Full) @rendersItemType('OrgUnit', ElementViewMode.Full)
@Component({ @Component({
selector: 'ds-orgunit', selector: 'ds-orgunit',
styleUrls: ['./orgunit.component.scss'], styleUrls: ['./orgunit.component.scss'],
templateUrl: './orgunit.component.html' templateUrl: './orgunit.component.html'
}) })
/** /**
* The component for displaying metadata and relations of an item with entity type Organisation Unit * The component for displaying metadata and relations of an item of the type Organisation Unit
*/ */
export class OrgunitComponent extends EntityComponent implements OnInit { export class OrgunitComponent extends ItemComponent implements OnInit {
/** /**
* The people related to this organisation unit * The people related to this organisation unit
*/ */

View File

@@ -24,14 +24,14 @@
</ds-generic-item-page-field> </ds-generic-item-page-field>
</div> </div>
<div class="col-xs-12 col-md-6"> <div class="col-xs-12 col-md-6">
<ds-related-entities <ds-related-items
[entities]="projects$ | async" [items]="projects$ | async"
[label]="'relationships.isProjectOf' | translate"> [label]="'relationships.isProjectOf' | translate">
</ds-related-entities> </ds-related-items>
<ds-related-entities <ds-related-items
[entities]="orgUnits$ | async" [items]="orgUnits$ | async"
[label]="'relationships.isOrgUnitOf' | translate"> [label]="'relationships.isOrgUnitOf' | translate">
</ds-related-entities> </ds-related-items>
<ds-generic-item-page-field [item]="item" <ds-generic-item-page-field [item]="item"
[fields]="['person.identifier.jobtitle']" [fields]="['person.identifier.jobtitle']"
[label]="'person.page.jobtitle'"> [label]="'person.page.jobtitle'">

View File

@@ -1,9 +1,8 @@
import { Observable } from 'rxjs';
import { Item } from '../../../../core/shared/item.model'; import { Item } from '../../../../core/shared/item.model';
import { RemoteData } from '../../../../core/data/remote-data'; import { RemoteData } from '../../../../core/data/remote-data';
import { PaginatedList } from '../../../../core/data/paginated-list'; import { PaginatedList } from '../../../../core/data/paginated-list';
import { PageInfo } from '../../../../core/shared/page-info.model'; import { PageInfo } from '../../../../core/shared/page-info.model';
import { createRelationshipsObservable, getEntityPageFieldsTest } from '../shared/entity.component.spec'; import { createRelationshipsObservable, getItemPageFieldsTest } from '../shared/item.component.spec';
import { PersonComponent } from './person.component'; import { PersonComponent } from './person.component';
import { of as observableOf } from 'rxjs'; import { of as observableOf } from 'rxjs';
@@ -48,4 +47,4 @@ const mockItem: Item = Object.assign(new Item(), {
relationships: createRelationshipsObservable() relationships: createRelationshipsObservable()
}); });
describe('PersonComponent', getEntityPageFieldsTest(mockItem, PersonComponent)); describe('PersonComponent', getItemPageFieldsTest(mockItem, PersonComponent));

View File

@@ -2,23 +2,23 @@ import { Component, Inject } from '@angular/core';
import { Observable , of as observableOf } from 'rxjs'; import { Observable , of as observableOf } from 'rxjs';
import { ItemDataService } from '../../../../core/data/item-data.service'; import { ItemDataService } from '../../../../core/data/item-data.service';
import { Item } from '../../../../core/shared/item.model'; import { Item } from '../../../../core/shared/item.model';
import { rendersEntityType } from '../../../../shared/entities/entity-type-decorator'; import { rendersItemType } from '../../../../shared/items/item-type-decorator';
import { ITEM } from '../../../../shared/entities/switcher/entity-type-switcher.component'; import { ITEM } from '../../../../shared/items/switcher/item-type-switcher.component';
import { ElementViewMode } from '../../../../shared/view-mode'; import { ElementViewMode } from '../../../../shared/view-mode';
import { SearchFixedFilterService } from '../../../../+search-page/search-filters/search-filter/search-fixed-filter.service'; import { SearchFixedFilterService } from '../../../../+search-page/search-filters/search-filter/search-fixed-filter.service';
import { isNotEmpty } from '../../../../shared/empty.util'; import { isNotEmpty } from '../../../../shared/empty.util';
import { EntityComponent, filterRelationsByTypeLabel, relationsToItems } from '../shared/entity.component'; import { ItemComponent, filterRelationsByTypeLabel, relationsToItems } from '../shared/item.component';
@rendersEntityType('Person', ElementViewMode.Full) @rendersItemType('Person', ElementViewMode.Full)
@Component({ @Component({
selector: 'ds-person', selector: 'ds-person',
styleUrls: ['./person.component.scss'], styleUrls: ['./person.component.scss'],
templateUrl: './person.component.html' templateUrl: './person.component.html'
}) })
/** /**
* The component for displaying metadata and relations of an item with entity type Person * The component for displaying metadata and relations of an item of the type Person
*/ */
export class PersonComponent extends EntityComponent { export class PersonComponent extends ItemComponent {
/** /**
* The publications related to this person * The publications related to this person
*/ */

View File

@@ -20,18 +20,18 @@
</ds-generic-item-page-field> </ds-generic-item-page-field>
</div> </div>
<div class="col-xs-12 col-md-6"> <div class="col-xs-12 col-md-6">
<ds-related-entities <ds-related-items
[entities]="people$ | async" [items]="people$ | async"
[label]="'relationships.isPersonOf' | translate"> [label]="'relationships.isPersonOf' | translate">
</ds-related-entities> </ds-related-items>
<ds-related-entities <ds-related-items
[entities]="publications$ | async" [items]="publications$ | async"
[label]="'relationships.isPublicationOf' | translate"> [label]="'relationships.isPublicationOf' | translate">
</ds-related-entities> </ds-related-items>
<ds-related-entities <ds-related-items
[entities]="orgUnits$ | async" [items]="orgUnits$ | async"
[label]="'relationships.isOrgUnitOf' | translate"> [label]="'relationships.isOrgUnitOf' | translate">
</ds-related-entities> </ds-related-items>
<ds-generic-item-page-field [item]="item" <ds-generic-item-page-field [item]="item"
[fields]="['project.identifier.description']" [fields]="['project.identifier.description']"
[label]="'project.page.description'"> [label]="'project.page.description'">

View File

@@ -1,9 +1,8 @@
import { Observable } from 'rxjs';
import { Item } from '../../../../core/shared/item.model'; import { Item } from '../../../../core/shared/item.model';
import { RemoteData } from '../../../../core/data/remote-data'; import { RemoteData } from '../../../../core/data/remote-data';
import { PaginatedList } from '../../../../core/data/paginated-list'; import { PaginatedList } from '../../../../core/data/paginated-list';
import { PageInfo } from '../../../../core/shared/page-info.model'; import { PageInfo } from '../../../../core/shared/page-info.model';
import { createRelationshipsObservable, getEntityPageFieldsTest } from '../shared/entity.component.spec'; import { createRelationshipsObservable, getItemPageFieldsTest } from '../shared/item.component.spec';
import { ProjectComponent } from './project.component'; import { ProjectComponent } from './project.component';
import { of as observableOf } from 'rxjs'; import { of as observableOf } from 'rxjs';
@@ -38,4 +37,4 @@ const mockItem: Item = Object.assign(new Item(), {
relationships: createRelationshipsObservable() relationships: createRelationshipsObservable()
}); });
describe('ProjectComponent', getEntityPageFieldsTest(mockItem, ProjectComponent)); describe('ProjectComponent', getItemPageFieldsTest(mockItem, ProjectComponent));

View File

@@ -2,22 +2,22 @@ import { Component, Inject, OnInit } from '@angular/core';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { ItemDataService } from '../../../../core/data/item-data.service'; import { ItemDataService } from '../../../../core/data/item-data.service';
import { Item } from '../../../../core/shared/item.model'; import { Item } from '../../../../core/shared/item.model';
import { rendersEntityType } from '../../../../shared/entities/entity-type-decorator'; import { rendersItemType } from '../../../../shared/items/item-type-decorator';
import { ElementViewMode } from '../../../../shared/view-mode'; import { ElementViewMode } from '../../../../shared/view-mode';
import { ITEM } from '../../../../shared/entities/switcher/entity-type-switcher.component'; import { ITEM } from '../../../../shared/items/switcher/item-type-switcher.component';
import { isNotEmpty } from '../../../../shared/empty.util'; import { isNotEmpty } from '../../../../shared/empty.util';
import { EntityComponent, filterRelationsByTypeLabel, relationsToItems } from '../shared/entity.component'; import { ItemComponent, filterRelationsByTypeLabel, relationsToItems } from '../shared/item.component';
@rendersEntityType('Project', ElementViewMode.Full) @rendersItemType('Project', ElementViewMode.Full)
@Component({ @Component({
selector: 'ds-project', selector: 'ds-project',
styleUrls: ['./project.component.scss'], styleUrls: ['./project.component.scss'],
templateUrl: './project.component.html' templateUrl: './project.component.html'
}) })
/** /**
* The component for displaying metadata and relations of an item with entity type Project * The component for displaying metadata and relations of an item of the type Project
*/ */
export class ProjectComponent extends EntityComponent implements OnInit { export class ProjectComponent extends ItemComponent implements OnInit {
/** /**
* The people related to this project * The people related to this project
*/ */

View File

@@ -9,22 +9,22 @@
<ds-item-page-author-field *ngIf="!(authors$ | async)" [item]="item"></ds-item-page-author-field> <ds-item-page-author-field *ngIf="!(authors$ | async)" [item]="item"></ds-item-page-author-field>
</div> </div>
<div class="col-xs-12 col-md-6"> <div class="col-xs-12 col-md-6">
<ds-related-entities <ds-related-items
[entities]="authors$ | async" [items]="authors$ | async"
[label]="'relationships.isAuthorOf' | translate"> [label]="'relationships.isAuthorOf' | translate">
</ds-related-entities> </ds-related-items>
<ds-related-entities <ds-related-items
[entities]="projects$ | async" [items]="projects$ | async"
[label]="'relationships.isProjectOf' | translate"> [label]="'relationships.isProjectOf' | translate">
</ds-related-entities> </ds-related-items>
<ds-related-entities <ds-related-items
[entities]="orgUnits$ | async" [items]="orgUnits$ | async"
[label]="'relationships.isOrgUnitOf' | translate"> [label]="'relationships.isOrgUnitOf' | translate">
</ds-related-entities> </ds-related-items>
<ds-related-entities <ds-related-items
[entities]="journalIssues$ | async" [items]="journalIssues$ | async"
[label]="'relationships.isJournalIssueOf' | translate"> [label]="'relationships.isJournalIssueOf' | translate">
</ds-related-entities> </ds-related-items>
<ds-item-page-abstract-field [item]="item"></ds-item-page-abstract-field> <ds-item-page-abstract-field [item]="item"></ds-item-page-abstract-field>
<ds-item-page-uri-field [item]="item"></ds-item-page-uri-field> <ds-item-page-uri-field [item]="item"></ds-item-page-uri-field>
<ds-item-page-collections [item]="item"></ds-item-page-collections> <ds-item-page-collections [item]="item"></ds-item-page-collections>

View File

@@ -3,18 +3,17 @@ import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
import { MockTranslateLoader } from '../../../../shared/mocks/mock-translate-loader'; import { MockTranslateLoader } from '../../../../shared/mocks/mock-translate-loader';
import { GenericItemPageFieldComponent } from '../../field-components/specific-field/generic/generic-item-page-field.component'; import { GenericItemPageFieldComponent } from '../../field-components/specific-field/generic/generic-item-page-field.component';
import { TruncatePipe } from '../../../../shared/utils/truncate.pipe'; import { TruncatePipe } from '../../../../shared/utils/truncate.pipe';
import { ITEM } from '../../../../shared/entities/switcher/entity-type-switcher.component'; import { ITEM } from '../../../../shared/items/switcher/item-type-switcher.component';
import { ItemDataService } from '../../../../core/data/item-data.service'; import { ItemDataService } from '../../../../core/data/item-data.service';
import { SearchFixedFilterService } from '../../../../+search-page/search-filters/search-filter/search-fixed-filter.service'; import { SearchFixedFilterService } from '../../../../+search-page/search-filters/search-filter/search-fixed-filter.service';
import { TruncatableService } from '../../../../shared/truncatable/truncatable.service'; import { TruncatableService } from '../../../../shared/truncatable/truncatable.service';
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
import { Item } from '../../../../core/shared/item.model'; import { Item } from '../../../../core/shared/item.model';
import { Observable } from 'rxjs';
import { RemoteData } from '../../../../core/data/remote-data'; import { RemoteData } from '../../../../core/data/remote-data';
import { PaginatedList } from '../../../../core/data/paginated-list'; import { PaginatedList } from '../../../../core/data/paginated-list';
import { PageInfo } from '../../../../core/shared/page-info.model'; import { PageInfo } from '../../../../core/shared/page-info.model';
import { By } from '@angular/platform-browser'; import { By } from '@angular/platform-browser';
import { createRelationshipsObservable } from '../shared/entity.component.spec'; import { createRelationshipsObservable } from '../shared/item.component.spec';
import { PublicationComponent } from './publication.component'; import { PublicationComponent } from './publication.component';
import { of as observableOf } from 'rxjs'; import { of as observableOf } from 'rxjs';

View File

@@ -3,22 +3,22 @@ import { Observable } from 'rxjs';
import { ItemDataService } from '../../../../core/data/item-data.service'; import { ItemDataService } from '../../../../core/data/item-data.service';
import { Item } from '../../../../core/shared/item.model'; import { Item } from '../../../../core/shared/item.model';
import { import {
DEFAULT_ENTITY_TYPE, DEFAULT_ITEM_TYPE,
rendersEntityType rendersItemType
} from '../../../../shared/entities/entity-type-decorator'; } from '../../../../shared/items/item-type-decorator';
import { ITEM } from '../../../../shared/entities/switcher/entity-type-switcher.component'; import { ITEM } from '../../../../shared/items/switcher/item-type-switcher.component';
import { ElementViewMode } from '../../../../shared/view-mode'; import { ElementViewMode } from '../../../../shared/view-mode';
import { EntityComponent, filterRelationsByTypeLabel, relationsToItems } from '../shared/entity.component'; import { ItemComponent, filterRelationsByTypeLabel, relationsToItems } from '../shared/item.component';
@rendersEntityType('Publication', ElementViewMode.Full) @rendersItemType('Publication', ElementViewMode.Full)
@rendersEntityType(DEFAULT_ENTITY_TYPE, ElementViewMode.Full) @rendersItemType(DEFAULT_ITEM_TYPE, ElementViewMode.Full)
@Component({ @Component({
selector: 'ds-publication', selector: 'ds-publication',
styleUrls: ['./publication.component.scss'], styleUrls: ['./publication.component.scss'],
templateUrl: './publication.component.html', templateUrl: './publication.component.html',
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
}) })
export class PublicationComponent extends EntityComponent implements OnInit { export class PublicationComponent extends ItemComponent implements OnInit {
/** /**
* The authors related to this publication * The authors related to this publication
*/ */

View File

@@ -7,27 +7,26 @@ import { ItemDataService } from '../../../../core/data/item-data.service';
import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
import { MockTranslateLoader } from '../../../../shared/mocks/mock-translate-loader'; import { MockTranslateLoader } from '../../../../shared/mocks/mock-translate-loader';
import { ChangeDetectionStrategy, DebugElement, NO_ERRORS_SCHEMA } from '@angular/core'; import { ChangeDetectionStrategy, DebugElement, NO_ERRORS_SCHEMA } from '@angular/core';
import { ITEM } from '../../../../shared/entities/switcher/entity-type-switcher.component'; import { ITEM } from '../../../../shared/items/switcher/item-type-switcher.component';
import { TruncatePipe } from '../../../../shared/utils/truncate.pipe'; import { TruncatePipe } from '../../../../shared/utils/truncate.pipe';
import { isNotEmpty } from '../../../../shared/empty.util'; import { isNotEmpty } from '../../../../shared/empty.util';
import { SearchFixedFilterService } from '../../../../+search-page/search-filters/search-filter/search-fixed-filter.service'; import { SearchFixedFilterService } from '../../../../+search-page/search-filters/search-filter/search-fixed-filter.service';
import { RelationshipType } from '../../../../core/shared/entities/relationship-type.model'; import { RelationshipType } from '../../../../core/shared/item-relationships/relationship-type.model';
import { PaginatedList } from '../../../../core/data/paginated-list'; import { PaginatedList } from '../../../../core/data/paginated-list';
import { RemoteData } from '../../../../core/data/remote-data'; import { RemoteData } from '../../../../core/data/remote-data';
import { Relationship } from '../../../../core/shared/entities/relationship.model'; import { Relationship } from '../../../../core/shared/item-relationships/relationship.model';
import { Observable } from 'rxjs';
import { PageInfo } from '../../../../core/shared/page-info.model'; import { PageInfo } from '../../../../core/shared/page-info.model';
import { compareArraysUsing, compareArraysUsingIds } from './entity.component'; import { compareArraysUsing, compareArraysUsingIds } from './item.component';
import { of as observableOf } from 'rxjs'; import { of as observableOf } from 'rxjs';
/** /**
* Create a generic test for an entity-page-fields component using a mockItem and the type of component * Create a generic test for an item-page-fields component using a mockItem and the type of component
* @param {Item} mockItem The item to use for testing. The item needs to contain just the metadata necessary to * @param {Item} mockItem The item to use for testing. The item needs to contain just the metadata necessary to
* execute the tests for it's component. * execute the tests for it's component.
* @param component The type of component to create test cases for. * @param component The type of component to create test cases for.
* @returns {() => void} Returns a specDefinition for the test. * @returns {() => void} Returns a specDefinition for the test.
*/ */
export function getEntityPageFieldsTest(mockItem: Item, component) { export function getItemPageFieldsTest(mockItem: Item, component) {
return () => { return () => {
let comp: any; let comp: any;
let fixture: ComponentFixture<any>; let fixture: ComponentFixture<any>;
@@ -101,7 +100,7 @@ export function createRelationshipsObservable() {
}) })
]))); ])));
} }
describe('EntityComponent', () => { describe('ItemComponent', () => {
const arr1 = [ const arr1 = [
{ {
id: 1, id: 1,

View File

@@ -4,12 +4,12 @@ import { distinctUntilChanged, filter, flatMap, map } from 'rxjs/operators';
import { ItemDataService } from '../../../../core/data/item-data.service'; import { ItemDataService } from '../../../../core/data/item-data.service';
import { PaginatedList } from '../../../../core/data/paginated-list'; import { PaginatedList } from '../../../../core/data/paginated-list';
import { RemoteData } from '../../../../core/data/remote-data'; import { RemoteData } from '../../../../core/data/remote-data';
import { RelationshipType } from '../../../../core/shared/entities/relationship-type.model'; import { RelationshipType } from '../../../../core/shared/item-relationships/relationship-type.model';
import { Relationship } from '../../../../core/shared/entities/relationship.model'; import { Relationship } from '../../../../core/shared/item-relationships/relationship.model';
import { Item } from '../../../../core/shared/item.model'; import { Item } from '../../../../core/shared/item.model';
import { getRemoteDataPayload } from '../../../../core/shared/operators'; import { getRemoteDataPayload } from '../../../../core/shared/operators';
import { hasValue } from '../../../../shared/empty.util'; import { hasValue } from '../../../../shared/empty.util';
import { ITEM } from '../../../../shared/entities/switcher/entity-type-switcher.component'; import { ITEM } from '../../../../shared/items/switcher/item-type-switcher.component';
/** /**
* Operator for comparing arrays using a mapping function * Operator for comparing arrays using a mapping function
@@ -83,13 +83,13 @@ export const relationsToItems = (thisId: string, ids: ItemDataService) =>
); );
@Component({ @Component({
selector: 'ds-entity', selector: 'ds-item',
template: '' template: ''
}) })
/** /**
* A generic component for displaying metadata and relations of an item * A generic component for displaying metadata and relations of an item
*/ */
export class EntityComponent implements OnInit { export class ItemComponent implements OnInit {
/** /**
* Resolved relationships and types together in one observable * Resolved relationships and types together in one observable
*/ */

View File

@@ -1,5 +0,0 @@
<ds-metadata-field-wrapper *ngIf="entities && entities.length > 0" [label]="label">
<ds-entity-type-switcher *ngFor="let entity of entities"
[object]="entity" [viewMode]="ElementViewMode.SetElement">
</ds-entity-type-switcher>
</ds-metadata-field-wrapper>

View File

@@ -3,19 +3,19 @@ import { Item } from '../../../core/shared/item.model';
import * as viewMode from '../../../shared/view-mode'; import * as viewMode from '../../../shared/view-mode';
@Component({ @Component({
selector: 'ds-related-entities', selector: 'ds-related-items',
styleUrls: ['./related-entities.component.scss'], styleUrls: ['./related-items.component.scss'],
templateUrl: './related-entities.component.html' templateUrl: './related-items.component.html'
}) })
/** /**
* This component is used for displaying relations between entities * This component is used for displaying relations between items
* It expects a list of entities to display and a label to put on top * It expects a list of items to display and a label to put on top
*/ */
export class RelatedEntitiesComponent { export class RelatedItemsComponent {
/** /**
* A list of entities to display * A list of items to display
*/ */
@Input() entities: Item[]; @Input() items: Item[];
/** /**
* An i18n label to use as a title for the list (usually describes the relation) * An i18n label to use as a title for the list (usually describes the relation)

View File

@@ -0,0 +1,5 @@
<ds-metadata-field-wrapper *ngIf="items && items.length > 0" [label]="label">
<ds-item-type-switcher *ngFor="let item of items"
[object]="item" [viewMode]="ElementViewMode.SetElement">
</ds-item-type-switcher>
</ds-metadata-field-wrapper>

View File

@@ -1,12 +1,12 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
import { RelatedEntitiesComponent } from './related-entities-component'; import { RelatedItemsComponent } from './related-items-component';
import { Item } from '../../../core/shared/item.model'; import { Item } from '../../../core/shared/item.model';
import { RemoteData } from '../../../core/data/remote-data'; import { RemoteData } from '../../../core/data/remote-data';
import { PaginatedList } from '../../../core/data/paginated-list'; import { PaginatedList } from '../../../core/data/paginated-list';
import { PageInfo } from '../../../core/shared/page-info.model'; import { PageInfo } from '../../../core/shared/page-info.model';
import { By } from '@angular/platform-browser'; import { By } from '@angular/platform-browser';
import { createRelationshipsObservable } from '../entity-types/shared/entity.component.spec'; import { createRelationshipsObservable } from '../item-types/shared/item.component.spec';
import { of as observableOf } from 'rxjs'; import { of as observableOf } from 'rxjs';
const mockItem1: Item = Object.assign(new Item(), { const mockItem1: Item = Object.assign(new Item(), {
@@ -19,33 +19,33 @@ const mockItem2: Item = Object.assign(new Item(), {
metadata: [], metadata: [],
relationships: createRelationshipsObservable() relationships: createRelationshipsObservable()
}); });
const mockEntities = [mockItem1, mockItem2]; const mockItems = [mockItem1, mockItem2];
describe('RelatedEntitiesComponent', () => { describe('RelatedItemsComponent', () => {
let comp: RelatedEntitiesComponent; let comp: RelatedItemsComponent;
let fixture: ComponentFixture<RelatedEntitiesComponent>; let fixture: ComponentFixture<RelatedItemsComponent>;
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [], imports: [],
declarations: [RelatedEntitiesComponent], declarations: [RelatedItemsComponent],
providers: [], providers: [],
schemas: [NO_ERRORS_SCHEMA] schemas: [NO_ERRORS_SCHEMA]
}).overrideComponent(RelatedEntitiesComponent, { }).overrideComponent(RelatedItemsComponent, {
set: {changeDetection: ChangeDetectionStrategy.Default} set: {changeDetection: ChangeDetectionStrategy.Default}
}).compileComponents(); }).compileComponents();
})); }));
beforeEach(async(() => { beforeEach(async(() => {
fixture = TestBed.createComponent(RelatedEntitiesComponent); fixture = TestBed.createComponent(RelatedItemsComponent);
comp = fixture.componentInstance; comp = fixture.componentInstance;
comp.entities = mockEntities; comp.items = mockItems;
fixture.detectChanges(); fixture.detectChanges();
})); }));
it(`should load ${mockEntities.length} entity-type-switcher components`, () => { it(`should load ${mockItems.length} item-type-switcher components`, () => {
const fields = fixture.debugElement.queryAll(By.css('ds-entity-type-switcher')); const fields = fixture.debugElement.queryAll(By.css('ds-item-type-switcher'));
expect(fields.length).toBe(mockEntities.length); expect(fields.length).toBe(mockItems.length);
}); });
}); });

View File

@@ -1,32 +1,32 @@
import { autoserialize, autoserializeAs, inheritSerialization } from 'cerialize'; import { autoserialize, autoserializeAs, inheritSerialization } from 'cerialize';
import { EntityType } from '../../../shared/entities/entity-type.model'; import { ItemType } from '../../../shared/item-relationships/item-type.model';
import { ResourceType } from '../../../shared/resource-type'; import { ResourceType } from '../../../shared/resource-type';
import { mapsTo } from '../../builders/build-decorators'; import { mapsTo } from '../../builders/build-decorators';
import { NormalizedObject } from '../normalized-object.model'; import { NormalizedObject } from '../normalized-object.model';
import { IDToUUIDSerializer } from '../../id-to-uuid-serializer'; import { IDToUUIDSerializer } from '../../id-to-uuid-serializer';
/** /**
* Normalized model class for a DSpace EntityType * Normalized model class for a DSpace ItemType
*/ */
@mapsTo(EntityType) @mapsTo(ItemType)
@inheritSerialization(NormalizedObject) @inheritSerialization(NormalizedObject)
export class NormalizedEntityType extends NormalizedObject { export class NormalizedItemType extends NormalizedObject {
/** /**
* The label that describes the ResourceType of the Entity * The label that describes the ResourceType of the Item
*/ */
@autoserialize @autoserialize
label: string; label: string;
/** /**
* The identifier of this EntityType * The identifier of this ItemType
*/ */
@autoserialize @autoserialize
id: string; id: string;
/** /**
* The universally unique identifier of this EntityType * The universally unique identifier of this ItemType
*/ */
@autoserializeAs(new IDToUUIDSerializer(ResourceType.EntityType), 'id') @autoserializeAs(new IDToUUIDSerializer(ResourceType.ItemType), 'id')
uuid: string; uuid: string;
} }

View File

@@ -1,5 +1,5 @@
import { autoserialize, autoserializeAs, inheritSerialization } from 'cerialize'; import { autoserialize, autoserializeAs, inheritSerialization } from 'cerialize';
import { RelationshipType } from '../../../shared/entities/relationship-type.model'; import { RelationshipType } from '../../../shared/item-relationships/relationship-type.model';
import { ResourceType } from '../../../shared/resource-type'; import { ResourceType } from '../../../shared/resource-type';
import { mapsTo, relationship } from '../../builders/build-decorators'; import { mapsTo, relationship } from '../../builders/build-decorators';
import { NormalizedDSpaceObject } from '../normalized-dspace-object.model'; import { NormalizedDSpaceObject } from '../normalized-dspace-object.model';
@@ -56,17 +56,17 @@ export class NormalizedRelationshipType extends NormalizedObject {
rightMinCardinality: number; rightMinCardinality: number;
/** /**
* The type of Entity found to the left of this RelationshipType * The type of Item found to the left of this RelationshipType
*/ */
@autoserialize @autoserialize
@relationship(ResourceType.EntityType, false) @relationship(ResourceType.ItemType, false)
leftType: string; leftType: string;
/** /**
* The type of Entity found to the right of this RelationshipType * The type of Item found to the right of this RelationshipType
*/ */
@autoserialize @autoserialize
@relationship(ResourceType.EntityType, false) @relationship(ResourceType.ItemType, false)
rightType: string; rightType: string;
/** /**

View File

@@ -1,5 +1,5 @@
import { autoserialize, autoserializeAs, inheritSerialization } from 'cerialize'; import { autoserialize, autoserializeAs, inheritSerialization } from 'cerialize';
import { Relationship } from '../../../shared/entities/relationship.model'; import { Relationship } from '../../../shared/item-relationships/relationship.model';
import { ResourceType } from '../../../shared/resource-type'; import { ResourceType } from '../../../shared/resource-type';
import { mapsTo, relationship } from '../../builders/build-decorators'; import { mapsTo, relationship } from '../../builders/build-decorators';
import { NormalizedObject } from '../normalized-object.model'; import { NormalizedObject } from '../normalized-object.model';
@@ -19,25 +19,25 @@ export class NormalizedRelationship extends NormalizedObject {
id: string; id: string;
/** /**
* The identifier of the Entity to the left side of this Relationship * The identifier of the Item to the left side of this Relationship
*/ */
@autoserialize @autoserialize
leftId: string; leftId: string;
/** /**
* The identifier of the Entity to the right side of this Relationship * The identifier of the Item to the right side of this Relationship
*/ */
@autoserialize @autoserialize
rightId: string; rightId: string;
/** /**
* The place of the Entity to the left side of this Relationship * The place of the Item to the left side of this Relationship
*/ */
@autoserialize @autoserialize
leftPlace: number; leftPlace: number;
/** /**
* The place of the Entity to the right side of this Relationship * The place of the Item to the right side of this Relationship
*/ */
@autoserialize @autoserialize
rightPlace: number; rightPlace: number;

View File

@@ -1,6 +1,6 @@
import { NormalizedEntityType } from './entities/normalized-entity-type.model'; import { NormalizedItemType } from './items/normalized-item-type.model';
import { NormalizedRelationshipType } from './entities/normalized-relationship-type.model'; import { NormalizedRelationshipType } from './items/normalized-relationship-type.model';
import { NormalizedRelationship } from './entities/normalized-relationship.model'; import { NormalizedRelationship } from './items/normalized-relationship.model';
import { NormalizedBitstream } from './normalized-bitstream.model'; import { NormalizedBitstream } from './normalized-bitstream.model';
import { NormalizedBundle } from './normalized-bundle.model'; import { NormalizedBundle } from './normalized-bundle.model';
import { NormalizedItem } from './normalized-item.model'; import { NormalizedItem } from './normalized-item.model';
@@ -44,8 +44,8 @@ export class NormalizedObjectFactory {
case ResourceType.RelationshipType: { case ResourceType.RelationshipType: {
return NormalizedRelationshipType return NormalizedRelationshipType
} }
case ResourceType.EntityType: { case ResourceType.ItemType: {
return NormalizedEntityType return NormalizedItemType
} }
case ResourceType.EPerson: { case ResourceType.EPerson: {
return NormalizedEPerson return NormalizedEPerson

View File

@@ -2,11 +2,11 @@ import { CacheableObject } from '../../cache/object-cache.reducer';
import { ResourceType } from '../resource-type'; import { ResourceType } from '../resource-type';
/** /**
* Describes a type of Entity * Describes a type of Item
*/ */
export class EntityType implements CacheableObject { export class ItemType implements CacheableObject {
/** /**
* The identifier of this EntityType * The identifier of this ItemType
*/ */
id: string; id: string;
@@ -21,7 +21,7 @@ export class EntityType implements CacheableObject {
type: ResourceType; type: ResourceType;
/** /**
* The universally unique identifier of this EntityType * The universally unique identifier of this ItemType
*/ */
uuid: string; uuid: string;
} }

View File

@@ -2,10 +2,10 @@ import { Observable } from 'rxjs';
import { CacheableObject } from '../../cache/object-cache.reducer'; import { CacheableObject } from '../../cache/object-cache.reducer';
import { RemoteData } from '../../data/remote-data'; import { RemoteData } from '../../data/remote-data';
import { ResourceType } from '../resource-type'; import { ResourceType } from '../resource-type';
import { EntityType } from './entity-type.model'; import { ItemType } from './item-type.model';
/** /**
* Describes a type of Relationship between multiple possible Entities * Describes a type of Relationship between multiple possible Items
*/ */
export class RelationshipType implements CacheableObject { export class RelationshipType implements CacheableObject {
/** /**
@@ -64,12 +64,12 @@ export class RelationshipType implements CacheableObject {
rightMinCardinality: number; rightMinCardinality: number;
/** /**
* The type of Entity found to the left of this RelationshipType * The type of Item found to the left of this RelationshipType
*/ */
leftType: Observable<RemoteData<EntityType>>; leftType: Observable<RemoteData<ItemType>>;
/** /**
* The type of Entity found to the right of this RelationshipType * The type of Item found to the right of this RelationshipType
*/ */
rightType: Observable<RemoteData<EntityType>>; rightType: Observable<RemoteData<ItemType>>;
} }

View File

@@ -5,7 +5,7 @@ import { ResourceType } from '../resource-type';
import { RelationshipType } from './relationship-type.model'; import { RelationshipType } from './relationship-type.model';
/** /**
* Describes a Relationship between two Entities * Describes a Relationship between two Items
*/ */
export class Relationship implements CacheableObject { export class Relationship implements CacheableObject {
/** /**
@@ -29,22 +29,22 @@ export class Relationship implements CacheableObject {
id: string; id: string;
/** /**
* The identifier of the Entity to the left side of this Relationship * The identifier of the Item to the left side of this Relationship
*/ */
leftId: string; leftId: string;
/** /**
* The identifier of the Entity to the right side of this Relationship * The identifier of the Item to the right side of this Relationship
*/ */
rightId: string; rightId: string;
/** /**
* The place of the Entity to the left side of this Relationship * The place of the Item to the left side of this Relationship
*/ */
leftPlace: number; leftPlace: number;
/** /**
* The place of the Entity to the right side of this Relationship * The place of the Item to the right side of this Relationship
*/ */
rightPlace: number; rightPlace: number;

View File

@@ -7,7 +7,7 @@ import { RemoteData } from '../data/remote-data';
import { Bitstream } from './bitstream.model'; import { Bitstream } from './bitstream.model';
import { hasValue, isNotEmpty } from '../../shared/empty.util'; import { hasValue, isNotEmpty } from '../../shared/empty.util';
import { PaginatedList } from '../data/paginated-list'; import { PaginatedList } from '../data/paginated-list';
import { Relationship } from './entities/relationship.model'; import { Relationship } from './item-relationships/relationship.model';
export class Item extends DSpaceObject { export class Item extends DSpaceObject {

View File

@@ -11,5 +11,5 @@ export enum ResourceType {
ResourcePolicy = 'resourcePolicy', ResourcePolicy = 'resourcePolicy',
Relationship = 'relationship', Relationship = 'relationship',
RelationshipType = 'relationshiptype', RelationshipType = 'relationshiptype',
EntityType = 'entitytype', ItemType = 'entitytype',
} }

View File

@@ -1,16 +1,16 @@
import { hasNoValue, hasValue } from '../empty.util'; import { hasNoValue, hasValue } from '../empty.util';
import { ElementViewMode } from '../view-mode'; import { ElementViewMode } from '../view-mode';
export const DEFAULT_ENTITY_TYPE = 'Default'; export const DEFAULT_ITEM_TYPE = 'Default';
const map = new Map(); const map = new Map();
/** /**
* Decorator used for rendering simple item pages for an Entity by type and viewMode * Decorator used for rendering simple item pages by type and viewMode
* @param type * @param type
* @param viewMode * @param viewMode
*/ */
export function rendersEntityType(type: string, viewMode: ElementViewMode) { export function rendersItemType(type: string, viewMode: ElementViewMode) {
return function decorator(component: any) { return function decorator(component: any) {
if (hasNoValue(map.get(viewMode))) { if (hasNoValue(map.get(viewMode))) {
map.set(viewMode, new Map()); map.set(viewMode, new Map());
@@ -23,14 +23,14 @@ export function rendersEntityType(type: string, viewMode: ElementViewMode) {
} }
/** /**
* Get the component used for rendering an entity by type and viewMode * Get the component used for rendering an item by type and viewMode
* @param type * @param type
* @param viewMode * @param viewMode
*/ */
export function getComponentByEntityType(type: string, viewMode: ElementViewMode) { export function getComponentByItemType(type: string, viewMode: ElementViewMode) {
let component = map.get(viewMode).get(type); let component = map.get(viewMode).get(type);
if (hasNoValue(component)) { if (hasNoValue(component)) {
component = map.get(viewMode).get(DEFAULT_ENTITY_TYPE); component = map.get(viewMode).get(DEFAULT_ITEM_TYPE);
} }
return component; return component;
} }

View File

@@ -1,4 +1,4 @@
import { EntityTypeSwitcherComponent } from './entity-type-switcher.component'; import { ItemTypeSwitcherComponent } from './item-type-switcher.component';
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { NO_ERRORS_SCHEMA } from '@angular/core'; import { NO_ERRORS_SCHEMA } from '@angular/core';
import { of as observableOf } from 'rxjs'; import { of as observableOf } from 'rxjs';
@@ -6,8 +6,8 @@ import { PageInfo } from '../../../core/shared/page-info.model';
import { Item } from '../../../core/shared/item.model'; import { Item } from '../../../core/shared/item.model';
import { PaginatedList } from '../../../core/data/paginated-list'; import { PaginatedList } from '../../../core/data/paginated-list';
import { RemoteData } from '../../../core/data/remote-data'; import { RemoteData } from '../../../core/data/remote-data';
import * as decorator from '../entity-type-decorator'; import * as decorator from '../item-type-decorator';
import { getComponentByEntityType } from '../entity-type-decorator'; import { getComponentByItemType } from '../item-type-decorator';
import { ElementViewMode } from '../../view-mode'; import { ElementViewMode } from '../../view-mode';
import createSpy = jasmine.createSpy; import createSpy = jasmine.createSpy;
@@ -28,23 +28,23 @@ const mockItem: Item = Object.assign(new Item(), {
}); });
const viewMode = ElementViewMode.Full; const viewMode = ElementViewMode.Full;
describe('EntityTypeSwitcherComponent', () => { describe('ItemTypeSwitcherComponent', () => {
let comp: EntityTypeSwitcherComponent; let comp: ItemTypeSwitcherComponent;
let fixture: ComponentFixture<EntityTypeSwitcherComponent>; let fixture: ComponentFixture<ItemTypeSwitcherComponent>;
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [ EntityTypeSwitcherComponent ], declarations: [ ItemTypeSwitcherComponent ],
schemas: [ NO_ERRORS_SCHEMA ] schemas: [ NO_ERRORS_SCHEMA ]
}).compileComponents(); // compile template and css }).compileComponents(); // compile template and css
})); }));
beforeEach(async(() => { beforeEach(async(() => {
fixture = TestBed.createComponent(EntityTypeSwitcherComponent); fixture = TestBed.createComponent(ItemTypeSwitcherComponent);
comp = fixture.componentInstance; comp = fixture.componentInstance;
comp.object = mockItem; comp.object = mockItem;
comp.viewMode = viewMode; comp.viewMode = viewMode;
spyOnProperty(decorator, 'getComponentByEntityType').and.returnValue(createSpy('getComponentByEntityType')) spyOnProperty(decorator, 'getComponentByItemType').and.returnValue(createSpy('getComponentByItemType'))
})); }));
describe('when calling getComponent', () => { describe('when calling getComponent', () => {
@@ -52,8 +52,8 @@ describe('EntityTypeSwitcherComponent', () => {
comp.getComponent(); comp.getComponent();
}); });
it('should call getComponentByEntityType with parameters type and viewMode', () => { it('should call getComponentByItemType with parameters type and viewMode', () => {
expect(decorator.getComponentByEntityType).toHaveBeenCalledWith(relationType, viewMode); expect(decorator.getComponentByItemType).toHaveBeenCalledWith(relationType, viewMode);
}); });
}); });

View File

@@ -3,20 +3,20 @@ import { SearchResult } from '../../../+search-page/search-result.model';
import { Item } from '../../../core/shared/item.model'; import { Item } from '../../../core/shared/item.model';
import { hasValue } from '../../empty.util'; import { hasValue } from '../../empty.util';
import { ItemSearchResult } from '../../object-collection/shared/item-search-result.model'; import { ItemSearchResult } from '../../object-collection/shared/item-search-result.model';
import { getComponentByEntityType } from '../entity-type-decorator'; import { getComponentByItemType } from '../item-type-decorator';
import { ElementViewMode } from '../../view-mode'; import { ElementViewMode } from '../../view-mode';
export const ITEM: InjectionToken<string> = new InjectionToken<string>('item'); export const ITEM: InjectionToken<string> = new InjectionToken<string>('item');
@Component({ @Component({
selector: 'ds-entity-type-switcher', selector: 'ds-item-type-switcher',
styleUrls: ['./entity-type-switcher.component.scss'], styleUrls: ['./item-type-switcher.component.scss'],
templateUrl: './entity-type-switcher.component.html' templateUrl: './item-type-switcher.component.html'
}) })
/** /**
* Component for determining what component to use depending on the item's relationship type (relationship.type) * Component for determining what component to use depending on the item's relationship type (relationship.type)
*/ */
export class EntityTypeSwitcherComponent implements OnInit { export class ItemTypeSwitcherComponent implements OnInit {
/** /**
* The item to determine the component for * The item to determine the component for
*/ */
@@ -57,6 +57,6 @@ export class EntityTypeSwitcherComponent implements OnInit {
} }
const type = item.findMetadata('relationship.type'); const type = item.findMetadata('relationship.type');
return getComponentByEntityType(type, this.viewMode); return getComponentByItemType(type, this.viewMode);
} }
} }

View File

@@ -1 +0,0 @@
<ds-entity-type-switcher [object]="object" [viewMode]="ElementViewMode.SetElement"></ds-entity-type-switcher>

View File

@@ -1,16 +0,0 @@
import { Component } from '@angular/core';
import { rendersEntityType } from '../../../../entities/entity-type-decorator';
import { ElementViewMode } from '../../../../view-mode';
import { EntitySearchResultComponent } from '../entity-search-result-component';
@rendersEntityType('JournalIssue', ElementViewMode.SetElement)
@Component({
selector: 'ds-journal-issue-list-element',
styleUrls: ['./journal-issue-list-element.component.scss'],
templateUrl: './journal-issue-list-element.component.html'
})
/**
* The component for displaying a list element for an item with entity type Journal Issue
*/
export class JournalIssueListElementComponent extends EntitySearchResultComponent {
}

View File

@@ -1,16 +0,0 @@
import { Component } from '@angular/core';
import { rendersEntityType } from '../../../../entities/entity-type-decorator';
import { ElementViewMode } from '../../../../view-mode';
import { EntitySearchResultComponent } from '../entity-search-result-component';
@rendersEntityType('JournalVolume', ElementViewMode.SetElement)
@Component({
selector: 'ds-journal-volume-list-element',
styleUrls: ['./journal-volume-list-element.component.scss'],
templateUrl: './journal-volume-list-element.component.html'
})
/**
* The component for displaying a list element for an item with entity type Journal Volume
*/
export class JournalVolumeListElementComponent extends EntitySearchResultComponent {
}

View File

@@ -1,16 +0,0 @@
import { Component } from '@angular/core';
import { rendersEntityType } from '../../../../entities/entity-type-decorator';
import { ElementViewMode } from '../../../../view-mode';
import { EntitySearchResultComponent } from '../entity-search-result-component';
@rendersEntityType('Journal', ElementViewMode.SetElement)
@Component({
selector: 'ds-journal-list-element',
styleUrls: ['./journal-list-element.component.scss'],
templateUrl: './journal-list-element.component.html'
})
/**
* The component for displaying a list element for an item with entity type Journal
*/
export class JournalListElementComponent extends EntitySearchResultComponent {
}

View File

@@ -1,16 +0,0 @@
import { Component } from '@angular/core';
import { rendersEntityType } from '../../../../entities/entity-type-decorator';
import { ElementViewMode } from '../../../../view-mode';
import { EntitySearchResultComponent } from '../entity-search-result-component';
@rendersEntityType('OrgUnit', ElementViewMode.SetElement)
@Component({
selector: 'ds-orgunit-list-element',
styleUrls: ['./orgunit-list-element.component.scss'],
templateUrl: './orgunit-list-element.component.html'
})
/**
* The component for displaying a list element for an item with entity type Organisation Unit
*/
export class OrgUnitListElementComponent extends EntitySearchResultComponent {
}

View File

@@ -1,16 +0,0 @@
import { Component } from '@angular/core';
import { rendersEntityType } from '../../../../entities/entity-type-decorator';
import { ElementViewMode } from '../../../../view-mode';
import { EntitySearchResultComponent } from '../entity-search-result-component';
@rendersEntityType('Person', ElementViewMode.SetElement)
@Component({
selector: 'ds-person-list-element',
styleUrls: ['./person-list-element.component.scss'],
templateUrl: './person-list-element.component.html'
})
/**
* The component for displaying a list element for an item with entity type Person
*/
export class PersonListElementComponent extends EntitySearchResultComponent {
}

View File

@@ -1,16 +0,0 @@
import { Component } from '@angular/core';
import { rendersEntityType } from '../../../../entities/entity-type-decorator';
import { ElementViewMode } from '../../../../view-mode';
import { EntitySearchResultComponent } from '../entity-search-result-component';
@rendersEntityType('Project', ElementViewMode.SetElement)
@Component({
selector: 'ds-project-list-element',
styleUrls: ['./project-list-element.component.scss'],
templateUrl: './project-list-element.component.html'
})
/**
* The component for displaying a list element for an item with entity type Project
*/
export class ProjectListElementComponent extends EntitySearchResultComponent {
}

View File

@@ -1,17 +0,0 @@
import { Component } from '@angular/core';
import { DEFAULT_ENTITY_TYPE, rendersEntityType } from '../../../../entities/entity-type-decorator';
import { ElementViewMode } from '../../../../view-mode';
import { EntitySearchResultComponent } from '../entity-search-result-component';
@rendersEntityType('Publication', ElementViewMode.SetElement)
@rendersEntityType(DEFAULT_ENTITY_TYPE, ElementViewMode.SetElement)
@Component({
selector: 'ds-publication-list-element',
styleUrls: ['./publication-list-element.component.scss'],
templateUrl: './publication-list-element.component.html'
})
/**
* The component for displaying a list element for an item with entity type Publication
*/
export class PublicationListElementComponent extends EntitySearchResultComponent {
}

View File

@@ -0,0 +1 @@
<ds-item-type-switcher [object]="object" [viewMode]="ElementViewMode.SetElement"></ds-item-type-switcher>

View File

@@ -1,13 +1,12 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
import { EntityListElementComponent } from './entity-list-element.component'; import { ItemListElementComponent } from './item-list-element.component';
import { Item } from '../../../core/shared/item.model'; import { Item } from '../../../core/shared/item.model';
import { Observable } from 'rxjs';
import { RemoteData } from '../../../core/data/remote-data'; import { RemoteData } from '../../../core/data/remote-data';
import { PaginatedList } from '../../../core/data/paginated-list'; import { PaginatedList } from '../../../core/data/paginated-list';
import { PageInfo } from '../../../core/shared/page-info.model'; import { PageInfo } from '../../../core/shared/page-info.model';
import { By } from '@angular/platform-browser'; import { By } from '@angular/platform-browser';
import { createRelationshipsObservable } from '../../../+item-page/simple/entity-types/shared/entity.component.spec'; import { createRelationshipsObservable } from '../../../+item-page/simple/item-types/shared/item.component.spec';
import { of as observableOf } from 'rxjs'; import { of as observableOf } from 'rxjs';
const mockItem: Item = Object.assign(new Item(), { const mockItem: Item = Object.assign(new Item(), {
@@ -16,32 +15,32 @@ const mockItem: Item = Object.assign(new Item(), {
relationships: createRelationshipsObservable() relationships: createRelationshipsObservable()
}); });
describe('EntityListElementComponent', () => { describe('ItemListElementComponent', () => {
let comp: EntityListElementComponent; let comp: ItemListElementComponent;
let fixture: ComponentFixture<EntityListElementComponent>; let fixture: ComponentFixture<ItemListElementComponent>;
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [], imports: [],
declarations: [EntityListElementComponent], declarations: [ItemListElementComponent],
providers: [ providers: [
{ provide: 'objectElementProvider', useValue: mockItem } { provide: 'objectElementProvider', useValue: mockItem }
], ],
schemas: [NO_ERRORS_SCHEMA] schemas: [NO_ERRORS_SCHEMA]
}).overrideComponent(EntityListElementComponent, { }).overrideComponent(ItemListElementComponent, {
set: {changeDetection: ChangeDetectionStrategy.Default} set: {changeDetection: ChangeDetectionStrategy.Default}
}).compileComponents(); }).compileComponents();
})); }));
beforeEach(async(() => { beforeEach(async(() => {
fixture = TestBed.createComponent(EntityListElementComponent); fixture = TestBed.createComponent(ItemListElementComponent);
comp = fixture.componentInstance; comp = fixture.componentInstance;
fixture.detectChanges(); fixture.detectChanges();
})); }));
it('should call an entity-type-switcher component and pass the item', () => { it('should call an item-type-switcher component and pass the item', () => {
const entityTypeSwitcher = fixture.debugElement.query(By.css('ds-entity-type-switcher')).componentInstance; const itemTypeSwitcher = fixture.debugElement.query(By.css('ds-item-type-switcher')).componentInstance;
expect(entityTypeSwitcher.object).toBe(mockItem); expect(itemTypeSwitcher.object).toBe(mockItem);
}); });
}); });

View File

@@ -7,16 +7,16 @@ import { AbstractListableElementComponent } from '../../object-collection/shared
import { SetViewMode } from '../../view-mode'; import { SetViewMode } from '../../view-mode';
@Component({ @Component({
selector: 'ds-entity-list-element', selector: 'ds-item-list-element',
styleUrls: ['./entity-list-element.component.scss'], styleUrls: ['./item-list-element.component.scss'],
templateUrl: './entity-list-element.component.html' templateUrl: './item-list-element.component.html'
}) })
/** /**
* The component used to list entities depending on type * The component used to list items depending on type
* Uses entity-type-switcher to determine which components to use for displaying the list * Uses item-type-switcher to determine which components to use for displaying the list
*/ */
@renderElementsFor(Item, SetViewMode.List) @renderElementsFor(Item, SetViewMode.List)
export class EntityListElementComponent extends AbstractListableElementComponent<Item> { export class ItemListElementComponent extends AbstractListableElementComponent<Item> {
ElementViewMode = viewMode.ElementViewMode; ElementViewMode = viewMode.ElementViewMode;
} }

View File

@@ -1,19 +1,19 @@
import { Component, Inject } from '@angular/core'; import { Component, Inject } from '@angular/core';
import { Item } from '../../../../core/shared/item.model'; import { Item } from '../../../../core/shared/item.model';
import { hasValue } from '../../../empty.util'; import { hasValue } from '../../../empty.util';
import { ITEM } from '../../../entities/switcher/entity-type-switcher.component'; import { ITEM } from '../../../items/switcher/item-type-switcher.component';
import { ItemSearchResult } from '../../../object-collection/shared/item-search-result.model'; import { ItemSearchResult } from '../../../object-collection/shared/item-search-result.model';
import { TruncatableService } from '../../../truncatable/truncatable.service'; import { TruncatableService } from '../../../truncatable/truncatable.service';
import { SearchResultListElementComponent } from '../../search-result-list-element/search-result-list-element.component'; import { SearchResultListElementComponent } from '../../search-result-list-element/search-result-list-element.component';
/** /**
* A generic component for displaying entity list elements * A generic component for displaying item list elements
*/ */
@Component({ @Component({
selector: 'ds-entity-search-result', selector: 'ds-item-search-result',
template: '' template: ''
}) })
export class EntitySearchResultComponent extends SearchResultListElementComponent<ItemSearchResult, Item> { export class ItemSearchResultComponent extends SearchResultListElementComponent<ItemSearchResult, Item> {
item: Item; item: Item;
constructor( constructor(

View File

@@ -2,15 +2,14 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { TruncatePipe } from '../../../utils/truncate.pipe'; import { TruncatePipe } from '../../../utils/truncate.pipe';
import { TruncatableService } from '../../../truncatable/truncatable.service'; import { TruncatableService } from '../../../truncatable/truncatable.service';
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
import { EntitySearchResultComponent } from './entity-search-result-component'; import { ItemSearchResultComponent } from './item-search-result-component';
import { Item } from '../../../../core/shared/item.model'; import { Item } from '../../../../core/shared/item.model';
import { Observable } from 'rxjs';
import { RemoteData } from '../../../../core/data/remote-data'; import { RemoteData } from '../../../../core/data/remote-data';
import { PaginatedList } from '../../../../core/data/paginated-list'; import { PaginatedList } from '../../../../core/data/paginated-list';
import { PageInfo } from '../../../../core/shared/page-info.model'; import { PageInfo } from '../../../../core/shared/page-info.model';
import { ITEM } from '../../../entities/switcher/entity-type-switcher.component'; import { ITEM } from '../../../items/switcher/item-type-switcher.component';
import { ItemSearchResult } from '../../../object-collection/shared/item-search-result.model'; import { ItemSearchResult } from '../../../object-collection/shared/item-search-result.model';
import { createRelationshipsObservable } from '../../../../+item-page/simple/entity-types/shared/entity.component.spec'; import { createRelationshipsObservable } from '../../../../+item-page/simple/item-types/shared/item.component.spec';
import { of as observableOf } from 'rxjs'; import { of as observableOf } from 'rxjs';
const mockItem: Item = Object.assign(new Item(), { const mockItem: Item = Object.assign(new Item(), {
@@ -23,27 +22,27 @@ const mockSearchResult = {
hitHighlights: [] hitHighlights: []
} as ItemSearchResult; } as ItemSearchResult;
describe('EntitySearchResultComponent', () => { describe('ItemSearchResultComponent', () => {
let comp: EntitySearchResultComponent; let comp: ItemSearchResultComponent;
let fixture: ComponentFixture<EntitySearchResultComponent>; let fixture: ComponentFixture<ItemSearchResultComponent>;
describe('when injecting an Item', () => { describe('when injecting an Item', () => {
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [EntitySearchResultComponent, TruncatePipe], declarations: [ItemSearchResultComponent, TruncatePipe],
providers: [ providers: [
{provide: TruncatableService, useValue: {}}, {provide: TruncatableService, useValue: {}},
{provide: ITEM, useValue: mockItem} {provide: ITEM, useValue: mockItem}
], ],
schemas: [NO_ERRORS_SCHEMA] schemas: [NO_ERRORS_SCHEMA]
}).overrideComponent(EntitySearchResultComponent, { }).overrideComponent(ItemSearchResultComponent, {
set: {changeDetection: ChangeDetectionStrategy.Default} set: {changeDetection: ChangeDetectionStrategy.Default}
}).compileComponents(); }).compileComponents();
})); }));
beforeEach(async(() => { beforeEach(async(() => {
fixture = TestBed.createComponent(EntitySearchResultComponent); fixture = TestBed.createComponent(ItemSearchResultComponent);
comp = fixture.componentInstance; comp = fixture.componentInstance;
})); }));
@@ -57,20 +56,20 @@ describe('EntitySearchResultComponent', () => {
describe('when injecting an ItemSearchResult', () => { describe('when injecting an ItemSearchResult', () => {
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [EntitySearchResultComponent, TruncatePipe], declarations: [ItemSearchResultComponent, TruncatePipe],
providers: [ providers: [
{provide: TruncatableService, useValue: {}}, {provide: TruncatableService, useValue: {}},
{provide: ITEM, useValue: mockSearchResult} {provide: ITEM, useValue: mockSearchResult}
], ],
schemas: [NO_ERRORS_SCHEMA] schemas: [NO_ERRORS_SCHEMA]
}).overrideComponent(EntitySearchResultComponent, { }).overrideComponent(ItemSearchResultComponent, {
set: {changeDetection: ChangeDetectionStrategy.Default} set: {changeDetection: ChangeDetectionStrategy.Default}
}).compileComponents(); }).compileComponents();
})); }));
beforeEach(async(() => { beforeEach(async(() => {
fixture = TestBed.createComponent(EntitySearchResultComponent); fixture = TestBed.createComponent(ItemSearchResultComponent);
comp = fixture.componentInstance; comp = fixture.componentInstance;
})); }));

View File

@@ -1,11 +1,10 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
import { By } from '@angular/platform-browser'; import { By } from '@angular/platform-browser';
import { Observable } from 'rxjs';
import { Item } from '../../../../../core/shared/item.model'; import { Item } from '../../../../../core/shared/item.model';
import { TruncatePipe } from '../../../../utils/truncate.pipe'; import { TruncatePipe } from '../../../../utils/truncate.pipe';
import { TruncatableService } from '../../../../truncatable/truncatable.service'; import { TruncatableService } from '../../../../truncatable/truncatable.service';
import { ITEM } from '../../../../entities/switcher/entity-type-switcher.component'; import { ITEM } from '../../../../items/switcher/item-type-switcher.component';
import { JournalIssueListElementComponent } from './journal-issue-list-element.component'; import { JournalIssueListElementComponent } from './journal-issue-list-element.component';
import { of as observableOf } from 'rxjs'; import { of as observableOf } from 'rxjs';

View File

@@ -0,0 +1,16 @@
import { Component } from '@angular/core';
import { rendersItemType } from '../../../../items/item-type-decorator';
import { ElementViewMode } from '../../../../view-mode';
import { ItemSearchResultComponent } from '../item-search-result-component';
@rendersItemType('JournalIssue', ElementViewMode.SetElement)
@Component({
selector: 'ds-journal-issue-list-element',
styleUrls: ['./journal-issue-list-element.component.scss'],
templateUrl: './journal-issue-list-element.component.html'
})
/**
* The component for displaying a list element for an item of the type Journal Issue
*/
export class JournalIssueListElementComponent extends ItemSearchResultComponent {
}

View File

@@ -1,11 +1,10 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
import { By } from '@angular/platform-browser'; import { By } from '@angular/platform-browser';
import { Observable } from 'rxjs';
import { Item } from '../../../../../core/shared/item.model'; import { Item } from '../../../../../core/shared/item.model';
import { TruncatePipe } from '../../../../utils/truncate.pipe'; import { TruncatePipe } from '../../../../utils/truncate.pipe';
import { TruncatableService } from '../../../../truncatable/truncatable.service'; import { TruncatableService } from '../../../../truncatable/truncatable.service';
import { ITEM } from '../../../../entities/switcher/entity-type-switcher.component'; import { ITEM } from '../../../../items/switcher/item-type-switcher.component';
import { JournalVolumeListElementComponent } from './journal-volume-list-element.component'; import { JournalVolumeListElementComponent } from './journal-volume-list-element.component';
import { of as observableOf } from 'rxjs'; import { of as observableOf } from 'rxjs';

View File

@@ -0,0 +1,16 @@
import { Component } from '@angular/core';
import { rendersItemType } from '../../../../items/item-type-decorator';
import { ElementViewMode } from '../../../../view-mode';
import { ItemSearchResultComponent } from '../item-search-result-component';
@rendersItemType('JournalVolume', ElementViewMode.SetElement)
@Component({
selector: 'ds-journal-volume-list-element',
styleUrls: ['./journal-volume-list-element.component.scss'],
templateUrl: './journal-volume-list-element.component.html'
})
/**
* The component for displaying a list element for an item of the type Journal Volume
*/
export class JournalVolumeListElementComponent extends ItemSearchResultComponent {
}

View File

@@ -1,11 +1,10 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
import { By } from '@angular/platform-browser'; import { By } from '@angular/platform-browser';
import { Observable } from 'rxjs';
import { Item } from '../../../../../core/shared/item.model'; import { Item } from '../../../../../core/shared/item.model';
import { TruncatePipe } from '../../../../utils/truncate.pipe'; import { TruncatePipe } from '../../../../utils/truncate.pipe';
import { TruncatableService } from '../../../../truncatable/truncatable.service'; import { TruncatableService } from '../../../../truncatable/truncatable.service';
import { ITEM } from '../../../../entities/switcher/entity-type-switcher.component'; import { ITEM } from '../../../../items/switcher/item-type-switcher.component';
import { JournalListElementComponent } from './journal-list-element.component'; import { JournalListElementComponent } from './journal-list-element.component';
import { of as observableOf } from 'rxjs'; import { of as observableOf } from 'rxjs';

View File

@@ -0,0 +1,16 @@
import { Component } from '@angular/core';
import { rendersItemType } from '../../../../items/item-type-decorator';
import { ElementViewMode } from '../../../../view-mode';
import { ItemSearchResultComponent } from '../item-search-result-component';
@rendersItemType('Journal', ElementViewMode.SetElement)
@Component({
selector: 'ds-journal-list-element',
styleUrls: ['./journal-list-element.component.scss'],
templateUrl: './journal-list-element.component.html'
})
/**
* The component for displaying a list element for an item of the type Journal
*/
export class JournalListElementComponent extends ItemSearchResultComponent {
}

View File

@@ -1,11 +1,10 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
import { By } from '@angular/platform-browser'; import { By } from '@angular/platform-browser';
import { Observable } from 'rxjs';
import { Item } from '../../../../../core/shared/item.model'; import { Item } from '../../../../../core/shared/item.model';
import { TruncatePipe } from '../../../../utils/truncate.pipe'; import { TruncatePipe } from '../../../../utils/truncate.pipe';
import { TruncatableService } from '../../../../truncatable/truncatable.service'; import { TruncatableService } from '../../../../truncatable/truncatable.service';
import { ITEM } from '../../../../entities/switcher/entity-type-switcher.component'; import { ITEM } from '../../../../items/switcher/item-type-switcher.component';
import { OrgUnitListElementComponent } from './orgunit-list-element.component'; import { OrgUnitListElementComponent } from './orgunit-list-element.component';
import { of as observableOf } from 'rxjs'; import { of as observableOf } from 'rxjs';

View File

@@ -0,0 +1,16 @@
import { Component } from '@angular/core';
import { rendersItemType } from '../../../../items/item-type-decorator';
import { ElementViewMode } from '../../../../view-mode';
import { ItemSearchResultComponent } from '../item-search-result-component';
@rendersItemType('OrgUnit', ElementViewMode.SetElement)
@Component({
selector: 'ds-orgunit-list-element',
styleUrls: ['./orgunit-list-element.component.scss'],
templateUrl: './orgunit-list-element.component.html'
})
/**
* The component for displaying a list element for an item of the type Organisation Unit
*/
export class OrgUnitListElementComponent extends ItemSearchResultComponent {
}

View File

@@ -1,11 +1,10 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
import { By } from '@angular/platform-browser'; import { By } from '@angular/platform-browser';
import { Observable } from 'rxjs';
import { Item } from '../../../../../core/shared/item.model'; import { Item } from '../../../../../core/shared/item.model';
import { TruncatePipe } from '../../../../utils/truncate.pipe'; import { TruncatePipe } from '../../../../utils/truncate.pipe';
import { TruncatableService } from '../../../../truncatable/truncatable.service'; import { TruncatableService } from '../../../../truncatable/truncatable.service';
import { ITEM } from '../../../../entities/switcher/entity-type-switcher.component'; import { ITEM } from '../../../../items/switcher/item-type-switcher.component';
import { PersonListElementComponent } from './person-list-element.component'; import { PersonListElementComponent } from './person-list-element.component';
import { of as observableOf } from 'rxjs'; import { of as observableOf } from 'rxjs';

View File

@@ -0,0 +1,16 @@
import { Component } from '@angular/core';
import { rendersItemType } from '../../../../items/item-type-decorator';
import { ElementViewMode } from '../../../../view-mode';
import { ItemSearchResultComponent } from '../item-search-result-component';
@rendersItemType('Person', ElementViewMode.SetElement)
@Component({
selector: 'ds-person-list-element',
styleUrls: ['./person-list-element.component.scss'],
templateUrl: './person-list-element.component.html'
})
/**
* The component for displaying a list element for an item of the type Person
*/
export class PersonListElementComponent extends ItemSearchResultComponent {
}

View File

@@ -1,11 +1,10 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
import { By } from '@angular/platform-browser'; import { By } from '@angular/platform-browser';
import { Observable } from 'rxjs';
import { Item } from '../../../../../core/shared/item.model'; import { Item } from '../../../../../core/shared/item.model';
import { TruncatePipe } from '../../../../utils/truncate.pipe'; import { TruncatePipe } from '../../../../utils/truncate.pipe';
import { TruncatableService } from '../../../../truncatable/truncatable.service'; import { TruncatableService } from '../../../../truncatable/truncatable.service';
import { ITEM } from '../../../../entities/switcher/entity-type-switcher.component'; import { ITEM } from '../../../../items/switcher/item-type-switcher.component';
import { ProjectListElementComponent } from './project-list-element.component'; import { ProjectListElementComponent } from './project-list-element.component';
import { of as observableOf } from 'rxjs'; import { of as observableOf } from 'rxjs';

View File

@@ -0,0 +1,16 @@
import { Component } from '@angular/core';
import { rendersItemType } from '../../../../items/item-type-decorator';
import { ElementViewMode } from '../../../../view-mode';
import { ItemSearchResultComponent } from '../item-search-result-component';
@rendersItemType('Project', ElementViewMode.SetElement)
@Component({
selector: 'ds-project-list-element',
styleUrls: ['./project-list-element.component.scss'],
templateUrl: './project-list-element.component.html'
})
/**
* The component for displaying a list element for an item of the type Project
*/
export class ProjectListElementComponent extends ItemSearchResultComponent {
}

View File

@@ -1,12 +1,11 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
import { By } from '@angular/platform-browser'; import { By } from '@angular/platform-browser';
import { Observable } from 'rxjs';
import { PublicationListElementComponent } from './publication-list-element.component'; import { PublicationListElementComponent } from './publication-list-element.component';
import { Item } from '../../../../../core/shared/item.model'; import { Item } from '../../../../../core/shared/item.model';
import { TruncatePipe } from '../../../../utils/truncate.pipe'; import { TruncatePipe } from '../../../../utils/truncate.pipe';
import { TruncatableService } from '../../../../truncatable/truncatable.service'; import { TruncatableService } from '../../../../truncatable/truncatable.service';
import { ITEM } from '../../../../entities/switcher/entity-type-switcher.component'; import { ITEM } from '../../../../items/switcher/item-type-switcher.component';
import { of as observableOf } from 'rxjs'; import { of as observableOf } from 'rxjs';
let publicationListElementComponent: PublicationListElementComponent; let publicationListElementComponent: PublicationListElementComponent;

View File

@@ -0,0 +1,17 @@
import { Component } from '@angular/core';
import { DEFAULT_ITEM_TYPE, rendersItemType } from '../../../../items/item-type-decorator';
import { ElementViewMode } from '../../../../view-mode';
import { ItemSearchResultComponent } from '../item-search-result-component';
@rendersItemType('Publication', ElementViewMode.SetElement)
@rendersItemType(DEFAULT_ITEM_TYPE, ElementViewMode.SetElement)
@Component({
selector: 'ds-publication-list-element',
styleUrls: ['./publication-list-element.component.scss'],
templateUrl: './publication-list-element.component.html'
})
/**
* The component for displaying a list element for an item of the type Publication
*/
export class PublicationListElementComponent extends ItemSearchResultComponent {
}

View File

@@ -1 +1 @@
<ds-entity-type-switcher [object]="object" [viewMode]="ElementViewMode.SetElement"></ds-entity-type-switcher> <ds-item-type-switcher [object]="object" [viewMode]="ElementViewMode.SetElement"></ds-item-type-switcher>

View File

@@ -9,7 +9,7 @@ import { ItemSearchResultListElementComponent } from './item-search-result-list-
import { By } from '@angular/platform-browser'; import { By } from '@angular/platform-browser';
import { TruncatableService } from '../../../truncatable/truncatable.service'; import { TruncatableService } from '../../../truncatable/truncatable.service';
import { TruncatePipe } from '../../../utils/truncate.pipe'; import { TruncatePipe } from '../../../utils/truncate.pipe';
import { createRelationshipsObservable } from '../../../../+item-page/simple/entity-types/shared/entity.component.spec'; import { createRelationshipsObservable } from '../../../../+item-page/simple/item-types/shared/item.component.spec';
import { ItemSearchResult } from '../../../object-collection/shared/item-search-result.model'; import { ItemSearchResult } from '../../../object-collection/shared/item-search-result.model';
const mockItem: Item = Object.assign(new Item(), { const mockItem: Item = Object.assign(new Item(), {
@@ -81,9 +81,9 @@ describe('ItemSearchResultListElementComponent', () => {
fixture.detectChanges(); fixture.detectChanges();
})); }));
it('should call an entity-type-switcher component and pass the item', () => { it('should call an item-type-switcher component and pass the item', () => {
const entityTypeSwitcher = fixture.debugElement.query(By.css('ds-entity-type-switcher')).componentInstance; const itemTypeSwitcher = fixture.debugElement.query(By.css('ds-item-type-switcher')).componentInstance;
expect(entityTypeSwitcher.object).toBe(mockItem); expect(itemTypeSwitcher.object).toBe(mockItem);
}); });
}); });

View File

@@ -13,15 +13,15 @@ import {
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
import { NgxPaginationModule } from 'ngx-pagination'; import { NgxPaginationModule } from 'ngx-pagination';
import { EntityTypeSwitcherComponent } from './entities/switcher/entity-type-switcher.component'; import { ItemTypeSwitcherComponent } from './items/switcher/item-type-switcher.component';
import { EntitySearchResultComponent } from './object-list/item-list-element/entity-types/entity-search-result-component'; import { ItemSearchResultComponent } from './object-list/item-list-element/item-types/item-search-result-component';
import { PublicationListElementComponent } from './object-list/item-list-element/entity-types/publication/publication-list-element.component'; import { PublicationListElementComponent } from './object-list/item-list-element/item-types/publication/publication-list-element.component';
import { OrgUnitListElementComponent } from './object-list/item-list-element/entity-types/orgunit/orgunit-list-element.component'; import { OrgUnitListElementComponent } from './object-list/item-list-element/item-types/orgunit/orgunit-list-element.component';
import { PersonListElementComponent } from './object-list/item-list-element/entity-types/person/person-list-element.component'; import { PersonListElementComponent } from './object-list/item-list-element/item-types/person/person-list-element.component';
import { ProjectListElementComponent } from './object-list/item-list-element/entity-types/project/project-list-element.component'; import { ProjectListElementComponent } from './object-list/item-list-element/item-types/project/project-list-element.component';
import { JournalListElementComponent } from './object-list/item-list-element/entity-types/journal/journal-list-element.component'; import { JournalListElementComponent } from './object-list/item-list-element/item-types/journal/journal-list-element.component';
import { JournalVolumeListElementComponent } from './object-list/item-list-element/entity-types/journal-volume/journal-volume-list-element.component'; import { JournalVolumeListElementComponent } from './object-list/item-list-element/item-types/journal-volume/journal-volume-list-element.component';
import { JournalIssueListElementComponent } from './object-list/item-list-element/entity-types/journal-issue/journal-issue-list-element.component'; import { JournalIssueListElementComponent } from './object-list/item-list-element/item-types/journal-issue/journal-issue-list-element.component';
import { FileUploadModule } from 'ng2-file-upload'; import { FileUploadModule } from 'ng2-file-upload';
@@ -34,7 +34,7 @@ import { ConsolePipe } from './utils/console.pipe';
import { CollectionListElementComponent } from './object-list/collection-list-element/collection-list-element.component'; import { CollectionListElementComponent } from './object-list/collection-list-element/collection-list-element.component';
import { CommunityListElementComponent } from './object-list/community-list-element/community-list-element.component'; import { CommunityListElementComponent } from './object-list/community-list-element/community-list-element.component';
import { EntityListElementComponent } from './object-list/item-list-element/entity-list-element.component'; import { ItemListElementComponent } from './object-list/item-list-element/item-list-element.component';
import { SearchResultListElementComponent } from './object-list/search-result-list-element/search-result-list-element.component'; import { SearchResultListElementComponent } from './object-list/search-result-list-element/search-result-list-element.component';
import { WrapperListElementComponent } from './object-list/wrapper-list-element/wrapper-list-element.component'; import { WrapperListElementComponent } from './object-list/wrapper-list-element/wrapper-list-element.component';
import { ObjectListComponent } from './object-list/object-list.component'; import { ObjectListComponent } from './object-list/object-list.component';
@@ -167,14 +167,14 @@ const COMPONENTS = [
TruncatableComponent, TruncatableComponent,
TruncatablePartComponent, TruncatablePartComponent,
InputSuggestionsComponent, InputSuggestionsComponent,
EntitySearchResultComponent, ItemSearchResultComponent,
EntityTypeSwitcherComponent, ItemTypeSwitcherComponent,
BrowseByComponent BrowseByComponent
]; ];
const ENTRY_COMPONENTS = [ const ENTRY_COMPONENTS = [
// put shared entry components (components that are created dynamically) here // put shared entry components (components that are created dynamically) here
EntityListElementComponent, ItemListElementComponent,
CollectionListElementComponent, CollectionListElementComponent,
CommunityListElementComponent, CommunityListElementComponent,
SearchResultListElementComponent, SearchResultListElementComponent,