From 8c1874c5842dfb1a36e7c464b826b659e2ac32ce Mon Sep 17 00:00:00 2001 From: Art Lowel Date: Wed, 16 Jan 2019 15:34:01 +0100 Subject: [PATCH 1/6] rename 'entity' to 'item' --- src/app/+item-page/item-page.module.ts | 22 ++++++++-------- .../simple/item-page.component.html | 2 +- .../simple/item-page.component.spec.ts | 3 +-- .../journal-issue.component.html | 12 ++++----- .../journal-issue.component.scss | 0 .../journal-issue.component.spec.ts | 5 ++-- .../journal-issue/journal-issue.component.ts | 12 ++++----- .../journal-volume.component.html | 12 ++++----- .../journal-volume.component.scss | 0 .../journal-volume.component.spec.ts | 5 ++-- .../journal-volume.component.ts | 12 ++++----- .../journal/journal.component.html | 6 ++--- .../journal/journal.component.scss | 0 .../journal/journal.component.spec.ts | 3 +-- .../journal/journal.component.ts | 12 ++++----- .../orgunit/orgunit.component.html | 18 ++++++------- .../orgunit/orgunit.component.scss | 0 .../orgunit/orgunit.component.spec.ts | 5 ++-- .../orgunit/orgunit.component.ts | 12 ++++----- .../person/person.component.html | 12 ++++----- .../person/person.component.scss | 0 .../person/person.component.spec.ts | 5 ++-- .../person/person.component.ts | 12 ++++----- .../project/project.component.html | 18 ++++++------- .../project/project.component.scss | 0 .../project/project.component.spec.ts | 5 ++-- .../project/project.component.ts | 12 ++++----- .../publication/publication.component.html | 24 ++++++++--------- .../publication/publication.component.scss | 0 .../publication/publication.component.spec.ts | 5 ++-- .../publication/publication.component.ts | 16 ++++++------ .../shared/item.component.spec.ts} | 15 +++++------ .../shared/item.component.ts} | 10 +++---- .../related-entities.component.html | 5 ---- .../related-items-component.ts} | 16 ++++++------ .../related-items.component.html | 5 ++++ .../related-items.component.scss} | 0 .../related-items.component.spec.ts} | 26 +++++++++---------- .../normalized-item-type.model.ts} | 16 ++++++------ .../normalized-relationship-type.model.ts | 10 +++---- .../normalized-relationship.model.ts | 10 +++---- .../cache/models/normalized-object-factory.ts | 10 +++---- .../item-type.model.ts} | 8 +++--- .../relationship-type.model.ts | 12 ++++----- .../relationship.model.ts | 10 +++---- src/app/core/shared/item.model.ts | 2 +- src/app/core/shared/resource-type.ts | 2 +- .../item-type-decorator.ts} | 12 ++++----- .../item-type-switcher.component.html} | 0 .../item-type-switcher.component.scss} | 0 .../item-type-switcher.component.spec.ts} | 22 ++++++++-------- .../switcher/item-type-switcher.component.ts} | 12 ++++----- .../entity-list-element.component.html | 1 - .../journal-issue-list-element.component.ts | 16 ------------ .../journal-volume-list-element.component.ts | 16 ------------ .../journal/journal-list-element.component.ts | 16 ------------ .../orgunit/orgunit-list-element.component.ts | 16 ------------ .../person/person-list-element.component.ts | 16 ------------ .../project/project-list-element.component.ts | 16 ------------ .../publication-list-element.component.ts | 17 ------------ .../item-list-element.component.html | 1 + ....scss => item-list-element.component.scss} | 0 ...ts => item-list-element.component.spec.ts} | 23 ++++++++-------- ...nent.ts => item-list-element.component.ts} | 12 ++++----- .../item-search-result-component.ts} | 8 +++--- .../item-search-result.component.spec.ts} | 25 +++++++++--------- .../journal-issue-list-element.component.html | 0 .../journal-issue-list-element.component.scss | 0 ...urnal-issue-list-element.component.spec.ts | 3 +-- .../journal-issue-list-element.component.ts | 16 ++++++++++++ ...journal-volume-list-element.component.html | 0 ...journal-volume-list-element.component.scss | 0 ...rnal-volume-list-element.component.spec.ts | 3 +-- .../journal-volume-list-element.component.ts | 16 ++++++++++++ .../journal-list-element.component.html | 0 .../journal-list-element.component.scss | 0 .../journal-list-element.component.spec.ts | 3 +-- .../journal/journal-list-element.component.ts | 16 ++++++++++++ .../orgunit-list-element.component.html | 0 .../orgunit-list-element.component.scss | 0 .../orgunit-list-element.component.spec.ts | 3 +-- .../orgunit/orgunit-list-element.component.ts | 16 ++++++++++++ .../person/person-list-element.component.html | 0 .../person/person-list-element.component.scss | 0 .../person-list-element.component.spec.ts | 3 +-- .../person/person-list-element.component.ts | 16 ++++++++++++ .../project-list-element.component.html | 0 .../project-list-element.component.scss | 0 .../project-list-element.component.spec.ts | 3 +-- .../project/project-list-element.component.ts | 16 ++++++++++++ .../publication-list-element.component.html | 0 .../publication-list-element.component.scss | 0 ...publication-list-element.component.spec.ts | 3 +-- .../publication-list-element.component.ts | 17 ++++++++++++ ...-search-result-list-element.component.html | 2 +- ...arch-result-list-element.component.spec.ts | 8 +++--- src/app/shared/shared.module.ts | 26 +++++++++---------- 97 files changed, 394 insertions(+), 412 deletions(-) rename src/app/+item-page/simple/{entity-types => item-types}/journal-issue/journal-issue.component.html (88%) rename src/app/+item-page/simple/{entity-types => item-types}/journal-issue/journal-issue.component.scss (100%) rename src/app/+item-page/simple/{entity-types => item-types}/journal-issue/journal-issue.component.spec.ts (81%) rename src/app/+item-page/simple/{entity-types => item-types}/journal-issue/journal-issue.component.ts (75%) rename src/app/+item-page/simple/{entity-types => item-types}/journal-volume/journal-volume.component.html (87%) rename src/app/+item-page/simple/{entity-types => item-types}/journal-volume/journal-volume.component.scss (100%) rename src/app/+item-page/simple/{entity-types => item-types}/journal-volume/journal-volume.component.spec.ts (79%) rename src/app/+item-page/simple/{entity-types => item-types}/journal-volume/journal-volume.component.ts (74%) rename src/app/+item-page/simple/{entity-types => item-types}/journal/journal.component.html (93%) rename src/app/+item-page/simple/{entity-types => item-types}/journal/journal.component.scss (100%) rename src/app/+item-page/simple/{entity-types => item-types}/journal/journal.component.spec.ts (96%) rename src/app/+item-page/simple/{entity-types => item-types}/journal/journal.component.ts (70%) rename src/app/+item-page/simple/{entity-types => item-types}/orgunit/orgunit.component.html (86%) rename src/app/+item-page/simple/{entity-types => item-types}/orgunit/orgunit.component.scss (100%) rename src/app/+item-page/simple/{entity-types => item-types}/orgunit/orgunit.component.spec.ts (82%) rename src/app/+item-page/simple/{entity-types => item-types}/orgunit/orgunit.component.ts (77%) rename src/app/+item-page/simple/{entity-types => item-types}/person/person.component.html (92%) rename src/app/+item-page/simple/{entity-types => item-types}/person/person.component.scss (100%) rename src/app/+item-page/simple/{entity-types => item-types}/person/person.component.spec.ts (85%) rename src/app/+item-page/simple/{entity-types => item-types}/person/person.component.ts (83%) rename src/app/+item-page/simple/{entity-types => item-types}/project/project.component.html (86%) rename src/app/+item-page/simple/{entity-types => item-types}/project/project.component.scss (100%) rename src/app/+item-page/simple/{entity-types => item-types}/project/project.component.spec.ts (83%) rename src/app/+item-page/simple/{entity-types => item-types}/project/project.component.ts (78%) rename src/app/+item-page/simple/{entity-types => item-types}/publication/publication.component.html (76%) rename src/app/+item-page/simple/{entity-types => item-types}/publication/publication.component.scss (100%) rename src/app/+item-page/simple/{entity-types => item-types}/publication/publication.component.spec.ts (94%) rename src/app/+item-page/simple/{entity-types => item-types}/publication/publication.component.ts (78%) rename src/app/+item-page/simple/{entity-types/shared/entity.component.spec.ts => item-types/shared/item.component.spec.ts} (94%) rename src/app/+item-page/simple/{entity-types/shared/entity.component.ts => item-types/shared/item.component.ts} (92%) delete mode 100644 src/app/+item-page/simple/related-entities/related-entities.component.html rename src/app/+item-page/simple/{related-entities/related-entities-component.ts => related-items/related-items-component.ts} (54%) create mode 100644 src/app/+item-page/simple/related-items/related-items.component.html rename src/app/+item-page/simple/{related-entities/related-entities.component.scss => related-items/related-items.component.scss} (100%) rename src/app/+item-page/simple/{related-entities/related-entities.component.spec.ts => related-items/related-items.component.spec.ts} (62%) rename src/app/core/cache/models/{entities/normalized-entity-type.model.ts => items/normalized-item-type.model.ts} (53%) rename src/app/core/cache/models/{entities => items}/normalized-relationship-type.model.ts (85%) rename src/app/core/cache/models/{entities => items}/normalized-relationship.model.ts (75%) rename src/app/core/shared/{entities/entity-type.model.ts => item-relationships/item-type.model.ts} (65%) rename src/app/core/shared/{entities => item-relationships}/relationship-type.model.ts (80%) rename src/app/core/shared/{entities => item-relationships}/relationship.model.ts (73%) rename src/app/shared/{entities/entity-type-decorator.ts => items/item-type-decorator.ts} (62%) rename src/app/shared/{entities/switcher/entity-type-switcher.component.html => items/switcher/item-type-switcher.component.html} (100%) rename src/app/shared/{entities/switcher/entity-type-switcher.component.scss => items/switcher/item-type-switcher.component.scss} (100%) rename src/app/shared/{entities/switcher/entity-type-switcher.component.spec.ts => items/switcher/item-type-switcher.component.spec.ts} (63%) rename src/app/shared/{entities/switcher/entity-type-switcher.component.ts => items/switcher/item-type-switcher.component.ts} (82%) delete mode 100644 src/app/shared/object-list/item-list-element/entity-list-element.component.html delete mode 100644 src/app/shared/object-list/item-list-element/entity-types/journal-issue/journal-issue-list-element.component.ts delete mode 100644 src/app/shared/object-list/item-list-element/entity-types/journal-volume/journal-volume-list-element.component.ts delete mode 100644 src/app/shared/object-list/item-list-element/entity-types/journal/journal-list-element.component.ts delete mode 100644 src/app/shared/object-list/item-list-element/entity-types/orgunit/orgunit-list-element.component.ts delete mode 100644 src/app/shared/object-list/item-list-element/entity-types/person/person-list-element.component.ts delete mode 100644 src/app/shared/object-list/item-list-element/entity-types/project/project-list-element.component.ts delete mode 100644 src/app/shared/object-list/item-list-element/entity-types/publication/publication-list-element.component.ts create mode 100644 src/app/shared/object-list/item-list-element/item-list-element.component.html rename src/app/shared/object-list/item-list-element/{entity-list-element.component.scss => item-list-element.component.scss} (100%) rename src/app/shared/object-list/item-list-element/{entity-list-element.component.spec.ts => item-list-element.component.spec.ts} (62%) rename src/app/shared/object-list/item-list-element/{entity-list-element.component.ts => item-list-element.component.ts} (59%) rename src/app/shared/object-list/item-list-element/{entity-types/entity-search-result-component.ts => item-types/item-search-result-component.ts} (77%) rename src/app/shared/object-list/item-list-element/{entity-types/entity-search-result.component.spec.ts => item-types/item-search-result.component.spec.ts} (75%) rename src/app/shared/object-list/item-list-element/{entity-types => item-types}/journal-issue/journal-issue-list-element.component.html (100%) rename src/app/shared/object-list/item-list-element/{entity-types => item-types}/journal-issue/journal-issue-list-element.component.scss (100%) rename src/app/shared/object-list/item-list-element/{entity-types => item-types}/journal-issue/journal-issue-list-element.component.spec.ts (96%) create mode 100644 src/app/shared/object-list/item-list-element/item-types/journal-issue/journal-issue-list-element.component.ts rename src/app/shared/object-list/item-list-element/{entity-types => item-types}/journal-volume/journal-volume-list-element.component.html (100%) rename src/app/shared/object-list/item-list-element/{entity-types => item-types}/journal-volume/journal-volume-list-element.component.scss (100%) rename src/app/shared/object-list/item-list-element/{entity-types => item-types}/journal-volume/journal-volume-list-element.component.spec.ts (96%) create mode 100644 src/app/shared/object-list/item-list-element/item-types/journal-volume/journal-volume-list-element.component.ts rename src/app/shared/object-list/item-list-element/{entity-types => item-types}/journal/journal-list-element.component.html (100%) rename src/app/shared/object-list/item-list-element/{entity-types => item-types}/journal/journal-list-element.component.scss (100%) rename src/app/shared/object-list/item-list-element/{entity-types => item-types}/journal/journal-list-element.component.spec.ts (95%) create mode 100644 src/app/shared/object-list/item-list-element/item-types/journal/journal-list-element.component.ts rename src/app/shared/object-list/item-list-element/{entity-types => item-types}/orgunit/orgunit-list-element.component.html (100%) rename src/app/shared/object-list/item-list-element/{entity-types => item-types}/orgunit/orgunit-list-element.component.scss (100%) rename src/app/shared/object-list/item-list-element/{entity-types => item-types}/orgunit/orgunit-list-element.component.spec.ts (95%) create mode 100644 src/app/shared/object-list/item-list-element/item-types/orgunit/orgunit-list-element.component.ts rename src/app/shared/object-list/item-list-element/{entity-types => item-types}/person/person-list-element.component.html (100%) rename src/app/shared/object-list/item-list-element/{entity-types => item-types}/person/person-list-element.component.scss (100%) rename src/app/shared/object-list/item-list-element/{entity-types => item-types}/person/person-list-element.component.spec.ts (95%) create mode 100644 src/app/shared/object-list/item-list-element/item-types/person/person-list-element.component.ts rename src/app/shared/object-list/item-list-element/{entity-types => item-types}/project/project-list-element.component.html (100%) rename src/app/shared/object-list/item-list-element/{entity-types => item-types}/project/project-list-element.component.scss (100%) rename src/app/shared/object-list/item-list-element/{entity-types => item-types}/project/project-list-element.component.spec.ts (95%) create mode 100644 src/app/shared/object-list/item-list-element/item-types/project/project-list-element.component.ts rename src/app/shared/object-list/item-list-element/{entity-types => item-types}/publication/publication-list-element.component.html (100%) rename src/app/shared/object-list/item-list-element/{entity-types => item-types}/publication/publication-list-element.component.scss (100%) rename src/app/shared/object-list/item-list-element/{entity-types => item-types}/publication/publication-list-element.component.spec.ts (97%) create mode 100644 src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.ts diff --git a/src/app/+item-page/item-page.module.ts b/src/app/+item-page/item-page.module.ts index 2103a548c1..b4e5ba1cd8 100644 --- a/src/app/+item-page/item-page.module.ts +++ b/src/app/+item-page/item-page.module.ts @@ -19,16 +19,16 @@ import { FileSectionComponent } from './simple/field-components/file-section/fil import { CollectionsComponent } from './field-components/collections/collections.component'; import { FullItemPageComponent } from './full/full-item-page.component'; import { FullFileSectionComponent } from './full/field-components/file-section/full-file-section.component'; -import { 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 { PublicationComponent } from './simple/entity-types/publication/publication.component'; -import { PersonComponent } from './simple/entity-types/person/person.component'; -import { OrgunitComponent } from './simple/entity-types/orgunit/orgunit.component'; -import { ProjectComponent } from './simple/entity-types/project/project.component'; -import { JournalComponent } from './simple/entity-types/journal/journal.component'; -import { JournalVolumeComponent } from './simple/entity-types/journal-volume/journal-volume.component'; -import { JournalIssueComponent } from './simple/entity-types/journal-issue/journal-issue.component'; -import { EntityComponent } from './simple/entity-types/shared/entity.component'; +import { PublicationComponent } from './simple/item-types/publication/publication.component'; +import { PersonComponent } from './simple/item-types/person/person.component'; +import { OrgunitComponent } from './simple/item-types/orgunit/orgunit.component'; +import { ProjectComponent } from './simple/item-types/project/project.component'; +import { JournalComponent } from './simple/item-types/journal/journal.component'; +import { JournalVolumeComponent } from './simple/item-types/journal-volume/journal-volume.component'; +import { JournalIssueComponent } from './simple/item-types/journal-issue/journal-issue.component'; +import { ItemComponent } from './simple/item-types/shared/item.component'; @NgModule({ imports: [ @@ -56,8 +56,8 @@ import { EntityComponent } from './simple/entity-types/shared/entity.component'; ProjectComponent, OrgunitComponent, PersonComponent, - RelatedEntitiesComponent, - EntityComponent, + RelatedItemsComponent, + ItemComponent, GenericItemPageFieldComponent, JournalComponent, JournalIssueComponent, diff --git a/src/app/+item-page/simple/item-page.component.html b/src/app/+item-page/simple/item-page.component.html index 0db8bbf318..e59d37fb9d 100644 --- a/src/app/+item-page/simple/item-page.component.html +++ b/src/app/+item-page/simple/item-page.component.html @@ -1,7 +1,7 @@
- +
diff --git a/src/app/+item-page/simple/item-page.component.spec.ts b/src/app/+item-page/simple/item-page.component.spec.ts index bc1df00300..fbe616227f 100644 --- a/src/app/+item-page/simple/item-page.component.spec.ts +++ b/src/app/+item-page/simple/item-page.component.spec.ts @@ -8,14 +8,13 @@ import { ActivatedRoute } from '@angular/router'; import { ActivatedRouteStub } from '../../shared/testing/active-router-stub'; import { MetadataService } from '../../core/metadata/metadata.service'; import { VarDirective } from '../../shared/utils/var.directive'; -import { Observable } from 'rxjs'; import { RemoteData } from '../../core/data/remote-data'; import { Item } from '../../core/shared/item.model'; import { PaginatedList } from '../../core/data/paginated-list'; import { PageInfo } from '../../core/shared/page-info.model'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; 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'; const mockItem: Item = Object.assign(new Item(), { diff --git a/src/app/+item-page/simple/entity-types/journal-issue/journal-issue.component.html b/src/app/+item-page/simple/item-types/journal-issue/journal-issue.component.html similarity index 88% rename from src/app/+item-page/simple/entity-types/journal-issue/journal-issue.component.html rename to src/app/+item-page/simple/item-types/journal-issue/journal-issue.component.html index 73fee41f8f..13e977ac5c 100644 --- a/src/app/+item-page/simple/entity-types/journal-issue/journal-issue.component.html +++ b/src/app/+item-page/simple/item-types/journal-issue/journal-issue.component.html @@ -16,14 +16,14 @@
- - - + - + diff --git a/src/app/+item-page/simple/entity-types/journal-issue/journal-issue.component.scss b/src/app/+item-page/simple/item-types/journal-issue/journal-issue.component.scss similarity index 100% rename from src/app/+item-page/simple/entity-types/journal-issue/journal-issue.component.scss rename to src/app/+item-page/simple/item-types/journal-issue/journal-issue.component.scss diff --git a/src/app/+item-page/simple/entity-types/journal-issue/journal-issue.component.spec.ts b/src/app/+item-page/simple/item-types/journal-issue/journal-issue.component.spec.ts similarity index 81% rename from src/app/+item-page/simple/entity-types/journal-issue/journal-issue.component.spec.ts rename to src/app/+item-page/simple/item-types/journal-issue/journal-issue.component.spec.ts index a2db07362d..a648250b03 100644 --- a/src/app/+item-page/simple/entity-types/journal-issue/journal-issue.component.spec.ts +++ b/src/app/+item-page/simple/item-types/journal-issue/journal-issue.component.spec.ts @@ -1,9 +1,8 @@ -import { Observable } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; import { RemoteData } from '../../../../core/data/remote-data'; import { PaginatedList } from '../../../../core/data/paginated-list'; 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 { of as observableOf } from 'rxjs'; @@ -33,4 +32,4 @@ const mockItem: Item = Object.assign(new Item(), { relationships: createRelationshipsObservable() }); -describe('JournalIssueComponent', getEntityPageFieldsTest(mockItem, JournalIssueComponent)); +describe('JournalIssueComponent', getItemPageFieldsTest(mockItem, JournalIssueComponent)); diff --git a/src/app/+item-page/simple/entity-types/journal-issue/journal-issue.component.ts b/src/app/+item-page/simple/item-types/journal-issue/journal-issue.component.ts similarity index 75% rename from src/app/+item-page/simple/entity-types/journal-issue/journal-issue.component.ts rename to src/app/+item-page/simple/item-types/journal-issue/journal-issue.component.ts index 91d4b1ce8c..c663b15256 100644 --- a/src/app/+item-page/simple/entity-types/journal-issue/journal-issue.component.ts +++ b/src/app/+item-page/simple/item-types/journal-issue/journal-issue.component.ts @@ -2,22 +2,22 @@ import { Component, Inject } from '@angular/core'; import { Observable } from 'rxjs'; import { ItemDataService } from '../../../../core/data/item-data.service'; import { Item } from '../../../../core/shared/item.model'; -import { rendersEntityType } from '../../../../shared/entities/entity-type-decorator'; -import { ITEM } from '../../../../shared/entities/switcher/entity-type-switcher.component'; +import { rendersItemType } from '../../../../shared/items/item-type-decorator'; +import { ITEM } from '../../../../shared/items/switcher/item-type-switcher.component'; import { ElementViewMode } from '../../../../shared/view-mode'; 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({ selector: 'ds-journal-issue', styleUrls: ['./journal-issue.component.scss'], 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 */ diff --git a/src/app/+item-page/simple/entity-types/journal-volume/journal-volume.component.html b/src/app/+item-page/simple/item-types/journal-volume/journal-volume.component.html similarity index 87% rename from src/app/+item-page/simple/entity-types/journal-volume/journal-volume.component.html rename to src/app/+item-page/simple/item-types/journal-volume/journal-volume.component.html index df770b06d8..a956e40fdd 100644 --- a/src/app/+item-page/simple/entity-types/journal-volume/journal-volume.component.html +++ b/src/app/+item-page/simple/item-types/journal-volume/journal-volume.component.html @@ -16,14 +16,14 @@
- - - + - + diff --git a/src/app/+item-page/simple/entity-types/journal-volume/journal-volume.component.scss b/src/app/+item-page/simple/item-types/journal-volume/journal-volume.component.scss similarity index 100% rename from src/app/+item-page/simple/entity-types/journal-volume/journal-volume.component.scss rename to src/app/+item-page/simple/item-types/journal-volume/journal-volume.component.scss diff --git a/src/app/+item-page/simple/entity-types/journal-volume/journal-volume.component.spec.ts b/src/app/+item-page/simple/item-types/journal-volume/journal-volume.component.spec.ts similarity index 79% rename from src/app/+item-page/simple/entity-types/journal-volume/journal-volume.component.spec.ts rename to src/app/+item-page/simple/item-types/journal-volume/journal-volume.component.spec.ts index 2cab243924..5442048a50 100644 --- a/src/app/+item-page/simple/entity-types/journal-volume/journal-volume.component.spec.ts +++ b/src/app/+item-page/simple/item-types/journal-volume/journal-volume.component.spec.ts @@ -1,9 +1,8 @@ -import { Observable } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; import { RemoteData } from '../../../../core/data/remote-data'; import { PaginatedList } from '../../../../core/data/paginated-list'; 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 { of as observableOf } from 'rxjs'; @@ -28,4 +27,4 @@ const mockItem: Item = Object.assign(new Item(), { relationships: createRelationshipsObservable() }); -describe('JournalVolumeComponent', getEntityPageFieldsTest(mockItem, JournalVolumeComponent)); +describe('JournalVolumeComponent', getItemPageFieldsTest(mockItem, JournalVolumeComponent)); diff --git a/src/app/+item-page/simple/entity-types/journal-volume/journal-volume.component.ts b/src/app/+item-page/simple/item-types/journal-volume/journal-volume.component.ts similarity index 74% rename from src/app/+item-page/simple/entity-types/journal-volume/journal-volume.component.ts rename to src/app/+item-page/simple/item-types/journal-volume/journal-volume.component.ts index c6b9233ece..ebb6919234 100644 --- a/src/app/+item-page/simple/entity-types/journal-volume/journal-volume.component.ts +++ b/src/app/+item-page/simple/item-types/journal-volume/journal-volume.component.ts @@ -2,22 +2,22 @@ import { Component, Inject } from '@angular/core'; import { Observable } from 'rxjs'; import { ItemDataService } from '../../../../core/data/item-data.service'; import { Item } from '../../../../core/shared/item.model'; -import { rendersEntityType } from '../../../../shared/entities/entity-type-decorator'; -import { ITEM } from '../../../../shared/entities/switcher/entity-type-switcher.component'; +import { rendersItemType } from '../../../../shared/items/item-type-decorator'; +import { ITEM } from '../../../../shared/items/switcher/item-type-switcher.component'; import { ElementViewMode } from '../../../../shared/view-mode'; 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({ selector: 'ds-journal-volume', styleUrls: ['./journal-volume.component.scss'], 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 */ diff --git a/src/app/+item-page/simple/entity-types/journal/journal.component.html b/src/app/+item-page/simple/item-types/journal/journal.component.html similarity index 93% rename from src/app/+item-page/simple/entity-types/journal/journal.component.html rename to src/app/+item-page/simple/item-types/journal/journal.component.html index b02000a9e4..548f6304bc 100644 --- a/src/app/+item-page/simple/entity-types/journal/journal.component.html +++ b/src/app/+item-page/simple/item-types/journal/journal.component.html @@ -16,10 +16,10 @@
- - + diff --git a/src/app/+item-page/simple/entity-types/journal/journal.component.scss b/src/app/+item-page/simple/item-types/journal/journal.component.scss similarity index 100% rename from src/app/+item-page/simple/entity-types/journal/journal.component.scss rename to src/app/+item-page/simple/item-types/journal/journal.component.scss diff --git a/src/app/+item-page/simple/entity-types/journal/journal.component.spec.ts b/src/app/+item-page/simple/item-types/journal/journal.component.spec.ts similarity index 96% rename from src/app/+item-page/simple/entity-types/journal/journal.component.spec.ts rename to src/app/+item-page/simple/item-types/journal/journal.component.spec.ts index d9915e0410..8a18f0f727 100644 --- a/src/app/+item-page/simple/entity-types/journal/journal.component.spec.ts +++ b/src/app/+item-page/simple/item-types/journal/journal.component.spec.ts @@ -1,10 +1,9 @@ import { ChangeDetectionStrategy, DebugElement, NO_ERRORS_SCHEMA } from '@angular/core'; import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 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 { ItemDataService } from '../../../../core/data/item-data.service'; -import { Observable } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; import { By } from '@angular/platform-browser'; import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; diff --git a/src/app/+item-page/simple/entity-types/journal/journal.component.ts b/src/app/+item-page/simple/item-types/journal/journal.component.ts similarity index 70% rename from src/app/+item-page/simple/entity-types/journal/journal.component.ts rename to src/app/+item-page/simple/item-types/journal/journal.component.ts index 7e1e0233b6..3af725062c 100644 --- a/src/app/+item-page/simple/entity-types/journal/journal.component.ts +++ b/src/app/+item-page/simple/item-types/journal/journal.component.ts @@ -2,22 +2,22 @@ import { Component, Inject } from '@angular/core'; import { Observable } from 'rxjs'; import { ItemDataService } from '../../../../core/data/item-data.service'; import { Item } from '../../../../core/shared/item.model'; -import { rendersEntityType } from '../../../../shared/entities/entity-type-decorator'; -import { ITEM } from '../../../../shared/entities/switcher/entity-type-switcher.component'; +import { rendersItemType } from '../../../../shared/items/item-type-decorator'; +import { ITEM } from '../../../../shared/items/switcher/item-type-switcher.component'; import { ElementViewMode } from '../../../../shared/view-mode'; 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({ selector: 'ds-journal', styleUrls: ['./journal.component.scss'], 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 */ diff --git a/src/app/+item-page/simple/entity-types/orgunit/orgunit.component.html b/src/app/+item-page/simple/item-types/orgunit/orgunit.component.html similarity index 86% rename from src/app/+item-page/simple/entity-types/orgunit/orgunit.component.html rename to src/app/+item-page/simple/item-types/orgunit/orgunit.component.html index e5a02b54e5..7eacf66347 100644 --- a/src/app/+item-page/simple/entity-types/orgunit/orgunit.component.html +++ b/src/app/+item-page/simple/item-types/orgunit/orgunit.component.html @@ -24,18 +24,18 @@
- - - + - - + - + diff --git a/src/app/+item-page/simple/entity-types/orgunit/orgunit.component.scss b/src/app/+item-page/simple/item-types/orgunit/orgunit.component.scss similarity index 100% rename from src/app/+item-page/simple/entity-types/orgunit/orgunit.component.scss rename to src/app/+item-page/simple/item-types/orgunit/orgunit.component.scss diff --git a/src/app/+item-page/simple/entity-types/orgunit/orgunit.component.spec.ts b/src/app/+item-page/simple/item-types/orgunit/orgunit.component.spec.ts similarity index 82% rename from src/app/+item-page/simple/entity-types/orgunit/orgunit.component.spec.ts rename to src/app/+item-page/simple/item-types/orgunit/orgunit.component.spec.ts index e7e83ccc2a..bb356ba7fb 100644 --- a/src/app/+item-page/simple/entity-types/orgunit/orgunit.component.spec.ts +++ b/src/app/+item-page/simple/item-types/orgunit/orgunit.component.spec.ts @@ -1,9 +1,8 @@ -import { Observable } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; import { RemoteData } from '../../../../core/data/remote-data'; import { PaginatedList } from '../../../../core/data/paginated-list'; 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 { of as observableOf } from 'rxjs'; @@ -38,4 +37,4 @@ const mockItem: Item = Object.assign(new Item(), { relationships: createRelationshipsObservable() }); -describe('OrgUnitComponent', getEntityPageFieldsTest(mockItem, OrgunitComponent)); +describe('OrgUnitComponent', getItemPageFieldsTest(mockItem, OrgunitComponent)); diff --git a/src/app/+item-page/simple/entity-types/orgunit/orgunit.component.ts b/src/app/+item-page/simple/item-types/orgunit/orgunit.component.ts similarity index 77% rename from src/app/+item-page/simple/entity-types/orgunit/orgunit.component.ts rename to src/app/+item-page/simple/item-types/orgunit/orgunit.component.ts index 1f99f29ea2..f1979b0961 100644 --- a/src/app/+item-page/simple/entity-types/orgunit/orgunit.component.ts +++ b/src/app/+item-page/simple/item-types/orgunit/orgunit.component.ts @@ -2,22 +2,22 @@ import { Component, Inject, OnInit } from '@angular/core'; import { Observable } from 'rxjs'; import { ItemDataService } from '../../../../core/data/item-data.service'; 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 { 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 { EntityComponent, filterRelationsByTypeLabel, relationsToItems } from '../shared/entity.component'; +import { ItemComponent, filterRelationsByTypeLabel, relationsToItems } from '../shared/item.component'; -@rendersEntityType('OrgUnit', ElementViewMode.Full) +@rendersItemType('OrgUnit', ElementViewMode.Full) @Component({ selector: 'ds-orgunit', styleUrls: ['./orgunit.component.scss'], 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 */ diff --git a/src/app/+item-page/simple/entity-types/person/person.component.html b/src/app/+item-page/simple/item-types/person/person.component.html similarity index 92% rename from src/app/+item-page/simple/entity-types/person/person.component.html rename to src/app/+item-page/simple/item-types/person/person.component.html index 548f46624d..a490361ac3 100644 --- a/src/app/+item-page/simple/entity-types/person/person.component.html +++ b/src/app/+item-page/simple/item-types/person/person.component.html @@ -24,14 +24,14 @@
- - - + - + diff --git a/src/app/+item-page/simple/entity-types/person/person.component.scss b/src/app/+item-page/simple/item-types/person/person.component.scss similarity index 100% rename from src/app/+item-page/simple/entity-types/person/person.component.scss rename to src/app/+item-page/simple/item-types/person/person.component.scss diff --git a/src/app/+item-page/simple/entity-types/person/person.component.spec.ts b/src/app/+item-page/simple/item-types/person/person.component.spec.ts similarity index 85% rename from src/app/+item-page/simple/entity-types/person/person.component.spec.ts rename to src/app/+item-page/simple/item-types/person/person.component.spec.ts index 70eba79180..4c582f67e8 100644 --- a/src/app/+item-page/simple/entity-types/person/person.component.spec.ts +++ b/src/app/+item-page/simple/item-types/person/person.component.spec.ts @@ -1,9 +1,8 @@ -import { Observable } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; import { RemoteData } from '../../../../core/data/remote-data'; import { PaginatedList } from '../../../../core/data/paginated-list'; 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 { of as observableOf } from 'rxjs'; @@ -48,4 +47,4 @@ const mockItem: Item = Object.assign(new Item(), { relationships: createRelationshipsObservable() }); -describe('PersonComponent', getEntityPageFieldsTest(mockItem, PersonComponent)); +describe('PersonComponent', getItemPageFieldsTest(mockItem, PersonComponent)); diff --git a/src/app/+item-page/simple/entity-types/person/person.component.ts b/src/app/+item-page/simple/item-types/person/person.component.ts similarity index 83% rename from src/app/+item-page/simple/entity-types/person/person.component.ts rename to src/app/+item-page/simple/item-types/person/person.component.ts index 2ba3a5bdcf..bb98799da5 100644 --- a/src/app/+item-page/simple/entity-types/person/person.component.ts +++ b/src/app/+item-page/simple/item-types/person/person.component.ts @@ -2,23 +2,23 @@ import { Component, Inject } from '@angular/core'; import { Observable , of as observableOf } from 'rxjs'; import { ItemDataService } from '../../../../core/data/item-data.service'; import { Item } from '../../../../core/shared/item.model'; -import { rendersEntityType } from '../../../../shared/entities/entity-type-decorator'; -import { ITEM } from '../../../../shared/entities/switcher/entity-type-switcher.component'; +import { rendersItemType } from '../../../../shared/items/item-type-decorator'; +import { ITEM } from '../../../../shared/items/switcher/item-type-switcher.component'; import { ElementViewMode } from '../../../../shared/view-mode'; import { SearchFixedFilterService } from '../../../../+search-page/search-filters/search-filter/search-fixed-filter.service'; 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({ selector: 'ds-person', styleUrls: ['./person.component.scss'], 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 */ diff --git a/src/app/+item-page/simple/entity-types/project/project.component.html b/src/app/+item-page/simple/item-types/project/project.component.html similarity index 86% rename from src/app/+item-page/simple/entity-types/project/project.component.html rename to src/app/+item-page/simple/item-types/project/project.component.html index 36a71bd71a..17aa8b2065 100644 --- a/src/app/+item-page/simple/entity-types/project/project.component.html +++ b/src/app/+item-page/simple/item-types/project/project.component.html @@ -20,18 +20,18 @@
- - - + - - + - + diff --git a/src/app/+item-page/simple/entity-types/project/project.component.scss b/src/app/+item-page/simple/item-types/project/project.component.scss similarity index 100% rename from src/app/+item-page/simple/entity-types/project/project.component.scss rename to src/app/+item-page/simple/item-types/project/project.component.scss diff --git a/src/app/+item-page/simple/entity-types/project/project.component.spec.ts b/src/app/+item-page/simple/item-types/project/project.component.spec.ts similarity index 83% rename from src/app/+item-page/simple/entity-types/project/project.component.spec.ts rename to src/app/+item-page/simple/item-types/project/project.component.spec.ts index c2fceb4266..e28c97f87d 100644 --- a/src/app/+item-page/simple/entity-types/project/project.component.spec.ts +++ b/src/app/+item-page/simple/item-types/project/project.component.spec.ts @@ -1,9 +1,8 @@ -import { Observable } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; import { RemoteData } from '../../../../core/data/remote-data'; import { PaginatedList } from '../../../../core/data/paginated-list'; 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 { of as observableOf } from 'rxjs'; @@ -38,4 +37,4 @@ const mockItem: Item = Object.assign(new Item(), { relationships: createRelationshipsObservable() }); -describe('ProjectComponent', getEntityPageFieldsTest(mockItem, ProjectComponent)); +describe('ProjectComponent', getItemPageFieldsTest(mockItem, ProjectComponent)); diff --git a/src/app/+item-page/simple/entity-types/project/project.component.ts b/src/app/+item-page/simple/item-types/project/project.component.ts similarity index 78% rename from src/app/+item-page/simple/entity-types/project/project.component.ts rename to src/app/+item-page/simple/item-types/project/project.component.ts index e31d748129..dfbdacff86 100644 --- a/src/app/+item-page/simple/entity-types/project/project.component.ts +++ b/src/app/+item-page/simple/item-types/project/project.component.ts @@ -2,22 +2,22 @@ import { Component, Inject, OnInit } from '@angular/core'; import { Observable } from 'rxjs'; import { ItemDataService } from '../../../../core/data/item-data.service'; 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 { 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 { EntityComponent, filterRelationsByTypeLabel, relationsToItems } from '../shared/entity.component'; +import { ItemComponent, filterRelationsByTypeLabel, relationsToItems } from '../shared/item.component'; -@rendersEntityType('Project', ElementViewMode.Full) +@rendersItemType('Project', ElementViewMode.Full) @Component({ selector: 'ds-project', styleUrls: ['./project.component.scss'], 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 */ diff --git a/src/app/+item-page/simple/entity-types/publication/publication.component.html b/src/app/+item-page/simple/item-types/publication/publication.component.html similarity index 76% rename from src/app/+item-page/simple/entity-types/publication/publication.component.html rename to src/app/+item-page/simple/item-types/publication/publication.component.html index 84cd5a151b..e619e18b01 100644 --- a/src/app/+item-page/simple/entity-types/publication/publication.component.html +++ b/src/app/+item-page/simple/item-types/publication/publication.component.html @@ -9,22 +9,22 @@
- - - + - - + - - + - + diff --git a/src/app/+item-page/simple/entity-types/publication/publication.component.scss b/src/app/+item-page/simple/item-types/publication/publication.component.scss similarity index 100% rename from src/app/+item-page/simple/entity-types/publication/publication.component.scss rename to src/app/+item-page/simple/item-types/publication/publication.component.scss diff --git a/src/app/+item-page/simple/entity-types/publication/publication.component.spec.ts b/src/app/+item-page/simple/item-types/publication/publication.component.spec.ts similarity index 94% rename from src/app/+item-page/simple/entity-types/publication/publication.component.spec.ts rename to src/app/+item-page/simple/item-types/publication/publication.component.spec.ts index c3c9c2cd81..603d358761 100644 --- a/src/app/+item-page/simple/entity-types/publication/publication.component.spec.ts +++ b/src/app/+item-page/simple/item-types/publication/publication.component.spec.ts @@ -3,18 +3,17 @@ import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; import { MockTranslateLoader } from '../../../../shared/mocks/mock-translate-loader'; import { GenericItemPageFieldComponent } from '../../field-components/specific-field/generic/generic-item-page-field.component'; 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 { SearchFixedFilterService } from '../../../../+search-page/search-filters/search-filter/search-fixed-filter.service'; import { TruncatableService } from '../../../../shared/truncatable/truncatable.service'; import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; import { Item } from '../../../../core/shared/item.model'; -import { Observable } from 'rxjs'; import { RemoteData } from '../../../../core/data/remote-data'; import { PaginatedList } from '../../../../core/data/paginated-list'; import { PageInfo } from '../../../../core/shared/page-info.model'; 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 { of as observableOf } from 'rxjs'; diff --git a/src/app/+item-page/simple/entity-types/publication/publication.component.ts b/src/app/+item-page/simple/item-types/publication/publication.component.ts similarity index 78% rename from src/app/+item-page/simple/entity-types/publication/publication.component.ts rename to src/app/+item-page/simple/item-types/publication/publication.component.ts index 09481362c1..b6178893d6 100644 --- a/src/app/+item-page/simple/entity-types/publication/publication.component.ts +++ b/src/app/+item-page/simple/item-types/publication/publication.component.ts @@ -3,22 +3,22 @@ import { Observable } from 'rxjs'; import { ItemDataService } from '../../../../core/data/item-data.service'; import { Item } from '../../../../core/shared/item.model'; import { - DEFAULT_ENTITY_TYPE, - rendersEntityType -} from '../../../../shared/entities/entity-type-decorator'; -import { ITEM } from '../../../../shared/entities/switcher/entity-type-switcher.component'; + DEFAULT_ITEM_TYPE, + rendersItemType +} from '../../../../shared/items/item-type-decorator'; +import { ITEM } from '../../../../shared/items/switcher/item-type-switcher.component'; 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) -@rendersEntityType(DEFAULT_ENTITY_TYPE, ElementViewMode.Full) +@rendersItemType('Publication', ElementViewMode.Full) +@rendersItemType(DEFAULT_ITEM_TYPE, ElementViewMode.Full) @Component({ selector: 'ds-publication', styleUrls: ['./publication.component.scss'], templateUrl: './publication.component.html', changeDetection: ChangeDetectionStrategy.OnPush, }) -export class PublicationComponent extends EntityComponent implements OnInit { +export class PublicationComponent extends ItemComponent implements OnInit { /** * The authors related to this publication */ diff --git a/src/app/+item-page/simple/entity-types/shared/entity.component.spec.ts b/src/app/+item-page/simple/item-types/shared/item.component.spec.ts similarity index 94% rename from src/app/+item-page/simple/entity-types/shared/entity.component.spec.ts rename to src/app/+item-page/simple/item-types/shared/item.component.spec.ts index 9565da1e7d..30f39957db 100644 --- a/src/app/+item-page/simple/entity-types/shared/entity.component.spec.ts +++ b/src/app/+item-page/simple/item-types/shared/item.component.spec.ts @@ -7,27 +7,26 @@ import { ItemDataService } from '../../../../core/data/item-data.service'; import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; import { MockTranslateLoader } from '../../../../shared/mocks/mock-translate-loader'; 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 { isNotEmpty } from '../../../../shared/empty.util'; 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 { RemoteData } from '../../../../core/data/remote-data'; -import { Relationship } from '../../../../core/shared/entities/relationship.model'; -import { Observable } from 'rxjs'; +import { Relationship } from '../../../../core/shared/item-relationships/relationship.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'; /** - * 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 * execute the tests for it's component. * @param component The type of component to create test cases for. * @returns {() => void} Returns a specDefinition for the test. */ -export function getEntityPageFieldsTest(mockItem: Item, component) { +export function getItemPageFieldsTest(mockItem: Item, component) { return () => { let comp: any; let fixture: ComponentFixture; @@ -101,7 +100,7 @@ export function createRelationshipsObservable() { }) ]))); } -describe('EntityComponent', () => { +describe('ItemComponent', () => { const arr1 = [ { id: 1, diff --git a/src/app/+item-page/simple/entity-types/shared/entity.component.ts b/src/app/+item-page/simple/item-types/shared/item.component.ts similarity index 92% rename from src/app/+item-page/simple/entity-types/shared/entity.component.ts rename to src/app/+item-page/simple/item-types/shared/item.component.ts index 616c14269b..5527114ec3 100644 --- a/src/app/+item-page/simple/entity-types/shared/entity.component.ts +++ b/src/app/+item-page/simple/item-types/shared/item.component.ts @@ -4,12 +4,12 @@ import { distinctUntilChanged, filter, flatMap, map } from 'rxjs/operators'; import { ItemDataService } from '../../../../core/data/item-data.service'; import { PaginatedList } from '../../../../core/data/paginated-list'; import { RemoteData } from '../../../../core/data/remote-data'; -import { RelationshipType } from '../../../../core/shared/entities/relationship-type.model'; -import { Relationship } from '../../../../core/shared/entities/relationship.model'; +import { RelationshipType } from '../../../../core/shared/item-relationships/relationship-type.model'; +import { Relationship } from '../../../../core/shared/item-relationships/relationship.model'; import { Item } from '../../../../core/shared/item.model'; import { getRemoteDataPayload } from '../../../../core/shared/operators'; 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 @@ -83,13 +83,13 @@ export const relationsToItems = (thisId: string, ids: ItemDataService) => ); @Component({ - selector: 'ds-entity', + selector: 'ds-item', template: '' }) /** * 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 */ diff --git a/src/app/+item-page/simple/related-entities/related-entities.component.html b/src/app/+item-page/simple/related-entities/related-entities.component.html deleted file mode 100644 index f09f0ccdef..0000000000 --- a/src/app/+item-page/simple/related-entities/related-entities.component.html +++ /dev/null @@ -1,5 +0,0 @@ - - - - diff --git a/src/app/+item-page/simple/related-entities/related-entities-component.ts b/src/app/+item-page/simple/related-items/related-items-component.ts similarity index 54% rename from src/app/+item-page/simple/related-entities/related-entities-component.ts rename to src/app/+item-page/simple/related-items/related-items-component.ts index 85532eacbe..6ad2f0eeb3 100644 --- a/src/app/+item-page/simple/related-entities/related-entities-component.ts +++ b/src/app/+item-page/simple/related-items/related-items-component.ts @@ -3,19 +3,19 @@ import { Item } from '../../../core/shared/item.model'; import * as viewMode from '../../../shared/view-mode'; @Component({ - selector: 'ds-related-entities', - styleUrls: ['./related-entities.component.scss'], - templateUrl: './related-entities.component.html' + selector: 'ds-related-items', + styleUrls: ['./related-items.component.scss'], + templateUrl: './related-items.component.html' }) /** - * This component is used for displaying relations between entities - * It expects a list of entities to display and a label to put on top + * This component is used for displaying relations between items + * 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) diff --git a/src/app/+item-page/simple/related-items/related-items.component.html b/src/app/+item-page/simple/related-items/related-items.component.html new file mode 100644 index 0000000000..bd8b7eb5f3 --- /dev/null +++ b/src/app/+item-page/simple/related-items/related-items.component.html @@ -0,0 +1,5 @@ + + + + diff --git a/src/app/+item-page/simple/related-entities/related-entities.component.scss b/src/app/+item-page/simple/related-items/related-items.component.scss similarity index 100% rename from src/app/+item-page/simple/related-entities/related-entities.component.scss rename to src/app/+item-page/simple/related-items/related-items.component.scss diff --git a/src/app/+item-page/simple/related-entities/related-entities.component.spec.ts b/src/app/+item-page/simple/related-items/related-items.component.spec.ts similarity index 62% rename from src/app/+item-page/simple/related-entities/related-entities.component.spec.ts rename to src/app/+item-page/simple/related-items/related-items.component.spec.ts index a8897c1e88..ef42ab1098 100644 --- a/src/app/+item-page/simple/related-entities/related-entities.component.spec.ts +++ b/src/app/+item-page/simple/related-items/related-items.component.spec.ts @@ -1,12 +1,12 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 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 { RemoteData } from '../../../core/data/remote-data'; import { PaginatedList } from '../../../core/data/paginated-list'; import { PageInfo } from '../../../core/shared/page-info.model'; 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'; const mockItem1: Item = Object.assign(new Item(), { @@ -19,33 +19,33 @@ const mockItem2: Item = Object.assign(new Item(), { metadata: [], relationships: createRelationshipsObservable() }); -const mockEntities = [mockItem1, mockItem2]; +const mockItems = [mockItem1, mockItem2]; -describe('RelatedEntitiesComponent', () => { - let comp: RelatedEntitiesComponent; - let fixture: ComponentFixture; +describe('RelatedItemsComponent', () => { + let comp: RelatedItemsComponent; + let fixture: ComponentFixture; beforeEach(async(() => { TestBed.configureTestingModule({ imports: [], - declarations: [RelatedEntitiesComponent], + declarations: [RelatedItemsComponent], providers: [], schemas: [NO_ERRORS_SCHEMA] - }).overrideComponent(RelatedEntitiesComponent, { + }).overrideComponent(RelatedItemsComponent, { set: {changeDetection: ChangeDetectionStrategy.Default} }).compileComponents(); })); beforeEach(async(() => { - fixture = TestBed.createComponent(RelatedEntitiesComponent); + fixture = TestBed.createComponent(RelatedItemsComponent); comp = fixture.componentInstance; - comp.entities = mockEntities; + comp.items = mockItems; fixture.detectChanges(); })); - it(`should load ${mockEntities.length} entity-type-switcher components`, () => { - const fields = fixture.debugElement.queryAll(By.css('ds-entity-type-switcher')); - expect(fields.length).toBe(mockEntities.length); + it(`should load ${mockItems.length} item-type-switcher components`, () => { + const fields = fixture.debugElement.queryAll(By.css('ds-item-type-switcher')); + expect(fields.length).toBe(mockItems.length); }); }); diff --git a/src/app/core/cache/models/entities/normalized-entity-type.model.ts b/src/app/core/cache/models/items/normalized-item-type.model.ts similarity index 53% rename from src/app/core/cache/models/entities/normalized-entity-type.model.ts rename to src/app/core/cache/models/items/normalized-item-type.model.ts index 729aa39d7b..80ec132c42 100644 --- a/src/app/core/cache/models/entities/normalized-entity-type.model.ts +++ b/src/app/core/cache/models/items/normalized-item-type.model.ts @@ -1,32 +1,32 @@ 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 { mapsTo } from '../../builders/build-decorators'; import { NormalizedObject } from '../normalized-object.model'; 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) -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 label: string; /** - * The identifier of this EntityType + * The identifier of this ItemType */ @autoserialize 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; } diff --git a/src/app/core/cache/models/entities/normalized-relationship-type.model.ts b/src/app/core/cache/models/items/normalized-relationship-type.model.ts similarity index 85% rename from src/app/core/cache/models/entities/normalized-relationship-type.model.ts rename to src/app/core/cache/models/items/normalized-relationship-type.model.ts index ea71e217b9..271bd9cb6f 100644 --- a/src/app/core/cache/models/entities/normalized-relationship-type.model.ts +++ b/src/app/core/cache/models/items/normalized-relationship-type.model.ts @@ -1,5 +1,5 @@ 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 { mapsTo, relationship } from '../../builders/build-decorators'; import { NormalizedDSpaceObject } from '../normalized-dspace-object.model'; @@ -56,17 +56,17 @@ export class NormalizedRelationshipType extends NormalizedObject { 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 - @relationship(ResourceType.EntityType, false) + @relationship(ResourceType.ItemType, false) 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 - @relationship(ResourceType.EntityType, false) + @relationship(ResourceType.ItemType, false) rightType: string; /** diff --git a/src/app/core/cache/models/entities/normalized-relationship.model.ts b/src/app/core/cache/models/items/normalized-relationship.model.ts similarity index 75% rename from src/app/core/cache/models/entities/normalized-relationship.model.ts rename to src/app/core/cache/models/items/normalized-relationship.model.ts index 598687bbde..5d0ca2a9ad 100644 --- a/src/app/core/cache/models/entities/normalized-relationship.model.ts +++ b/src/app/core/cache/models/items/normalized-relationship.model.ts @@ -1,5 +1,5 @@ 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 { mapsTo, relationship } from '../../builders/build-decorators'; import { NormalizedObject } from '../normalized-object.model'; @@ -19,25 +19,25 @@ export class NormalizedRelationship extends NormalizedObject { 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 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 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 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 rightPlace: number; diff --git a/src/app/core/cache/models/normalized-object-factory.ts b/src/app/core/cache/models/normalized-object-factory.ts index 2f8cab737f..e3b2f8dcd2 100644 --- a/src/app/core/cache/models/normalized-object-factory.ts +++ b/src/app/core/cache/models/normalized-object-factory.ts @@ -1,6 +1,6 @@ -import { NormalizedEntityType } from './entities/normalized-entity-type.model'; -import { NormalizedRelationshipType } from './entities/normalized-relationship-type.model'; -import { NormalizedRelationship } from './entities/normalized-relationship.model'; +import { NormalizedItemType } from './items/normalized-item-type.model'; +import { NormalizedRelationshipType } from './items/normalized-relationship-type.model'; +import { NormalizedRelationship } from './items/normalized-relationship.model'; import { NormalizedBitstream } from './normalized-bitstream.model'; import { NormalizedBundle } from './normalized-bundle.model'; import { NormalizedItem } from './normalized-item.model'; @@ -44,8 +44,8 @@ export class NormalizedObjectFactory { case ResourceType.RelationshipType: { return NormalizedRelationshipType } - case ResourceType.EntityType: { - return NormalizedEntityType + case ResourceType.ItemType: { + return NormalizedItemType } case ResourceType.EPerson: { return NormalizedEPerson diff --git a/src/app/core/shared/entities/entity-type.model.ts b/src/app/core/shared/item-relationships/item-type.model.ts similarity index 65% rename from src/app/core/shared/entities/entity-type.model.ts rename to src/app/core/shared/item-relationships/item-type.model.ts index 4532e05b19..e4f98ab653 100644 --- a/src/app/core/shared/entities/entity-type.model.ts +++ b/src/app/core/shared/item-relationships/item-type.model.ts @@ -2,11 +2,11 @@ import { CacheableObject } from '../../cache/object-cache.reducer'; 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; @@ -21,7 +21,7 @@ export class EntityType implements CacheableObject { type: ResourceType; /** - * The universally unique identifier of this EntityType + * The universally unique identifier of this ItemType */ uuid: string; } diff --git a/src/app/core/shared/entities/relationship-type.model.ts b/src/app/core/shared/item-relationships/relationship-type.model.ts similarity index 80% rename from src/app/core/shared/entities/relationship-type.model.ts rename to src/app/core/shared/item-relationships/relationship-type.model.ts index 05dd0cd754..404d8cdb4b 100644 --- a/src/app/core/shared/entities/relationship-type.model.ts +++ b/src/app/core/shared/item-relationships/relationship-type.model.ts @@ -2,10 +2,10 @@ import { Observable } from 'rxjs'; import { CacheableObject } from '../../cache/object-cache.reducer'; import { RemoteData } from '../../data/remote-data'; 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 { /** @@ -64,12 +64,12 @@ export class RelationshipType implements CacheableObject { 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>; + leftType: Observable>; /** - * The type of Entity found to the right of this RelationshipType + * The type of Item found to the right of this RelationshipType */ - rightType: Observable>; + rightType: Observable>; } diff --git a/src/app/core/shared/entities/relationship.model.ts b/src/app/core/shared/item-relationships/relationship.model.ts similarity index 73% rename from src/app/core/shared/entities/relationship.model.ts rename to src/app/core/shared/item-relationships/relationship.model.ts index ef76b0a32a..df8f04cd8a 100644 --- a/src/app/core/shared/entities/relationship.model.ts +++ b/src/app/core/shared/item-relationships/relationship.model.ts @@ -5,7 +5,7 @@ import { ResourceType } from '../resource-type'; import { RelationshipType } from './relationship-type.model'; /** - * Describes a Relationship between two Entities + * Describes a Relationship between two Items */ export class Relationship implements CacheableObject { /** @@ -29,22 +29,22 @@ export class Relationship implements CacheableObject { 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; /** - * 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; /** - * 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; /** - * 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; diff --git a/src/app/core/shared/item.model.ts b/src/app/core/shared/item.model.ts index e8646777cf..7dadfafdd9 100644 --- a/src/app/core/shared/item.model.ts +++ b/src/app/core/shared/item.model.ts @@ -7,7 +7,7 @@ import { RemoteData } from '../data/remote-data'; import { Bitstream } from './bitstream.model'; import { hasValue, isNotEmpty } from '../../shared/empty.util'; import { PaginatedList } from '../data/paginated-list'; -import { Relationship } from './entities/relationship.model'; +import { Relationship } from './item-relationships/relationship.model'; export class Item extends DSpaceObject { diff --git a/src/app/core/shared/resource-type.ts b/src/app/core/shared/resource-type.ts index 4251f68e35..c61989dcc3 100644 --- a/src/app/core/shared/resource-type.ts +++ b/src/app/core/shared/resource-type.ts @@ -11,5 +11,5 @@ export enum ResourceType { ResourcePolicy = 'resourcePolicy', Relationship = 'relationship', RelationshipType = 'relationshiptype', - EntityType = 'entitytype', + ItemType = 'entitytype', } diff --git a/src/app/shared/entities/entity-type-decorator.ts b/src/app/shared/items/item-type-decorator.ts similarity index 62% rename from src/app/shared/entities/entity-type-decorator.ts rename to src/app/shared/items/item-type-decorator.ts index 9af226ea3d..509a1c754a 100644 --- a/src/app/shared/entities/entity-type-decorator.ts +++ b/src/app/shared/items/item-type-decorator.ts @@ -1,16 +1,16 @@ import { hasNoValue, hasValue } from '../empty.util'; import { ElementViewMode } from '../view-mode'; -export const DEFAULT_ENTITY_TYPE = 'Default'; +export const DEFAULT_ITEM_TYPE = 'Default'; 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 viewMode */ -export function rendersEntityType(type: string, viewMode: ElementViewMode) { +export function rendersItemType(type: string, viewMode: ElementViewMode) { return function decorator(component: any) { if (hasNoValue(map.get(viewMode))) { 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 viewMode */ -export function getComponentByEntityType(type: string, viewMode: ElementViewMode) { +export function getComponentByItemType(type: string, viewMode: ElementViewMode) { let component = map.get(viewMode).get(type); if (hasNoValue(component)) { - component = map.get(viewMode).get(DEFAULT_ENTITY_TYPE); + component = map.get(viewMode).get(DEFAULT_ITEM_TYPE); } return component; } diff --git a/src/app/shared/entities/switcher/entity-type-switcher.component.html b/src/app/shared/items/switcher/item-type-switcher.component.html similarity index 100% rename from src/app/shared/entities/switcher/entity-type-switcher.component.html rename to src/app/shared/items/switcher/item-type-switcher.component.html diff --git a/src/app/shared/entities/switcher/entity-type-switcher.component.scss b/src/app/shared/items/switcher/item-type-switcher.component.scss similarity index 100% rename from src/app/shared/entities/switcher/entity-type-switcher.component.scss rename to src/app/shared/items/switcher/item-type-switcher.component.scss diff --git a/src/app/shared/entities/switcher/entity-type-switcher.component.spec.ts b/src/app/shared/items/switcher/item-type-switcher.component.spec.ts similarity index 63% rename from src/app/shared/entities/switcher/entity-type-switcher.component.spec.ts rename to src/app/shared/items/switcher/item-type-switcher.component.spec.ts index 053b03512a..67f5309793 100644 --- a/src/app/shared/entities/switcher/entity-type-switcher.component.spec.ts +++ b/src/app/shared/items/switcher/item-type-switcher.component.spec.ts @@ -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 { NO_ERRORS_SCHEMA } from '@angular/core'; 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 { PaginatedList } from '../../../core/data/paginated-list'; import { RemoteData } from '../../../core/data/remote-data'; -import * as decorator from '../entity-type-decorator'; -import { getComponentByEntityType } from '../entity-type-decorator'; +import * as decorator from '../item-type-decorator'; +import { getComponentByItemType } from '../item-type-decorator'; import { ElementViewMode } from '../../view-mode'; import createSpy = jasmine.createSpy; @@ -28,23 +28,23 @@ const mockItem: Item = Object.assign(new Item(), { }); const viewMode = ElementViewMode.Full; -describe('EntityTypeSwitcherComponent', () => { - let comp: EntityTypeSwitcherComponent; - let fixture: ComponentFixture; +describe('ItemTypeSwitcherComponent', () => { + let comp: ItemTypeSwitcherComponent; + let fixture: ComponentFixture; beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ EntityTypeSwitcherComponent ], + declarations: [ ItemTypeSwitcherComponent ], schemas: [ NO_ERRORS_SCHEMA ] }).compileComponents(); // compile template and css })); beforeEach(async(() => { - fixture = TestBed.createComponent(EntityTypeSwitcherComponent); + fixture = TestBed.createComponent(ItemTypeSwitcherComponent); comp = fixture.componentInstance; comp.object = mockItem; comp.viewMode = viewMode; - spyOnProperty(decorator, 'getComponentByEntityType').and.returnValue(createSpy('getComponentByEntityType')) + spyOnProperty(decorator, 'getComponentByItemType').and.returnValue(createSpy('getComponentByItemType')) })); describe('when calling getComponent', () => { @@ -52,8 +52,8 @@ describe('EntityTypeSwitcherComponent', () => { comp.getComponent(); }); - it('should call getComponentByEntityType with parameters type and viewMode', () => { - expect(decorator.getComponentByEntityType).toHaveBeenCalledWith(relationType, viewMode); + it('should call getComponentByItemType with parameters type and viewMode', () => { + expect(decorator.getComponentByItemType).toHaveBeenCalledWith(relationType, viewMode); }); }); diff --git a/src/app/shared/entities/switcher/entity-type-switcher.component.ts b/src/app/shared/items/switcher/item-type-switcher.component.ts similarity index 82% rename from src/app/shared/entities/switcher/entity-type-switcher.component.ts rename to src/app/shared/items/switcher/item-type-switcher.component.ts index 4b910ebebc..5599326e98 100644 --- a/src/app/shared/entities/switcher/entity-type-switcher.component.ts +++ b/src/app/shared/items/switcher/item-type-switcher.component.ts @@ -3,20 +3,20 @@ import { SearchResult } from '../../../+search-page/search-result.model'; import { Item } from '../../../core/shared/item.model'; import { hasValue } from '../../empty.util'; 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'; export const ITEM: InjectionToken = new InjectionToken('item'); @Component({ - selector: 'ds-entity-type-switcher', - styleUrls: ['./entity-type-switcher.component.scss'], - templateUrl: './entity-type-switcher.component.html' + selector: 'ds-item-type-switcher', + styleUrls: ['./item-type-switcher.component.scss'], + templateUrl: './item-type-switcher.component.html' }) /** * 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 */ @@ -57,6 +57,6 @@ export class EntityTypeSwitcherComponent implements OnInit { } const type = item.findMetadata('relationship.type'); - return getComponentByEntityType(type, this.viewMode); + return getComponentByItemType(type, this.viewMode); } } diff --git a/src/app/shared/object-list/item-list-element/entity-list-element.component.html b/src/app/shared/object-list/item-list-element/entity-list-element.component.html deleted file mode 100644 index 777f131a23..0000000000 --- a/src/app/shared/object-list/item-list-element/entity-list-element.component.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/app/shared/object-list/item-list-element/entity-types/journal-issue/journal-issue-list-element.component.ts b/src/app/shared/object-list/item-list-element/entity-types/journal-issue/journal-issue-list-element.component.ts deleted file mode 100644 index 7f8278fcd3..0000000000 --- a/src/app/shared/object-list/item-list-element/entity-types/journal-issue/journal-issue-list-element.component.ts +++ /dev/null @@ -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 { -} diff --git a/src/app/shared/object-list/item-list-element/entity-types/journal-volume/journal-volume-list-element.component.ts b/src/app/shared/object-list/item-list-element/entity-types/journal-volume/journal-volume-list-element.component.ts deleted file mode 100644 index e68b7e462d..0000000000 --- a/src/app/shared/object-list/item-list-element/entity-types/journal-volume/journal-volume-list-element.component.ts +++ /dev/null @@ -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 { -} diff --git a/src/app/shared/object-list/item-list-element/entity-types/journal/journal-list-element.component.ts b/src/app/shared/object-list/item-list-element/entity-types/journal/journal-list-element.component.ts deleted file mode 100644 index 23d030c77f..0000000000 --- a/src/app/shared/object-list/item-list-element/entity-types/journal/journal-list-element.component.ts +++ /dev/null @@ -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 { -} diff --git a/src/app/shared/object-list/item-list-element/entity-types/orgunit/orgunit-list-element.component.ts b/src/app/shared/object-list/item-list-element/entity-types/orgunit/orgunit-list-element.component.ts deleted file mode 100644 index 72bd143971..0000000000 --- a/src/app/shared/object-list/item-list-element/entity-types/orgunit/orgunit-list-element.component.ts +++ /dev/null @@ -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 { -} diff --git a/src/app/shared/object-list/item-list-element/entity-types/person/person-list-element.component.ts b/src/app/shared/object-list/item-list-element/entity-types/person/person-list-element.component.ts deleted file mode 100644 index 32e378c8c7..0000000000 --- a/src/app/shared/object-list/item-list-element/entity-types/person/person-list-element.component.ts +++ /dev/null @@ -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 { -} diff --git a/src/app/shared/object-list/item-list-element/entity-types/project/project-list-element.component.ts b/src/app/shared/object-list/item-list-element/entity-types/project/project-list-element.component.ts deleted file mode 100644 index ffffd70a33..0000000000 --- a/src/app/shared/object-list/item-list-element/entity-types/project/project-list-element.component.ts +++ /dev/null @@ -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 { -} diff --git a/src/app/shared/object-list/item-list-element/entity-types/publication/publication-list-element.component.ts b/src/app/shared/object-list/item-list-element/entity-types/publication/publication-list-element.component.ts deleted file mode 100644 index 5e98a5657e..0000000000 --- a/src/app/shared/object-list/item-list-element/entity-types/publication/publication-list-element.component.ts +++ /dev/null @@ -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 { -} diff --git a/src/app/shared/object-list/item-list-element/item-list-element.component.html b/src/app/shared/object-list/item-list-element/item-list-element.component.html new file mode 100644 index 0000000000..8cdf8cac6a --- /dev/null +++ b/src/app/shared/object-list/item-list-element/item-list-element.component.html @@ -0,0 +1 @@ + diff --git a/src/app/shared/object-list/item-list-element/entity-list-element.component.scss b/src/app/shared/object-list/item-list-element/item-list-element.component.scss similarity index 100% rename from src/app/shared/object-list/item-list-element/entity-list-element.component.scss rename to src/app/shared/object-list/item-list-element/item-list-element.component.scss diff --git a/src/app/shared/object-list/item-list-element/entity-list-element.component.spec.ts b/src/app/shared/object-list/item-list-element/item-list-element.component.spec.ts similarity index 62% rename from src/app/shared/object-list/item-list-element/entity-list-element.component.spec.ts rename to src/app/shared/object-list/item-list-element/item-list-element.component.spec.ts index b32db3df06..11fdae7e6d 100644 --- a/src/app/shared/object-list/item-list-element/entity-list-element.component.spec.ts +++ b/src/app/shared/object-list/item-list-element/item-list-element.component.spec.ts @@ -1,13 +1,12 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 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 { Observable } from 'rxjs'; import { RemoteData } from '../../../core/data/remote-data'; import { PaginatedList } from '../../../core/data/paginated-list'; import { PageInfo } from '../../../core/shared/page-info.model'; 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'; const mockItem: Item = Object.assign(new Item(), { @@ -16,32 +15,32 @@ const mockItem: Item = Object.assign(new Item(), { relationships: createRelationshipsObservable() }); -describe('EntityListElementComponent', () => { - let comp: EntityListElementComponent; - let fixture: ComponentFixture; +describe('ItemListElementComponent', () => { + let comp: ItemListElementComponent; + let fixture: ComponentFixture; beforeEach(async(() => { TestBed.configureTestingModule({ imports: [], - declarations: [EntityListElementComponent], + declarations: [ItemListElementComponent], providers: [ { provide: 'objectElementProvider', useValue: mockItem } ], schemas: [NO_ERRORS_SCHEMA] - }).overrideComponent(EntityListElementComponent, { + }).overrideComponent(ItemListElementComponent, { set: {changeDetection: ChangeDetectionStrategy.Default} }).compileComponents(); })); beforeEach(async(() => { - fixture = TestBed.createComponent(EntityListElementComponent); + fixture = TestBed.createComponent(ItemListElementComponent); comp = fixture.componentInstance; fixture.detectChanges(); })); - it('should call an entity-type-switcher component and pass the item', () => { - const entityTypeSwitcher = fixture.debugElement.query(By.css('ds-entity-type-switcher')).componentInstance; - expect(entityTypeSwitcher.object).toBe(mockItem); + it('should call an item-type-switcher component and pass the item', () => { + const itemTypeSwitcher = fixture.debugElement.query(By.css('ds-item-type-switcher')).componentInstance; + expect(itemTypeSwitcher.object).toBe(mockItem); }); }); diff --git a/src/app/shared/object-list/item-list-element/entity-list-element.component.ts b/src/app/shared/object-list/item-list-element/item-list-element.component.ts similarity index 59% rename from src/app/shared/object-list/item-list-element/entity-list-element.component.ts rename to src/app/shared/object-list/item-list-element/item-list-element.component.ts index e71a868579..a9677c9777 100644 --- a/src/app/shared/object-list/item-list-element/entity-list-element.component.ts +++ b/src/app/shared/object-list/item-list-element/item-list-element.component.ts @@ -7,16 +7,16 @@ import { AbstractListableElementComponent } from '../../object-collection/shared import { SetViewMode } from '../../view-mode'; @Component({ - selector: 'ds-entity-list-element', - styleUrls: ['./entity-list-element.component.scss'], - templateUrl: './entity-list-element.component.html' + selector: 'ds-item-list-element', + styleUrls: ['./item-list-element.component.scss'], + templateUrl: './item-list-element.component.html' }) /** - * The component used to list entities depending on type - * Uses entity-type-switcher to determine which components to use for displaying the list + * The component used to list items depending on type + * Uses item-type-switcher to determine which components to use for displaying the list */ @renderElementsFor(Item, SetViewMode.List) -export class EntityListElementComponent extends AbstractListableElementComponent { +export class ItemListElementComponent extends AbstractListableElementComponent { ElementViewMode = viewMode.ElementViewMode; } diff --git a/src/app/shared/object-list/item-list-element/entity-types/entity-search-result-component.ts b/src/app/shared/object-list/item-list-element/item-types/item-search-result-component.ts similarity index 77% rename from src/app/shared/object-list/item-list-element/entity-types/entity-search-result-component.ts rename to src/app/shared/object-list/item-list-element/item-types/item-search-result-component.ts index ed53c45395..17e7b7f173 100644 --- a/src/app/shared/object-list/item-list-element/entity-types/entity-search-result-component.ts +++ b/src/app/shared/object-list/item-list-element/item-types/item-search-result-component.ts @@ -1,19 +1,19 @@ import { Component, Inject } from '@angular/core'; import { Item } from '../../../../core/shared/item.model'; 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 { TruncatableService } from '../../../truncatable/truncatable.service'; 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({ - selector: 'ds-entity-search-result', + selector: 'ds-item-search-result', template: '' }) -export class EntitySearchResultComponent extends SearchResultListElementComponent { +export class ItemSearchResultComponent extends SearchResultListElementComponent { item: Item; constructor( diff --git a/src/app/shared/object-list/item-list-element/entity-types/entity-search-result.component.spec.ts b/src/app/shared/object-list/item-list-element/item-types/item-search-result.component.spec.ts similarity index 75% rename from src/app/shared/object-list/item-list-element/entity-types/entity-search-result.component.spec.ts rename to src/app/shared/object-list/item-list-element/item-types/item-search-result.component.spec.ts index e9a871985b..be163f7a6c 100644 --- a/src/app/shared/object-list/item-list-element/entity-types/entity-search-result.component.spec.ts +++ b/src/app/shared/object-list/item-list-element/item-types/item-search-result.component.spec.ts @@ -2,15 +2,14 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { TruncatePipe } from '../../../utils/truncate.pipe'; import { TruncatableService } from '../../../truncatable/truncatable.service'; 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 { Observable } from 'rxjs'; import { RemoteData } from '../../../../core/data/remote-data'; import { PaginatedList } from '../../../../core/data/paginated-list'; 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 { 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'; const mockItem: Item = Object.assign(new Item(), { @@ -23,27 +22,27 @@ const mockSearchResult = { hitHighlights: [] } as ItemSearchResult; -describe('EntitySearchResultComponent', () => { - let comp: EntitySearchResultComponent; - let fixture: ComponentFixture; +describe('ItemSearchResultComponent', () => { + let comp: ItemSearchResultComponent; + let fixture: ComponentFixture; describe('when injecting an Item', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [EntitySearchResultComponent, TruncatePipe], + declarations: [ItemSearchResultComponent, TruncatePipe], providers: [ {provide: TruncatableService, useValue: {}}, {provide: ITEM, useValue: mockItem} ], schemas: [NO_ERRORS_SCHEMA] - }).overrideComponent(EntitySearchResultComponent, { + }).overrideComponent(ItemSearchResultComponent, { set: {changeDetection: ChangeDetectionStrategy.Default} }).compileComponents(); })); beforeEach(async(() => { - fixture = TestBed.createComponent(EntitySearchResultComponent); + fixture = TestBed.createComponent(ItemSearchResultComponent); comp = fixture.componentInstance; })); @@ -57,20 +56,20 @@ describe('EntitySearchResultComponent', () => { describe('when injecting an ItemSearchResult', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [EntitySearchResultComponent, TruncatePipe], + declarations: [ItemSearchResultComponent, TruncatePipe], providers: [ {provide: TruncatableService, useValue: {}}, {provide: ITEM, useValue: mockSearchResult} ], schemas: [NO_ERRORS_SCHEMA] - }).overrideComponent(EntitySearchResultComponent, { + }).overrideComponent(ItemSearchResultComponent, { set: {changeDetection: ChangeDetectionStrategy.Default} }).compileComponents(); })); beforeEach(async(() => { - fixture = TestBed.createComponent(EntitySearchResultComponent); + fixture = TestBed.createComponent(ItemSearchResultComponent); comp = fixture.componentInstance; })); diff --git a/src/app/shared/object-list/item-list-element/entity-types/journal-issue/journal-issue-list-element.component.html b/src/app/shared/object-list/item-list-element/item-types/journal-issue/journal-issue-list-element.component.html similarity index 100% rename from src/app/shared/object-list/item-list-element/entity-types/journal-issue/journal-issue-list-element.component.html rename to src/app/shared/object-list/item-list-element/item-types/journal-issue/journal-issue-list-element.component.html diff --git a/src/app/shared/object-list/item-list-element/entity-types/journal-issue/journal-issue-list-element.component.scss b/src/app/shared/object-list/item-list-element/item-types/journal-issue/journal-issue-list-element.component.scss similarity index 100% rename from src/app/shared/object-list/item-list-element/entity-types/journal-issue/journal-issue-list-element.component.scss rename to src/app/shared/object-list/item-list-element/item-types/journal-issue/journal-issue-list-element.component.scss diff --git a/src/app/shared/object-list/item-list-element/entity-types/journal-issue/journal-issue-list-element.component.spec.ts b/src/app/shared/object-list/item-list-element/item-types/journal-issue/journal-issue-list-element.component.spec.ts similarity index 96% rename from src/app/shared/object-list/item-list-element/entity-types/journal-issue/journal-issue-list-element.component.spec.ts rename to src/app/shared/object-list/item-list-element/item-types/journal-issue/journal-issue-list-element.component.spec.ts index 07be07d051..4f829a6818 100644 --- a/src/app/shared/object-list/item-list-element/entity-types/journal-issue/journal-issue-list-element.component.spec.ts +++ b/src/app/shared/object-list/item-list-element/item-types/journal-issue/journal-issue-list-element.component.spec.ts @@ -1,11 +1,10 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; import { By } from '@angular/platform-browser'; -import { Observable } from 'rxjs'; import { Item } from '../../../../../core/shared/item.model'; import { TruncatePipe } from '../../../../utils/truncate.pipe'; 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 { of as observableOf } from 'rxjs'; diff --git a/src/app/shared/object-list/item-list-element/item-types/journal-issue/journal-issue-list-element.component.ts b/src/app/shared/object-list/item-list-element/item-types/journal-issue/journal-issue-list-element.component.ts new file mode 100644 index 0000000000..3b47d1ab51 --- /dev/null +++ b/src/app/shared/object-list/item-list-element/item-types/journal-issue/journal-issue-list-element.component.ts @@ -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 { +} diff --git a/src/app/shared/object-list/item-list-element/entity-types/journal-volume/journal-volume-list-element.component.html b/src/app/shared/object-list/item-list-element/item-types/journal-volume/journal-volume-list-element.component.html similarity index 100% rename from src/app/shared/object-list/item-list-element/entity-types/journal-volume/journal-volume-list-element.component.html rename to src/app/shared/object-list/item-list-element/item-types/journal-volume/journal-volume-list-element.component.html diff --git a/src/app/shared/object-list/item-list-element/entity-types/journal-volume/journal-volume-list-element.component.scss b/src/app/shared/object-list/item-list-element/item-types/journal-volume/journal-volume-list-element.component.scss similarity index 100% rename from src/app/shared/object-list/item-list-element/entity-types/journal-volume/journal-volume-list-element.component.scss rename to src/app/shared/object-list/item-list-element/item-types/journal-volume/journal-volume-list-element.component.scss diff --git a/src/app/shared/object-list/item-list-element/entity-types/journal-volume/journal-volume-list-element.component.spec.ts b/src/app/shared/object-list/item-list-element/item-types/journal-volume/journal-volume-list-element.component.spec.ts similarity index 96% rename from src/app/shared/object-list/item-list-element/entity-types/journal-volume/journal-volume-list-element.component.spec.ts rename to src/app/shared/object-list/item-list-element/item-types/journal-volume/journal-volume-list-element.component.spec.ts index 7388d12f25..93071289b8 100644 --- a/src/app/shared/object-list/item-list-element/entity-types/journal-volume/journal-volume-list-element.component.spec.ts +++ b/src/app/shared/object-list/item-list-element/item-types/journal-volume/journal-volume-list-element.component.spec.ts @@ -1,11 +1,10 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; import { By } from '@angular/platform-browser'; -import { Observable } from 'rxjs'; import { Item } from '../../../../../core/shared/item.model'; import { TruncatePipe } from '../../../../utils/truncate.pipe'; 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 { of as observableOf } from 'rxjs'; diff --git a/src/app/shared/object-list/item-list-element/item-types/journal-volume/journal-volume-list-element.component.ts b/src/app/shared/object-list/item-list-element/item-types/journal-volume/journal-volume-list-element.component.ts new file mode 100644 index 0000000000..39595122e1 --- /dev/null +++ b/src/app/shared/object-list/item-list-element/item-types/journal-volume/journal-volume-list-element.component.ts @@ -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 { +} diff --git a/src/app/shared/object-list/item-list-element/entity-types/journal/journal-list-element.component.html b/src/app/shared/object-list/item-list-element/item-types/journal/journal-list-element.component.html similarity index 100% rename from src/app/shared/object-list/item-list-element/entity-types/journal/journal-list-element.component.html rename to src/app/shared/object-list/item-list-element/item-types/journal/journal-list-element.component.html diff --git a/src/app/shared/object-list/item-list-element/entity-types/journal/journal-list-element.component.scss b/src/app/shared/object-list/item-list-element/item-types/journal/journal-list-element.component.scss similarity index 100% rename from src/app/shared/object-list/item-list-element/entity-types/journal/journal-list-element.component.scss rename to src/app/shared/object-list/item-list-element/item-types/journal/journal-list-element.component.scss diff --git a/src/app/shared/object-list/item-list-element/entity-types/journal/journal-list-element.component.spec.ts b/src/app/shared/object-list/item-list-element/item-types/journal/journal-list-element.component.spec.ts similarity index 95% rename from src/app/shared/object-list/item-list-element/entity-types/journal/journal-list-element.component.spec.ts rename to src/app/shared/object-list/item-list-element/item-types/journal/journal-list-element.component.spec.ts index 8fd8d870fa..abdeb9c00f 100644 --- a/src/app/shared/object-list/item-list-element/entity-types/journal/journal-list-element.component.spec.ts +++ b/src/app/shared/object-list/item-list-element/item-types/journal/journal-list-element.component.spec.ts @@ -1,11 +1,10 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; import { By } from '@angular/platform-browser'; -import { Observable } from 'rxjs'; import { Item } from '../../../../../core/shared/item.model'; import { TruncatePipe } from '../../../../utils/truncate.pipe'; 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 { of as observableOf } from 'rxjs'; diff --git a/src/app/shared/object-list/item-list-element/item-types/journal/journal-list-element.component.ts b/src/app/shared/object-list/item-list-element/item-types/journal/journal-list-element.component.ts new file mode 100644 index 0000000000..113594630e --- /dev/null +++ b/src/app/shared/object-list/item-list-element/item-types/journal/journal-list-element.component.ts @@ -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 { +} diff --git a/src/app/shared/object-list/item-list-element/entity-types/orgunit/orgunit-list-element.component.html b/src/app/shared/object-list/item-list-element/item-types/orgunit/orgunit-list-element.component.html similarity index 100% rename from src/app/shared/object-list/item-list-element/entity-types/orgunit/orgunit-list-element.component.html rename to src/app/shared/object-list/item-list-element/item-types/orgunit/orgunit-list-element.component.html diff --git a/src/app/shared/object-list/item-list-element/entity-types/orgunit/orgunit-list-element.component.scss b/src/app/shared/object-list/item-list-element/item-types/orgunit/orgunit-list-element.component.scss similarity index 100% rename from src/app/shared/object-list/item-list-element/entity-types/orgunit/orgunit-list-element.component.scss rename to src/app/shared/object-list/item-list-element/item-types/orgunit/orgunit-list-element.component.scss diff --git a/src/app/shared/object-list/item-list-element/entity-types/orgunit/orgunit-list-element.component.spec.ts b/src/app/shared/object-list/item-list-element/item-types/orgunit/orgunit-list-element.component.spec.ts similarity index 95% rename from src/app/shared/object-list/item-list-element/entity-types/orgunit/orgunit-list-element.component.spec.ts rename to src/app/shared/object-list/item-list-element/item-types/orgunit/orgunit-list-element.component.spec.ts index 678e1e42bc..14b86d720a 100644 --- a/src/app/shared/object-list/item-list-element/entity-types/orgunit/orgunit-list-element.component.spec.ts +++ b/src/app/shared/object-list/item-list-element/item-types/orgunit/orgunit-list-element.component.spec.ts @@ -1,11 +1,10 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; import { By } from '@angular/platform-browser'; -import { Observable } from 'rxjs'; import { Item } from '../../../../../core/shared/item.model'; import { TruncatePipe } from '../../../../utils/truncate.pipe'; 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 { of as observableOf } from 'rxjs'; diff --git a/src/app/shared/object-list/item-list-element/item-types/orgunit/orgunit-list-element.component.ts b/src/app/shared/object-list/item-list-element/item-types/orgunit/orgunit-list-element.component.ts new file mode 100644 index 0000000000..6fe95e6917 --- /dev/null +++ b/src/app/shared/object-list/item-list-element/item-types/orgunit/orgunit-list-element.component.ts @@ -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 { +} diff --git a/src/app/shared/object-list/item-list-element/entity-types/person/person-list-element.component.html b/src/app/shared/object-list/item-list-element/item-types/person/person-list-element.component.html similarity index 100% rename from src/app/shared/object-list/item-list-element/entity-types/person/person-list-element.component.html rename to src/app/shared/object-list/item-list-element/item-types/person/person-list-element.component.html diff --git a/src/app/shared/object-list/item-list-element/entity-types/person/person-list-element.component.scss b/src/app/shared/object-list/item-list-element/item-types/person/person-list-element.component.scss similarity index 100% rename from src/app/shared/object-list/item-list-element/entity-types/person/person-list-element.component.scss rename to src/app/shared/object-list/item-list-element/item-types/person/person-list-element.component.scss diff --git a/src/app/shared/object-list/item-list-element/entity-types/person/person-list-element.component.spec.ts b/src/app/shared/object-list/item-list-element/item-types/person/person-list-element.component.spec.ts similarity index 95% rename from src/app/shared/object-list/item-list-element/entity-types/person/person-list-element.component.spec.ts rename to src/app/shared/object-list/item-list-element/item-types/person/person-list-element.component.spec.ts index 3005c852af..836588c565 100644 --- a/src/app/shared/object-list/item-list-element/entity-types/person/person-list-element.component.spec.ts +++ b/src/app/shared/object-list/item-list-element/item-types/person/person-list-element.component.spec.ts @@ -1,11 +1,10 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; import { By } from '@angular/platform-browser'; -import { Observable } from 'rxjs'; import { Item } from '../../../../../core/shared/item.model'; import { TruncatePipe } from '../../../../utils/truncate.pipe'; 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 { of as observableOf } from 'rxjs'; diff --git a/src/app/shared/object-list/item-list-element/item-types/person/person-list-element.component.ts b/src/app/shared/object-list/item-list-element/item-types/person/person-list-element.component.ts new file mode 100644 index 0000000000..5fd3c63f27 --- /dev/null +++ b/src/app/shared/object-list/item-list-element/item-types/person/person-list-element.component.ts @@ -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 { +} diff --git a/src/app/shared/object-list/item-list-element/entity-types/project/project-list-element.component.html b/src/app/shared/object-list/item-list-element/item-types/project/project-list-element.component.html similarity index 100% rename from src/app/shared/object-list/item-list-element/entity-types/project/project-list-element.component.html rename to src/app/shared/object-list/item-list-element/item-types/project/project-list-element.component.html diff --git a/src/app/shared/object-list/item-list-element/entity-types/project/project-list-element.component.scss b/src/app/shared/object-list/item-list-element/item-types/project/project-list-element.component.scss similarity index 100% rename from src/app/shared/object-list/item-list-element/entity-types/project/project-list-element.component.scss rename to src/app/shared/object-list/item-list-element/item-types/project/project-list-element.component.scss diff --git a/src/app/shared/object-list/item-list-element/entity-types/project/project-list-element.component.spec.ts b/src/app/shared/object-list/item-list-element/item-types/project/project-list-element.component.spec.ts similarity index 95% rename from src/app/shared/object-list/item-list-element/entity-types/project/project-list-element.component.spec.ts rename to src/app/shared/object-list/item-list-element/item-types/project/project-list-element.component.spec.ts index b4437ceaea..cd0cce95f2 100644 --- a/src/app/shared/object-list/item-list-element/entity-types/project/project-list-element.component.spec.ts +++ b/src/app/shared/object-list/item-list-element/item-types/project/project-list-element.component.spec.ts @@ -1,11 +1,10 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; import { By } from '@angular/platform-browser'; -import { Observable } from 'rxjs'; import { Item } from '../../../../../core/shared/item.model'; import { TruncatePipe } from '../../../../utils/truncate.pipe'; 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 { of as observableOf } from 'rxjs'; diff --git a/src/app/shared/object-list/item-list-element/item-types/project/project-list-element.component.ts b/src/app/shared/object-list/item-list-element/item-types/project/project-list-element.component.ts new file mode 100644 index 0000000000..ad3cb824ea --- /dev/null +++ b/src/app/shared/object-list/item-list-element/item-types/project/project-list-element.component.ts @@ -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 { +} diff --git a/src/app/shared/object-list/item-list-element/entity-types/publication/publication-list-element.component.html b/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.html similarity index 100% rename from src/app/shared/object-list/item-list-element/entity-types/publication/publication-list-element.component.html rename to src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.html diff --git a/src/app/shared/object-list/item-list-element/entity-types/publication/publication-list-element.component.scss b/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.scss similarity index 100% rename from src/app/shared/object-list/item-list-element/entity-types/publication/publication-list-element.component.scss rename to src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.scss diff --git a/src/app/shared/object-list/item-list-element/entity-types/publication/publication-list-element.component.spec.ts b/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.spec.ts similarity index 97% rename from src/app/shared/object-list/item-list-element/entity-types/publication/publication-list-element.component.spec.ts rename to src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.spec.ts index 9a2fdbcc0b..6f596d1938 100644 --- a/src/app/shared/object-list/item-list-element/entity-types/publication/publication-list-element.component.spec.ts +++ b/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.spec.ts @@ -1,12 +1,11 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; import { By } from '@angular/platform-browser'; -import { Observable } from 'rxjs'; import { PublicationListElementComponent } from './publication-list-element.component'; import { Item } from '../../../../../core/shared/item.model'; import { TruncatePipe } from '../../../../utils/truncate.pipe'; 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'; let publicationListElementComponent: PublicationListElementComponent; diff --git a/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.ts b/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.ts new file mode 100644 index 0000000000..777cfc6013 --- /dev/null +++ b/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.ts @@ -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 { +} diff --git a/src/app/shared/object-list/search-result-list-element/item-search-result/item-search-result-list-element.component.html b/src/app/shared/object-list/search-result-list-element/item-search-result/item-search-result-list-element.component.html index 777f131a23..8cdf8cac6a 100644 --- a/src/app/shared/object-list/search-result-list-element/item-search-result/item-search-result-list-element.component.html +++ b/src/app/shared/object-list/search-result-list-element/item-search-result/item-search-result-list-element.component.html @@ -1 +1 @@ - + diff --git a/src/app/shared/object-list/search-result-list-element/item-search-result/item-search-result-list-element.component.spec.ts b/src/app/shared/object-list/search-result-list-element/item-search-result/item-search-result-list-element.component.spec.ts index b1f511868a..28fbbc419a 100644 --- a/src/app/shared/object-list/search-result-list-element/item-search-result/item-search-result-list-element.component.spec.ts +++ b/src/app/shared/object-list/search-result-list-element/item-search-result/item-search-result-list-element.component.spec.ts @@ -9,7 +9,7 @@ import { ItemSearchResultListElementComponent } from './item-search-result-list- import { By } from '@angular/platform-browser'; import { TruncatableService } from '../../../truncatable/truncatable.service'; 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'; const mockItem: Item = Object.assign(new Item(), { @@ -81,9 +81,9 @@ describe('ItemSearchResultListElementComponent', () => { fixture.detectChanges(); })); - it('should call an entity-type-switcher component and pass the item', () => { - const entityTypeSwitcher = fixture.debugElement.query(By.css('ds-entity-type-switcher')).componentInstance; - expect(entityTypeSwitcher.object).toBe(mockItem); + it('should call an item-type-switcher component and pass the item', () => { + const itemTypeSwitcher = fixture.debugElement.query(By.css('ds-item-type-switcher')).componentInstance; + expect(itemTypeSwitcher.object).toBe(mockItem); }); }); diff --git a/src/app/shared/shared.module.ts b/src/app/shared/shared.module.ts index 106b330744..410425b865 100644 --- a/src/app/shared/shared.module.ts +++ b/src/app/shared/shared.module.ts @@ -13,15 +13,15 @@ import { import { TranslateModule } from '@ngx-translate/core'; import { NgxPaginationModule } from 'ngx-pagination'; -import { EntityTypeSwitcherComponent } from './entities/switcher/entity-type-switcher.component'; -import { EntitySearchResultComponent } from './object-list/item-list-element/entity-types/entity-search-result-component'; -import { PublicationListElementComponent } from './object-list/item-list-element/entity-types/publication/publication-list-element.component'; -import { OrgUnitListElementComponent } from './object-list/item-list-element/entity-types/orgunit/orgunit-list-element.component'; -import { PersonListElementComponent } from './object-list/item-list-element/entity-types/person/person-list-element.component'; -import { ProjectListElementComponent } from './object-list/item-list-element/entity-types/project/project-list-element.component'; -import { JournalListElementComponent } from './object-list/item-list-element/entity-types/journal/journal-list-element.component'; -import { JournalVolumeListElementComponent } from './object-list/item-list-element/entity-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 { ItemTypeSwitcherComponent } from './items/switcher/item-type-switcher.component'; +import { ItemSearchResultComponent } from './object-list/item-list-element/item-types/item-search-result-component'; +import { PublicationListElementComponent } from './object-list/item-list-element/item-types/publication/publication-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/item-types/person/person-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/item-types/journal/journal-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/item-types/journal-issue/journal-issue-list-element.component'; 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 { 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 { WrapperListElementComponent } from './object-list/wrapper-list-element/wrapper-list-element.component'; import { ObjectListComponent } from './object-list/object-list.component'; @@ -167,14 +167,14 @@ const COMPONENTS = [ TruncatableComponent, TruncatablePartComponent, InputSuggestionsComponent, - EntitySearchResultComponent, - EntityTypeSwitcherComponent, + ItemSearchResultComponent, + ItemTypeSwitcherComponent, BrowseByComponent ]; const ENTRY_COMPONENTS = [ // put shared entry components (components that are created dynamically) here - EntityListElementComponent, + ItemListElementComponent, CollectionListElementComponent, CommunityListElementComponent, SearchResultListElementComponent, From 95e9e9166a1d907532584d85e9147e8137f97d24 Mon Sep 17 00:00:00 2001 From: Art Lowel Date: Wed, 16 Jan 2019 16:34:10 +0100 Subject: [PATCH 2/6] rename ItemSearchResultComponent to prevent confusion with ItemSearchResultListElementComponent --- .../journal-issue-list-element.component.ts | 4 ++-- .../journal-volume-list-element.component.ts | 4 ++-- .../journal/journal-list-element.component.ts | 4 ++-- .../orgunit/orgunit-list-element.component.ts | 4 ++-- .../person/person-list-element.component.ts | 4 ++-- .../project/project-list-element.component.ts | 4 ++-- .../publication-list-element.component.ts | 4 ++-- ...arch-result-list-element.component.spec.ts} | 18 +++++++++--------- ...em-search-result-list-element.component.ts} | 2 +- src/app/shared/shared.module.ts | 4 ++-- 10 files changed, 26 insertions(+), 26 deletions(-) rename src/app/shared/object-list/item-list-element/item-types/{item-search-result.component.spec.ts => typed-item-search-result-list-element.component.spec.ts} (78%) rename src/app/shared/object-list/item-list-element/item-types/{item-search-result-component.ts => typed-item-search-result-list-element.component.ts} (90%) diff --git a/src/app/shared/object-list/item-list-element/item-types/journal-issue/journal-issue-list-element.component.ts b/src/app/shared/object-list/item-list-element/item-types/journal-issue/journal-issue-list-element.component.ts index 3b47d1ab51..4f18822773 100644 --- a/src/app/shared/object-list/item-list-element/item-types/journal-issue/journal-issue-list-element.component.ts +++ b/src/app/shared/object-list/item-list-element/item-types/journal-issue/journal-issue-list-element.component.ts @@ -1,7 +1,7 @@ import { Component } from '@angular/core'; import { rendersItemType } from '../../../../items/item-type-decorator'; import { ElementViewMode } from '../../../../view-mode'; -import { ItemSearchResultComponent } from '../item-search-result-component'; +import { TypedItemSearchResultListElementComponent } from '../typed-item-search-result-list-element.component'; @rendersItemType('JournalIssue', ElementViewMode.SetElement) @Component({ @@ -12,5 +12,5 @@ import { ItemSearchResultComponent } from '../item-search-result-component'; /** * The component for displaying a list element for an item of the type Journal Issue */ -export class JournalIssueListElementComponent extends ItemSearchResultComponent { +export class JournalIssueListElementComponent extends TypedItemSearchResultListElementComponent { } diff --git a/src/app/shared/object-list/item-list-element/item-types/journal-volume/journal-volume-list-element.component.ts b/src/app/shared/object-list/item-list-element/item-types/journal-volume/journal-volume-list-element.component.ts index 39595122e1..a95dca88f9 100644 --- a/src/app/shared/object-list/item-list-element/item-types/journal-volume/journal-volume-list-element.component.ts +++ b/src/app/shared/object-list/item-list-element/item-types/journal-volume/journal-volume-list-element.component.ts @@ -1,7 +1,7 @@ import { Component } from '@angular/core'; import { rendersItemType } from '../../../../items/item-type-decorator'; import { ElementViewMode } from '../../../../view-mode'; -import { ItemSearchResultComponent } from '../item-search-result-component'; +import { TypedItemSearchResultListElementComponent } from '../typed-item-search-result-list-element.component'; @rendersItemType('JournalVolume', ElementViewMode.SetElement) @Component({ @@ -12,5 +12,5 @@ import { ItemSearchResultComponent } from '../item-search-result-component'; /** * The component for displaying a list element for an item of the type Journal Volume */ -export class JournalVolumeListElementComponent extends ItemSearchResultComponent { +export class JournalVolumeListElementComponent extends TypedItemSearchResultListElementComponent { } diff --git a/src/app/shared/object-list/item-list-element/item-types/journal/journal-list-element.component.ts b/src/app/shared/object-list/item-list-element/item-types/journal/journal-list-element.component.ts index 113594630e..28be0d8149 100644 --- a/src/app/shared/object-list/item-list-element/item-types/journal/journal-list-element.component.ts +++ b/src/app/shared/object-list/item-list-element/item-types/journal/journal-list-element.component.ts @@ -1,7 +1,7 @@ import { Component } from '@angular/core'; import { rendersItemType } from '../../../../items/item-type-decorator'; import { ElementViewMode } from '../../../../view-mode'; -import { ItemSearchResultComponent } from '../item-search-result-component'; +import { TypedItemSearchResultListElementComponent } from '../typed-item-search-result-list-element.component'; @rendersItemType('Journal', ElementViewMode.SetElement) @Component({ @@ -12,5 +12,5 @@ import { ItemSearchResultComponent } from '../item-search-result-component'; /** * The component for displaying a list element for an item of the type Journal */ -export class JournalListElementComponent extends ItemSearchResultComponent { +export class JournalListElementComponent extends TypedItemSearchResultListElementComponent { } diff --git a/src/app/shared/object-list/item-list-element/item-types/orgunit/orgunit-list-element.component.ts b/src/app/shared/object-list/item-list-element/item-types/orgunit/orgunit-list-element.component.ts index 6fe95e6917..e3433f7e76 100644 --- a/src/app/shared/object-list/item-list-element/item-types/orgunit/orgunit-list-element.component.ts +++ b/src/app/shared/object-list/item-list-element/item-types/orgunit/orgunit-list-element.component.ts @@ -1,7 +1,7 @@ import { Component } from '@angular/core'; import { rendersItemType } from '../../../../items/item-type-decorator'; import { ElementViewMode } from '../../../../view-mode'; -import { ItemSearchResultComponent } from '../item-search-result-component'; +import { TypedItemSearchResultListElementComponent } from '../typed-item-search-result-list-element.component'; @rendersItemType('OrgUnit', ElementViewMode.SetElement) @Component({ @@ -12,5 +12,5 @@ import { ItemSearchResultComponent } from '../item-search-result-component'; /** * The component for displaying a list element for an item of the type Organisation Unit */ -export class OrgUnitListElementComponent extends ItemSearchResultComponent { +export class OrgUnitListElementComponent extends TypedItemSearchResultListElementComponent { } diff --git a/src/app/shared/object-list/item-list-element/item-types/person/person-list-element.component.ts b/src/app/shared/object-list/item-list-element/item-types/person/person-list-element.component.ts index 5fd3c63f27..b0369458f9 100644 --- a/src/app/shared/object-list/item-list-element/item-types/person/person-list-element.component.ts +++ b/src/app/shared/object-list/item-list-element/item-types/person/person-list-element.component.ts @@ -1,7 +1,7 @@ import { Component } from '@angular/core'; import { rendersItemType } from '../../../../items/item-type-decorator'; import { ElementViewMode } from '../../../../view-mode'; -import { ItemSearchResultComponent } from '../item-search-result-component'; +import { TypedItemSearchResultListElementComponent } from '../typed-item-search-result-list-element.component'; @rendersItemType('Person', ElementViewMode.SetElement) @Component({ @@ -12,5 +12,5 @@ import { ItemSearchResultComponent } from '../item-search-result-component'; /** * The component for displaying a list element for an item of the type Person */ -export class PersonListElementComponent extends ItemSearchResultComponent { +export class PersonListElementComponent extends TypedItemSearchResultListElementComponent { } diff --git a/src/app/shared/object-list/item-list-element/item-types/project/project-list-element.component.ts b/src/app/shared/object-list/item-list-element/item-types/project/project-list-element.component.ts index ad3cb824ea..6b130e4786 100644 --- a/src/app/shared/object-list/item-list-element/item-types/project/project-list-element.component.ts +++ b/src/app/shared/object-list/item-list-element/item-types/project/project-list-element.component.ts @@ -1,7 +1,7 @@ import { Component } from '@angular/core'; import { rendersItemType } from '../../../../items/item-type-decorator'; import { ElementViewMode } from '../../../../view-mode'; -import { ItemSearchResultComponent } from '../item-search-result-component'; +import { TypedItemSearchResultListElementComponent } from '../typed-item-search-result-list-element.component'; @rendersItemType('Project', ElementViewMode.SetElement) @Component({ @@ -12,5 +12,5 @@ import { ItemSearchResultComponent } from '../item-search-result-component'; /** * The component for displaying a list element for an item of the type Project */ -export class ProjectListElementComponent extends ItemSearchResultComponent { +export class ProjectListElementComponent extends TypedItemSearchResultListElementComponent { } diff --git a/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.ts b/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.ts index 777cfc6013..4575ab5cca 100644 --- a/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.ts +++ b/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.ts @@ -1,7 +1,7 @@ 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'; +import { TypedItemSearchResultListElementComponent } from '../typed-item-search-result-list-element.component'; @rendersItemType('Publication', ElementViewMode.SetElement) @rendersItemType(DEFAULT_ITEM_TYPE, ElementViewMode.SetElement) @@ -13,5 +13,5 @@ import { ItemSearchResultComponent } from '../item-search-result-component'; /** * The component for displaying a list element for an item of the type Publication */ -export class PublicationListElementComponent extends ItemSearchResultComponent { +export class PublicationListElementComponent extends TypedItemSearchResultListElementComponent { } diff --git a/src/app/shared/object-list/item-list-element/item-types/item-search-result.component.spec.ts b/src/app/shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component.spec.ts similarity index 78% rename from src/app/shared/object-list/item-list-element/item-types/item-search-result.component.spec.ts rename to src/app/shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component.spec.ts index be163f7a6c..e97f632033 100644 --- a/src/app/shared/object-list/item-list-element/item-types/item-search-result.component.spec.ts +++ b/src/app/shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component.spec.ts @@ -2,7 +2,7 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { TruncatePipe } from '../../../utils/truncate.pipe'; import { TruncatableService } from '../../../truncatable/truncatable.service'; import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; -import { ItemSearchResultComponent } from './item-search-result-component'; +import { TypedItemSearchResultListElementComponent } from './typed-item-search-result-list-element.component'; import { Item } from '../../../../core/shared/item.model'; import { RemoteData } from '../../../../core/data/remote-data'; import { PaginatedList } from '../../../../core/data/paginated-list'; @@ -23,26 +23,26 @@ const mockSearchResult = { } as ItemSearchResult; describe('ItemSearchResultComponent', () => { - let comp: ItemSearchResultComponent; - let fixture: ComponentFixture; + let comp: TypedItemSearchResultListElementComponent; + let fixture: ComponentFixture; describe('when injecting an Item', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ItemSearchResultComponent, TruncatePipe], + declarations: [TypedItemSearchResultListElementComponent, TruncatePipe], providers: [ {provide: TruncatableService, useValue: {}}, {provide: ITEM, useValue: mockItem} ], schemas: [NO_ERRORS_SCHEMA] - }).overrideComponent(ItemSearchResultComponent, { + }).overrideComponent(TypedItemSearchResultListElementComponent, { set: {changeDetection: ChangeDetectionStrategy.Default} }).compileComponents(); })); beforeEach(async(() => { - fixture = TestBed.createComponent(ItemSearchResultComponent); + fixture = TestBed.createComponent(TypedItemSearchResultListElementComponent); comp = fixture.componentInstance; })); @@ -56,20 +56,20 @@ describe('ItemSearchResultComponent', () => { describe('when injecting an ItemSearchResult', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ItemSearchResultComponent, TruncatePipe], + declarations: [TypedItemSearchResultListElementComponent, TruncatePipe], providers: [ {provide: TruncatableService, useValue: {}}, {provide: ITEM, useValue: mockSearchResult} ], schemas: [NO_ERRORS_SCHEMA] - }).overrideComponent(ItemSearchResultComponent, { + }).overrideComponent(TypedItemSearchResultListElementComponent, { set: {changeDetection: ChangeDetectionStrategy.Default} }).compileComponents(); })); beforeEach(async(() => { - fixture = TestBed.createComponent(ItemSearchResultComponent); + fixture = TestBed.createComponent(TypedItemSearchResultListElementComponent); comp = fixture.componentInstance; })); diff --git a/src/app/shared/object-list/item-list-element/item-types/item-search-result-component.ts b/src/app/shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component.ts similarity index 90% rename from src/app/shared/object-list/item-list-element/item-types/item-search-result-component.ts rename to src/app/shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component.ts index 17e7b7f173..57b339da53 100644 --- a/src/app/shared/object-list/item-list-element/item-types/item-search-result-component.ts +++ b/src/app/shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component.ts @@ -13,7 +13,7 @@ import { SearchResultListElementComponent } from '../../search-result-list-eleme selector: 'ds-item-search-result', template: '' }) -export class ItemSearchResultComponent extends SearchResultListElementComponent { +export class TypedItemSearchResultListElementComponent extends SearchResultListElementComponent { item: Item; constructor( diff --git a/src/app/shared/shared.module.ts b/src/app/shared/shared.module.ts index 410425b865..e467839b57 100644 --- a/src/app/shared/shared.module.ts +++ b/src/app/shared/shared.module.ts @@ -14,7 +14,7 @@ import { TranslateModule } from '@ngx-translate/core'; import { NgxPaginationModule } from 'ngx-pagination'; import { ItemTypeSwitcherComponent } from './items/switcher/item-type-switcher.component'; -import { ItemSearchResultComponent } from './object-list/item-list-element/item-types/item-search-result-component'; +import { TypedItemSearchResultListElementComponent } from './object-list/item-list-element/item-types/typed-item-search-result-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/item-types/orgunit/orgunit-list-element.component'; import { PersonListElementComponent } from './object-list/item-list-element/item-types/person/person-list-element.component'; @@ -167,7 +167,7 @@ const COMPONENTS = [ TruncatableComponent, TruncatablePartComponent, InputSuggestionsComponent, - ItemSearchResultComponent, + TypedItemSearchResultListElementComponent, ItemTypeSwitcherComponent, BrowseByComponent ]; From 8ae8498ab115d66035e4c9ba7b551fd4979f0ead Mon Sep 17 00:00:00 2001 From: Art Lowel Date: Wed, 16 Jan 2019 17:47:53 +0100 Subject: [PATCH 3/6] rename 'entity' to 'item' in en.json --- resources/i18n/en.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/i18n/en.json b/resources/i18n/en.json index 667d5132ba..e3126b16b8 100644 --- a/resources/i18n/en.json +++ b/resources/i18n/en.json @@ -207,7 +207,7 @@ "f.dateIssued.max": "End date", "f.subject": "Subject", "f.has_content_in_original_bundle": "Has files", - "f.entityType": "Entity Type" + "f.entityType": "Item Type" }, "filter": { "show-more": "Show more", @@ -237,8 +237,8 @@ "head": "Has files" }, "entityType": { - "placeholder": "Entity Type", - "head": "Entity Type" + "placeholder": "Item Type", + "head": "Item Type" } } } From 57999ad3822e44746895702189efa073f4243b01 Mon Sep 17 00:00:00 2001 From: Art Lowel Date: Mon, 21 Jan 2019 18:27:07 +0100 Subject: [PATCH 4/6] add the ability to mix text based metadata fields, authority controlled fields and typed items in the same section --- resources/i18n/en.json | 6 +- .../metadata-values.component.spec.ts | 3 +- src/app/+item-page/item-page.module.ts | 4 +- .../simple/item-page.component.html | 2 +- .../+item-page/simple/item-page.component.ts | 5 +- .../journal-issue/journal-issue.component.ts | 4 +- .../journal-volume.component.ts | 4 +- .../item-types/journal/journal.component.ts | 4 +- .../item-types/orgunit/orgunit.component.ts | 4 +- .../item-types/person/person.component.ts | 4 +- .../item-types/project/project.component.ts | 4 +- .../publication/publication.component.html | 8 +- .../publication/publication.component.ts | 14 +- .../item-types/shared/item.component.spec.ts | 124 +++++++++++++++++- .../item-types/shared/item.component.ts | 67 +++++++++- ...etadata-representation-list.component.html | 5 + ...data-representation-list.component.spec.ts | 40 ++++++ .../metadata-representation-list.component.ts | 31 +++++ .../related-items/related-items-component.ts | 5 +- .../related-items.component.html | 2 +- .../core/metadata/metadata.service.spec.ts | 3 +- src/app/core/shared/dspace-object.model.ts | 21 ++- ...item-metadata-representation.model.spec.ts | 36 +++++ .../item-metadata-representation.model.ts | 48 +++++++ .../metadata-representation.model.ts | 31 +++++ .../metadatum-representation.model.spec.ts | 54 ++++++++ .../metadatum-representation.model.ts | 38 ++++++ src/app/core/shared/metadatum.model.ts | 13 ++ src/app/shared/items/item-type-decorator.ts | 48 +++++-- .../item-type-switcher.component.spec.ts | 41 +++++- .../switcher/item-type-switcher.component.ts | 13 +- .../item-list-element.component.html | 2 +- .../item-list-element.component.ts | 4 +- .../journal-issue-list-element.component.ts | 4 +- .../journal-volume-list-element.component.ts | 4 +- .../journal/journal-list-element.component.ts | 4 +- .../orgunit/orgunit-list-element.component.ts | 4 +- .../person/person-list-element.component.html | 1 - .../person/person-list-element.component.ts | 4 +- ...erson-metadata-list-element.component.html | 15 +++ .../person-metadata-list-element.component.ts | 16 +++ .../project/project-list-element.component.ts | 4 +- .../publication-list-element.component.ts | 6 +- .../item-metadata-list-element.component.html | 2 + ...em-metadata-list-element.component.spec.ts | 38 ++++++ .../item-metadata-list-element.component.ts | 25 ++++ ...a-representation-list-element.component.ts | 15 +++ ...-text-metadata-list-element.component.html | 3 + ...xt-metadata-list-element.component.spec.ts | 39 ++++++ ...in-text-metadata-list-element.component.ts | 19 +++ ...-search-result-list-element.component.html | 2 +- ...em-search-result-list-element.component.ts | 4 +- src/app/shared/shared.module.ts | 18 ++- src/app/shared/view-mode.ts | 12 +- 54 files changed, 833 insertions(+), 98 deletions(-) create mode 100644 src/app/+item-page/simple/metadata-representation-list/metadata-representation-list.component.html create mode 100644 src/app/+item-page/simple/metadata-representation-list/metadata-representation-list.component.spec.ts create mode 100644 src/app/+item-page/simple/metadata-representation-list/metadata-representation-list.component.ts create mode 100644 src/app/core/shared/metadata-representation/item/item-metadata-representation.model.spec.ts create mode 100644 src/app/core/shared/metadata-representation/item/item-metadata-representation.model.ts create mode 100644 src/app/core/shared/metadata-representation/metadata-representation.model.ts create mode 100644 src/app/core/shared/metadata-representation/metadatum/metadatum-representation.model.spec.ts create mode 100644 src/app/core/shared/metadata-representation/metadatum/metadatum-representation.model.ts create mode 100644 src/app/shared/object-list/item-list-element/item-types/person/person-metadata-list-element.component.html create mode 100644 src/app/shared/object-list/item-list-element/item-types/person/person-metadata-list-element.component.ts create mode 100644 src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.html create mode 100644 src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.spec.ts create mode 100644 src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.ts create mode 100644 src/app/shared/object-list/metadata-representation-list-element/metadata-representation-list-element.component.ts create mode 100644 src/app/shared/object-list/metadata-representation-list-element/plain-text/plain-text-metadata-list-element.component.html create mode 100644 src/app/shared/object-list/metadata-representation-list-element/plain-text/plain-text-metadata-list-element.component.spec.ts create mode 100644 src/app/shared/object-list/metadata-representation-list-element/plain-text/plain-text-metadata-list-element.component.ts diff --git a/resources/i18n/en.json b/resources/i18n/en.json index e3126b16b8..667d5132ba 100644 --- a/resources/i18n/en.json +++ b/resources/i18n/en.json @@ -207,7 +207,7 @@ "f.dateIssued.max": "End date", "f.subject": "Subject", "f.has_content_in_original_bundle": "Has files", - "f.entityType": "Item Type" + "f.entityType": "Entity Type" }, "filter": { "show-more": "Show more", @@ -237,8 +237,8 @@ "head": "Has files" }, "entityType": { - "placeholder": "Item Type", - "head": "Item Type" + "placeholder": "Entity Type", + "head": "Entity Type" } } } diff --git a/src/app/+item-page/field-components/metadata-values/metadata-values.component.spec.ts b/src/app/+item-page/field-components/metadata-values/metadata-values.component.spec.ts index 9447e1c48e..9682386b96 100644 --- a/src/app/+item-page/field-components/metadata-values/metadata-values.component.spec.ts +++ b/src/app/+item-page/field-components/metadata-values/metadata-values.component.spec.ts @@ -4,6 +4,7 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { MockTranslateLoader } from '../../../shared/mocks/mock-translate-loader'; import { MetadataValuesComponent } from './metadata-values.component'; import { By } from '@angular/platform-browser'; +import { Metadatum } from '../../../core/shared/metadatum.model'; let comp: MetadataValuesComponent; let fixture: ComponentFixture; @@ -23,7 +24,7 @@ const mockMetadata = [ key: 'journal.identifier.description', language: 'en_US', value: 'desc' - }]; + }] as Metadatum[]; const mockSeperator = '
'; const mockLabel = 'fake.message'; diff --git a/src/app/+item-page/item-page.module.ts b/src/app/+item-page/item-page.module.ts index b4e5ba1cd8..41d78f6393 100644 --- a/src/app/+item-page/item-page.module.ts +++ b/src/app/+item-page/item-page.module.ts @@ -29,6 +29,7 @@ import { JournalComponent } from './simple/item-types/journal/journal.component' import { JournalVolumeComponent } from './simple/item-types/journal-volume/journal-volume.component'; import { JournalIssueComponent } from './simple/item-types/journal-issue/journal-issue.component'; import { ItemComponent } from './simple/item-types/shared/item.component'; +import { MetadataRepresentationListComponent } from './simple/metadata-representation-list/metadata-representation-list.component'; @NgModule({ imports: [ @@ -61,7 +62,8 @@ import { ItemComponent } from './simple/item-types/shared/item.component'; GenericItemPageFieldComponent, JournalComponent, JournalIssueComponent, - JournalVolumeComponent + JournalVolumeComponent, + MetadataRepresentationListComponent ], entryComponents: [ PublicationComponent, diff --git a/src/app/+item-page/simple/item-page.component.html b/src/app/+item-page/simple/item-page.component.html index e59d37fb9d..b6de496dc4 100644 --- a/src/app/+item-page/simple/item-page.component.html +++ b/src/app/+item-page/simple/item-page.component.html @@ -1,7 +1,7 @@
- +
diff --git a/src/app/+item-page/simple/item-page.component.ts b/src/app/+item-page/simple/item-page.component.ts index 1cee863070..ac23add738 100644 --- a/src/app/+item-page/simple/item-page.component.ts +++ b/src/app/+item-page/simple/item-page.component.ts @@ -15,6 +15,8 @@ import { fadeInOut } from '../../shared/animations/fade'; import { hasValue } from '../../shared/empty.util'; import * as viewMode from '../../shared/view-mode'; +export const VIEW_MODE_FULL = 'full'; + /** * This component renders a simple item page. * The route parameter 'id' is used to request the item it represents. @@ -46,9 +48,8 @@ export class ItemPageComponent implements OnInit { /** * The view-mode we're currently on - * @type {ElementViewMode} */ - ElementViewMode = viewMode.ElementViewMode; + viewMode = VIEW_MODE_FULL; constructor( private route: ActivatedRoute, diff --git a/src/app/+item-page/simple/item-types/journal-issue/journal-issue.component.ts b/src/app/+item-page/simple/item-types/journal-issue/journal-issue.component.ts index c663b15256..9240616c59 100644 --- a/src/app/+item-page/simple/item-types/journal-issue/journal-issue.component.ts +++ b/src/app/+item-page/simple/item-types/journal-issue/journal-issue.component.ts @@ -4,11 +4,11 @@ import { ItemDataService } from '../../../../core/data/item-data.service'; import { Item } from '../../../../core/shared/item.model'; import { rendersItemType } from '../../../../shared/items/item-type-decorator'; import { ITEM } from '../../../../shared/items/switcher/item-type-switcher.component'; -import { ElementViewMode } from '../../../../shared/view-mode'; import { isNotEmpty } from '../../../../shared/empty.util'; import { ItemComponent, filterRelationsByTypeLabel, relationsToItems } from '../shared/item.component'; +import { VIEW_MODE_FULL } from '../../item-page.component'; -@rendersItemType('JournalIssue', ElementViewMode.Full) +@rendersItemType('JournalIssue', VIEW_MODE_FULL) @Component({ selector: 'ds-journal-issue', styleUrls: ['./journal-issue.component.scss'], diff --git a/src/app/+item-page/simple/item-types/journal-volume/journal-volume.component.ts b/src/app/+item-page/simple/item-types/journal-volume/journal-volume.component.ts index ebb6919234..0372fe5d30 100644 --- a/src/app/+item-page/simple/item-types/journal-volume/journal-volume.component.ts +++ b/src/app/+item-page/simple/item-types/journal-volume/journal-volume.component.ts @@ -4,11 +4,11 @@ import { ItemDataService } from '../../../../core/data/item-data.service'; import { Item } from '../../../../core/shared/item.model'; import { rendersItemType } from '../../../../shared/items/item-type-decorator'; import { ITEM } from '../../../../shared/items/switcher/item-type-switcher.component'; -import { ElementViewMode } from '../../../../shared/view-mode'; import { isNotEmpty } from '../../../../shared/empty.util'; import { ItemComponent, filterRelationsByTypeLabel, relationsToItems } from '../shared/item.component'; +import { VIEW_MODE_FULL } from '../../item-page.component'; -@rendersItemType('JournalVolume', ElementViewMode.Full) +@rendersItemType('JournalVolume', VIEW_MODE_FULL) @Component({ selector: 'ds-journal-volume', styleUrls: ['./journal-volume.component.scss'], diff --git a/src/app/+item-page/simple/item-types/journal/journal.component.ts b/src/app/+item-page/simple/item-types/journal/journal.component.ts index 3af725062c..12ba91eb6b 100644 --- a/src/app/+item-page/simple/item-types/journal/journal.component.ts +++ b/src/app/+item-page/simple/item-types/journal/journal.component.ts @@ -4,11 +4,11 @@ import { ItemDataService } from '../../../../core/data/item-data.service'; import { Item } from '../../../../core/shared/item.model'; import { rendersItemType } from '../../../../shared/items/item-type-decorator'; import { ITEM } from '../../../../shared/items/switcher/item-type-switcher.component'; -import { ElementViewMode } from '../../../../shared/view-mode'; import { isNotEmpty } from '../../../../shared/empty.util'; import { ItemComponent, filterRelationsByTypeLabel, relationsToItems } from '../shared/item.component'; +import { VIEW_MODE_FULL } from '../../item-page.component'; -@rendersItemType('Journal', ElementViewMode.Full) +@rendersItemType('Journal', VIEW_MODE_FULL) @Component({ selector: 'ds-journal', styleUrls: ['./journal.component.scss'], diff --git a/src/app/+item-page/simple/item-types/orgunit/orgunit.component.ts b/src/app/+item-page/simple/item-types/orgunit/orgunit.component.ts index f1979b0961..1a6ab4ba36 100644 --- a/src/app/+item-page/simple/item-types/orgunit/orgunit.component.ts +++ b/src/app/+item-page/simple/item-types/orgunit/orgunit.component.ts @@ -3,12 +3,12 @@ import { Observable } from 'rxjs'; import { ItemDataService } from '../../../../core/data/item-data.service'; import { Item } from '../../../../core/shared/item.model'; import { rendersItemType } from '../../../../shared/items/item-type-decorator'; -import { ElementViewMode } from '../../../../shared/view-mode'; import { ITEM } from '../../../../shared/items/switcher/item-type-switcher.component'; import { isNotEmpty } from '../../../../shared/empty.util'; import { ItemComponent, filterRelationsByTypeLabel, relationsToItems } from '../shared/item.component'; +import { VIEW_MODE_FULL } from '../../item-page.component'; -@rendersItemType('OrgUnit', ElementViewMode.Full) +@rendersItemType('OrgUnit', VIEW_MODE_FULL) @Component({ selector: 'ds-orgunit', styleUrls: ['./orgunit.component.scss'], diff --git a/src/app/+item-page/simple/item-types/person/person.component.ts b/src/app/+item-page/simple/item-types/person/person.component.ts index bb98799da5..3cf5a230bf 100644 --- a/src/app/+item-page/simple/item-types/person/person.component.ts +++ b/src/app/+item-page/simple/item-types/person/person.component.ts @@ -4,12 +4,12 @@ import { ItemDataService } from '../../../../core/data/item-data.service'; import { Item } from '../../../../core/shared/item.model'; import { rendersItemType } from '../../../../shared/items/item-type-decorator'; import { ITEM } from '../../../../shared/items/switcher/item-type-switcher.component'; -import { ElementViewMode } from '../../../../shared/view-mode'; import { SearchFixedFilterService } from '../../../../+search-page/search-filters/search-filter/search-fixed-filter.service'; import { isNotEmpty } from '../../../../shared/empty.util'; import { ItemComponent, filterRelationsByTypeLabel, relationsToItems } from '../shared/item.component'; +import { VIEW_MODE_FULL } from '../../item-page.component'; -@rendersItemType('Person', ElementViewMode.Full) +@rendersItemType('Person', VIEW_MODE_FULL) @Component({ selector: 'ds-person', styleUrls: ['./person.component.scss'], diff --git a/src/app/+item-page/simple/item-types/project/project.component.ts b/src/app/+item-page/simple/item-types/project/project.component.ts index dfbdacff86..4bdb6012f2 100644 --- a/src/app/+item-page/simple/item-types/project/project.component.ts +++ b/src/app/+item-page/simple/item-types/project/project.component.ts @@ -3,12 +3,12 @@ import { Observable } from 'rxjs'; import { ItemDataService } from '../../../../core/data/item-data.service'; import { Item } from '../../../../core/shared/item.model'; import { rendersItemType } from '../../../../shared/items/item-type-decorator'; -import { ElementViewMode } from '../../../../shared/view-mode'; import { ITEM } from '../../../../shared/items/switcher/item-type-switcher.component'; import { isNotEmpty } from '../../../../shared/empty.util'; import { ItemComponent, filterRelationsByTypeLabel, relationsToItems } from '../shared/item.component'; +import { VIEW_MODE_FULL } from '../../item-page.component'; -@rendersItemType('Project', ElementViewMode.Full) +@rendersItemType('Project', VIEW_MODE_FULL) @Component({ selector: 'ds-project', styleUrls: ['./project.component.scss'], diff --git a/src/app/+item-page/simple/item-types/publication/publication.component.html b/src/app/+item-page/simple/item-types/publication/publication.component.html index e619e18b01..b1259be689 100644 --- a/src/app/+item-page/simple/item-types/publication/publication.component.html +++ b/src/app/+item-page/simple/item-types/publication/publication.component.html @@ -9,10 +9,10 @@
- - + + diff --git a/src/app/+item-page/simple/item-types/publication/publication.component.ts b/src/app/+item-page/simple/item-types/publication/publication.component.ts index b6178893d6..1ea50598c7 100644 --- a/src/app/+item-page/simple/item-types/publication/publication.component.ts +++ b/src/app/+item-page/simple/item-types/publication/publication.component.ts @@ -7,11 +7,12 @@ import { rendersItemType } from '../../../../shared/items/item-type-decorator'; import { ITEM } from '../../../../shared/items/switcher/item-type-switcher.component'; -import { ElementViewMode } from '../../../../shared/view-mode'; import { ItemComponent, filterRelationsByTypeLabel, relationsToItems } from '../shared/item.component'; +import { MetadataRepresentation } from '../../../../core/shared/metadata-representation/metadata-representation.model'; +import { VIEW_MODE_FULL } from '../../item-page.component'; -@rendersItemType('Publication', ElementViewMode.Full) -@rendersItemType(DEFAULT_ITEM_TYPE, ElementViewMode.Full) +@rendersItemType('Publication', VIEW_MODE_FULL) +@rendersItemType(DEFAULT_ITEM_TYPE, VIEW_MODE_FULL) @Component({ selector: 'ds-publication', styleUrls: ['./publication.component.scss'], @@ -22,7 +23,7 @@ export class PublicationComponent extends ItemComponent implements OnInit { /** * The authors related to this publication */ - authors$: Observable; + authors$: Observable; /** * The projects related to this publication @@ -51,10 +52,7 @@ export class PublicationComponent extends ItemComponent implements OnInit { if (this.resolvedRelsAndTypes$) { - this.authors$ = this.resolvedRelsAndTypes$.pipe( - filterRelationsByTypeLabel('isAuthorOfPublication'), - relationsToItems(this.item.id, this.ids) - ); + this.authors$ = this.buildRepresentations('Person', 'dc.contributor.author', this.ids); this.projects$ = this.resolvedRelsAndTypes$.pipe( filterRelationsByTypeLabel('isProjectOfPublication'), diff --git a/src/app/+item-page/simple/item-types/shared/item.component.spec.ts b/src/app/+item-page/simple/item-types/shared/item.component.spec.ts index 30f39957db..8c6cf15ee9 100644 --- a/src/app/+item-page/simple/item-types/shared/item.component.spec.ts +++ b/src/app/+item-page/simple/item-types/shared/item.component.spec.ts @@ -16,8 +16,18 @@ import { PaginatedList } from '../../../../core/data/paginated-list'; import { RemoteData } from '../../../../core/data/remote-data'; import { Relationship } from '../../../../core/shared/item-relationships/relationship.model'; import { PageInfo } from '../../../../core/shared/page-info.model'; -import { compareArraysUsing, compareArraysUsingIds } from './item.component'; +import { compareArraysUsing, compareArraysUsingIds, ItemComponent } from './item.component'; import { of as observableOf } from 'rxjs'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; +import { ItemPageComponent } from '../../item-page.component'; +import { VarDirective } from '../../../../shared/utils/var.directive'; +import { ActivatedRoute } from '@angular/router'; +import { MetadataService } from '../../../../core/metadata/metadata.service'; +import { of } from 'rxjs/internal/observable/of'; +import { Observable } from 'rxjs/internal/Observable'; +import { MetadataRepresentation } from '../../../../core/shared/metadata-representation/metadata-representation.model'; +import { MetadatumRepresentation } from '../../../../core/shared/metadata-representation/metadatum/metadatum-representation.model'; +import { ItemMetadataRepresentation } from '../../../../core/shared/metadata-representation/item/item-metadata-representation.model'; /** * Create a generic test for an item-page-fields component using a mockItem and the type of component @@ -306,4 +316,116 @@ describe('ItemComponent', () => { }); }); + describe('when calling buildRepresentations', () => { + let comp: ItemComponent; + let fixture: ComponentFixture; + + const metadataField = 'dc.contributor.author'; + const mockItem = Object.assign(new Item(), { + id: '1', + uuid: '1', + metadata: [ + { + key: metadataField, + value: 'Second value', + place: 1 + }, + { + key: metadataField, + value: 'Third value', + place: 2, + authority: 'virtual::123' + }, + { + key: metadataField, + value: 'First value', + place: 0 + }, + { + key: metadataField, + value: 'Fourth value', + place: 3, + authority: '123' + } + ], + relationships: observableOf(new RemoteData(false, false, true, null, new PaginatedList(new PageInfo(), [ + Object.assign(new Relationship(), { + uuid: '123', + id: '123', + leftId: '1', + rightId: '2', + relationshipType: observableOf(new RemoteData(false, false, true, null, new RelationshipType())) + }) + ]))) + }); + const relatedItem = Object.assign(new Item(), { + id: '2', + metadata: [ + { + key: 'dc.title', + value: 'related item' + } + ] + }); + const mockItemDataService = { + findById: (id) => { + if (id === relatedItem.id) { + return observableOf(new RemoteData(false, false, true, null, relatedItem)) + } + } + } as ItemDataService; + + let representations: Observable; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [TranslateModule.forRoot({ + loader: { + provide: TranslateLoader, + useClass: MockTranslateLoader + } + }), BrowserAnimationsModule], + declarations: [ItemComponent, VarDirective], + providers: [ + {provide: ITEM, useValue: mockItem} + ], + + schemas: [NO_ERRORS_SCHEMA] + }).overrideComponent(ItemComponent, { + set: {changeDetection: ChangeDetectionStrategy.Default} + }).compileComponents(); + })); + + beforeEach(async(() => { + fixture = TestBed.createComponent(ItemComponent); + comp = fixture.componentInstance; + fixture.detectChanges(); + representations = comp.buildRepresentations('bogus', metadataField, mockItemDataService); + })); + + it('should contain exactly 4 metadata-representations', () => { + representations.subscribe((reps: MetadataRepresentation[]) => { + expect(reps.length).toEqual(4); + }); + }); + + it('should have all the representations in the correct order', () => { + representations.subscribe((reps: MetadataRepresentation[]) => { + expect(reps[0].getPrimaryValue()).toEqual('First value'); + expect(reps[1].getPrimaryValue()).toEqual('Second value'); + expect(reps[2].getPrimaryValue()).toEqual('related item'); + expect(reps[3].getPrimaryValue()).toEqual('Fourth value'); + }); + }); + + it('should have created the correct MetadatumRepresentation and ItemMetadataRepresentation objects for the correct Metadata', () => { + representations.subscribe((reps: MetadataRepresentation[]) => { + expect(reps[0] instanceof MetadatumRepresentation).toEqual(true); + expect(reps[1] instanceof MetadatumRepresentation).toEqual(true); + expect(reps[2] instanceof ItemMetadataRepresentation).toEqual(true); + expect(reps[3] instanceof MetadatumRepresentation).toEqual(true); + }); + }); + }) + }); diff --git a/src/app/+item-page/simple/item-types/shared/item.component.ts b/src/app/+item-page/simple/item-types/shared/item.component.ts index 5527114ec3..c5aae65f13 100644 --- a/src/app/+item-page/simple/item-types/shared/item.component.ts +++ b/src/app/+item-page/simple/item-types/shared/item.component.ts @@ -7,9 +7,14 @@ import { RemoteData } from '../../../../core/data/remote-data'; import { RelationshipType } from '../../../../core/shared/item-relationships/relationship-type.model'; import { Relationship } from '../../../../core/shared/item-relationships/relationship.model'; import { Item } from '../../../../core/shared/item.model'; -import { getRemoteDataPayload } from '../../../../core/shared/operators'; -import { hasValue } from '../../../../shared/empty.util'; +import { getRemoteDataPayload, getSucceededRemoteData } from '../../../../core/shared/operators'; +import { hasNoValue, hasValue } from '../../../../shared/empty.util'; import { ITEM } from '../../../../shared/items/switcher/item-type-switcher.component'; +import { MetadataRepresentation } from '../../../../core/shared/metadata-representation/metadata-representation.model'; +import { ItemMetadataRepresentation } from '../../../../core/shared/metadata-representation/item/item-metadata-representation.model'; +import { Metadatum } from '../../../../core/shared/metadatum.model'; +import { MetadatumRepresentation } from '../../../../core/shared/metadata-representation/metadatum/metadatum-representation.model'; +import { of } from 'rxjs/internal/observable/of'; /** * Operator for comparing arrays using a mapping function @@ -82,6 +87,41 @@ export const relationsToItems = (thisId: string, ids: ItemDataService) => distinctUntilChanged(compareArraysUsingIds()), ); +/** + * Operator for turning a list of relationships into a list of metadatarepresentations given the original metadata + * @param thisId The id of the parent item + * @param itemType The type of relation this list resembles (for creating representations) + * @param metadata The list of original Metadatum objects + * @param ids The ItemDataService to use for fetching Items from the Rest API + */ +export const relationsToRepresentations = (thisId: string, itemType: string, metadata: Metadatum[], ids: ItemDataService) => + (source: Observable): Observable => + source.pipe( + flatMap((rels: Relationship[]) => + observableZip( + ...metadata.map((metadatum: Metadatum) => { + const prefix = 'virtual::'; + if (hasValue(metadatum.authority) && metadatum.authority.startsWith(prefix)) { + const matchingRels = rels.filter((rel: Relationship) => ('' + rel.id) === metadatum.authority.substring(metadatum.authority.indexOf(prefix) + prefix.length)); + if (matchingRels.length > 0) { + const matchingRel = matchingRels[0]; + let queryId = matchingRel.leftId; + if (matchingRel.leftId === thisId) { + queryId = matchingRel.rightId; + } + return ids.findById(queryId).pipe( + getSucceededRemoteData(), + map((d: RemoteData) => Object.assign(new ItemMetadataRepresentation(itemType), d.payload)) + ); + } + } else { + return of(Object.assign(new MetadatumRepresentation(itemType), metadatum)); + } + }) + ) + ) + ); + @Component({ selector: 'ds-item', template: '' @@ -93,7 +133,7 @@ export class ItemComponent implements OnInit { /** * Resolved relationships and types together in one observable */ - resolvedRelsAndTypes$: Observable<[Relationship[], RelationshipType[]]> + resolvedRelsAndTypes$: Observable<[Relationship[], RelationshipType[]]>; constructor( @Inject(ITEM) public item: Item @@ -125,4 +165,25 @@ export class ItemComponent implements OnInit { } } + /** + * Build a list of MetadataRepresentations for the current item. This combines all metadata and relationships of a + * certain type. + * @param itemType The type of item we're building representations of. Used for matching templates. + * @param metadataField The metadata field that resembles the item type. + * @param itemDataService ItemDataService to turn relations into items. + */ + buildRepresentations(itemType: string, metadataField: string, itemDataService: ItemDataService): Observable { + const metadata = this.item.findMetadataSortedByPlace(metadataField); + const relsCurrentPage$ = this.item.relationships.pipe( + getSucceededRemoteData(), + getRemoteDataPayload(), + map((pl: PaginatedList) => pl.page), + distinctUntilChanged(compareArraysUsingIds()) + ); + + return relsCurrentPage$.pipe( + relationsToRepresentations(this.item.id, itemType, metadata, itemDataService) + ); + } + } diff --git a/src/app/+item-page/simple/metadata-representation-list/metadata-representation-list.component.html b/src/app/+item-page/simple/metadata-representation-list/metadata-representation-list.component.html new file mode 100644 index 0000000000..48eabf8451 --- /dev/null +++ b/src/app/+item-page/simple/metadata-representation-list/metadata-representation-list.component.html @@ -0,0 +1,5 @@ + + + + diff --git a/src/app/+item-page/simple/metadata-representation-list/metadata-representation-list.component.spec.ts b/src/app/+item-page/simple/metadata-representation-list/metadata-representation-list.component.spec.ts new file mode 100644 index 0000000000..77ba30778e --- /dev/null +++ b/src/app/+item-page/simple/metadata-representation-list/metadata-representation-list.component.spec.ts @@ -0,0 +1,40 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; +import { By } from '@angular/platform-browser'; +import { MetadataRepresentationListComponent } from './metadata-representation-list.component'; +import { MetadatumRepresentation } from '../../../core/shared/metadata-representation/metadatum/metadatum-representation.model'; +import { ItemMetadataRepresentation } from '../../../core/shared/metadata-representation/item/item-metadata-representation.model'; + +const itemType = 'type'; +const metadataRepresentation1 = new MetadatumRepresentation(itemType); +const metadataRepresentation2 = new ItemMetadataRepresentation(itemType); +const representations = [metadataRepresentation1, metadataRepresentation2]; + +describe('MetadataRepresentationListComponent', () => { + let comp: MetadataRepresentationListComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [], + declarations: [MetadataRepresentationListComponent], + providers: [], + schemas: [NO_ERRORS_SCHEMA] + }).overrideComponent(MetadataRepresentationListComponent, { + set: {changeDetection: ChangeDetectionStrategy.Default} + }).compileComponents(); + })); + + beforeEach(async(() => { + fixture = TestBed.createComponent(MetadataRepresentationListComponent); + comp = fixture.componentInstance; + comp.representations = representations; + fixture.detectChanges(); + })); + + it(`should load ${representations.length} item-type-switcher components`, () => { + const fields = fixture.debugElement.queryAll(By.css('ds-item-type-switcher')); + expect(fields.length).toBe(representations.length); + }); + +}); diff --git a/src/app/+item-page/simple/metadata-representation-list/metadata-representation-list.component.ts b/src/app/+item-page/simple/metadata-representation-list/metadata-representation-list.component.ts new file mode 100644 index 0000000000..b821557f4a --- /dev/null +++ b/src/app/+item-page/simple/metadata-representation-list/metadata-representation-list.component.ts @@ -0,0 +1,31 @@ +import { Component, Input } from '@angular/core'; +import * as viewMode from '../../../shared/view-mode'; +import { MetadataRepresentation } from '../../../core/shared/metadata-representation/metadata-representation.model'; + +export const VIEW_MODE_METADATA = 'metadata'; + +@Component({ + selector: 'ds-metadata-representation-list', + templateUrl: './metadata-representation-list.component.html' +}) +/** + * This component is used for displaying metadata + * It expects a list of MetadataRepresentation objects and a label to put on top of the list + */ +export class MetadataRepresentationListComponent { + /** + * A list of metadata-representations to display + */ + @Input() representations: MetadataRepresentation[]; + + /** + * An i18n label to use as a title for the list + */ + @Input() label: string; + + /** + * The view-mode we're currently on + * @type {ElementViewMode} + */ + viewMode = VIEW_MODE_METADATA; +} diff --git a/src/app/+item-page/simple/related-items/related-items-component.ts b/src/app/+item-page/simple/related-items/related-items-component.ts index 6ad2f0eeb3..ce8ca58b29 100644 --- a/src/app/+item-page/simple/related-items/related-items-component.ts +++ b/src/app/+item-page/simple/related-items/related-items-component.ts @@ -1,6 +1,7 @@ import { Component, Input } from '@angular/core'; import { Item } from '../../../core/shared/item.model'; -import * as viewMode from '../../../shared/view-mode'; + +export const VIEW_MODE_ELEMENT = 'element'; @Component({ selector: 'ds-related-items', @@ -26,5 +27,5 @@ export class RelatedItemsComponent { * The view-mode we're currently on * @type {ElementViewMode} */ - ElementViewMode = viewMode.ElementViewMode + viewMode = VIEW_MODE_ELEMENT; } diff --git a/src/app/+item-page/simple/related-items/related-items.component.html b/src/app/+item-page/simple/related-items/related-items.component.html index bd8b7eb5f3..4b284ad63c 100644 --- a/src/app/+item-page/simple/related-items/related-items.component.html +++ b/src/app/+item-page/simple/related-items/related-items.component.html @@ -1,5 +1,5 @@ + [object]="item" [viewMode]="viewMode"> diff --git a/src/app/core/metadata/metadata.service.spec.ts b/src/app/core/metadata/metadata.service.spec.ts index 006707d710..189517e9f5 100644 --- a/src/app/core/metadata/metadata.service.spec.ts +++ b/src/app/core/metadata/metadata.service.spec.ts @@ -33,6 +33,7 @@ import { MockTranslateLoader } from '../../shared/mocks/mock-translate-loader'; import { BrowseService } from '../browse/browse.service'; import { HALEndpointService } from '../shared/hal-endpoint.service'; import { EmptyError } from 'rxjs/internal-compatibility'; +import { Metadatum } from '../shared/metadatum.model'; /* tslint:disable:max-classes-per-file */ @Component({ @@ -223,7 +224,7 @@ describe('MetadataService', () => { key: 'dc.publisher', language: 'en_US', value: 'Mock Publisher' - }); + } as Metadatum); return publishedMockItem; } diff --git a/src/app/core/shared/dspace-object.model.ts b/src/app/core/shared/dspace-object.model.ts index 3a40d142aa..916274eda6 100644 --- a/src/app/core/shared/dspace-object.model.ts +++ b/src/app/core/shared/dspace-object.model.ts @@ -1,5 +1,5 @@ import { Metadatum } from './metadatum.model' -import { isEmpty, isNotEmpty } from '../../shared/empty.util'; +import { hasNoValue, isEmpty, isNotEmpty } from '../../shared/empty.util'; import { CacheableObject } from '../cache/object-cache.reducer'; import { RemoteData } from '../data/remote-data'; import { ResourceType } from './resource-type'; @@ -91,4 +91,23 @@ export class DSpaceObject implements CacheableObject, ListableObject { }); } + /** + * Find metadata on a specific field and order all of them using their "place" property. + * @param key + */ + findMetadataSortedByPlace(key: string): Metadatum[] { + return this.filterMetadata([key]).sort((a: Metadatum, b: Metadatum) => { + if (hasNoValue(a.place) && hasNoValue(b.place)) { + return 0; + } + if (hasNoValue(a.place)) { + return -1; + } + if (hasNoValue(b.place)) { + return 1; + } + return a.place - b.place; + }); + } + } diff --git a/src/app/core/shared/metadata-representation/item/item-metadata-representation.model.spec.ts b/src/app/core/shared/metadata-representation/item/item-metadata-representation.model.spec.ts new file mode 100644 index 0000000000..4afe5a783f --- /dev/null +++ b/src/app/core/shared/metadata-representation/item/item-metadata-representation.model.spec.ts @@ -0,0 +1,36 @@ +import { MetadataRepresentationType } from '../metadata-representation.model'; +import { ItemMetadataRepresentation, ItemTypeToPrimaryValue } from './item-metadata-representation.model'; +import { Item } from '../../item.model'; +import { Metadatum } from '../../metadatum.model'; + +describe('ItemMetadataRepresentation', () => { + const valuePrefix = 'Test value for '; + const item = new Item(); + let itemMetadataRepresentation: ItemMetadataRepresentation; + item.metadata = Object.keys(ItemTypeToPrimaryValue).map((key: string) => { + return Object.assign(new Metadatum(), { + key: ItemTypeToPrimaryValue[key], + value: `${valuePrefix}${ItemTypeToPrimaryValue[key]}` + }); + }); + + for (const itemType of Object.keys(ItemTypeToPrimaryValue)) { + describe(`when creating an ItemMetadataRepresentation with item-type "${itemType}"`, () => { + beforeEach(() => { + itemMetadataRepresentation = Object.assign(new ItemMetadataRepresentation(itemType), item); + }); + + it('should have a representation type of item', () => { + expect(itemMetadataRepresentation.representationType).toEqual(MetadataRepresentationType.Item); + }); + + it('should return the correct value when calling getPrimaryValue', () => { + expect(itemMetadataRepresentation.getPrimaryValue()).toEqual(`${valuePrefix}${ItemTypeToPrimaryValue[itemType]}`); + }); + + it('should return the correct item type', () => { + expect(itemMetadataRepresentation.itemType).toEqual(itemType); + }); + }); + } +}); diff --git a/src/app/core/shared/metadata-representation/item/item-metadata-representation.model.ts b/src/app/core/shared/metadata-representation/item/item-metadata-representation.model.ts new file mode 100644 index 0000000000..9ff72d5cf6 --- /dev/null +++ b/src/app/core/shared/metadata-representation/item/item-metadata-representation.model.ts @@ -0,0 +1,48 @@ +import { Item } from '../../item.model'; +import { MetadataRepresentation, MetadataRepresentationType } from '../metadata-representation.model'; +import { hasValue } from '../../../../shared/empty.util'; + +/** + * An object to convert item types into the metadata field it should render for the item's primary value + */ +export const ItemTypeToPrimaryValue = { + Default: 'dc.title', + Person: 'dc.contributor.author' +}; + +/** + * This class defines the way the item it extends should be represented as metadata + */ +export class ItemMetadataRepresentation extends Item implements MetadataRepresentation { + + /** + * The type of item this item can be represented as + */ + itemType: string; + + constructor(itemType: string) { + super(); + this.itemType = itemType; + } + + /** + * Fetch the way this item should be rendered as in a list + */ + get representationType(): MetadataRepresentationType { + return MetadataRepresentationType.Item; + } + + /** + * Get the value to display, depending on the itemType + */ + getPrimaryValue(): string { + let metadata; + if (hasValue(ItemTypeToPrimaryValue[this.itemType])) { + metadata = ItemTypeToPrimaryValue[this.itemType]; + } else { + metadata = ItemTypeToPrimaryValue.Default; + } + return this.findMetadata(metadata); + } + +} diff --git a/src/app/core/shared/metadata-representation/metadata-representation.model.ts b/src/app/core/shared/metadata-representation/metadata-representation.model.ts new file mode 100644 index 0000000000..770c462e8d --- /dev/null +++ b/src/app/core/shared/metadata-representation/metadata-representation.model.ts @@ -0,0 +1,31 @@ +/** + * An Enum defining the representation type of metadata + */ +export enum MetadataRepresentationType { + None = 'none', + Item = 'item', + AuthorityControlled = 'authority_controlled', + PlainText = 'plain_text' +} + +/** + * An interface containing information about how we should represent certain metadata + */ +export interface MetadataRepresentation { + /** + * The type of item this metadata is representing + * e.g. 'Person' + * This can be used for template matching + */ + itemType: string; + + /** + * How we should render the metadata in a list + */ + representationType: MetadataRepresentationType, + + /** + * Fetches the primary value to be displayed + */ + getPrimaryValue(): string +} diff --git a/src/app/core/shared/metadata-representation/metadatum/metadatum-representation.model.spec.ts b/src/app/core/shared/metadata-representation/metadatum/metadatum-representation.model.spec.ts new file mode 100644 index 0000000000..7356a79bbd --- /dev/null +++ b/src/app/core/shared/metadata-representation/metadatum/metadatum-representation.model.spec.ts @@ -0,0 +1,54 @@ +import { Metadatum } from '../../metadatum.model'; +import { MetadatumRepresentation } from './metadatum-representation.model'; +import { MetadataRepresentationType } from '../metadata-representation.model'; + +describe('MetadatumRepresentation', () => { + const itemType = 'Person'; + const normalMetadatum = Object.assign(new Metadatum(), { + key: 'dc.contributor.author', + value: 'Test Author' + }); + const authorityMetadatum = Object.assign(new Metadatum(), { + key: 'dc.contributor.author', + value: 'Test Authority Author', + authority: '1234' + }); + + let metadatumRepresentation: MetadatumRepresentation; + + describe('when creating a MetadatumRepresentation based on a standard Metadatum object', () => { + beforeEach(() => { + metadatumRepresentation = Object.assign(new MetadatumRepresentation(itemType), normalMetadatum); + }); + + it('should have a representation type of plain text', () => { + expect(metadatumRepresentation.representationType).toEqual(MetadataRepresentationType.PlainText); + }); + + it('should return the correct value when calling getPrimaryValue', () => { + expect(metadatumRepresentation.getPrimaryValue()).toEqual(normalMetadatum.value); + }); + + it('should return the correct item type', () => { + expect(metadatumRepresentation.itemType).toEqual(itemType); + }); + }); + + describe('when creating a MetadatumRepresentation based on an authority controlled Metadatum object', () => { + beforeEach(() => { + metadatumRepresentation = Object.assign(new MetadatumRepresentation(itemType), authorityMetadatum); + }); + + it('should have a representation type of plain text', () => { + expect(metadatumRepresentation.representationType).toEqual(MetadataRepresentationType.AuthorityControlled); + }); + + it('should return the correct value when calling getPrimaryValue', () => { + expect(metadatumRepresentation.getPrimaryValue()).toEqual(authorityMetadatum.value); + }); + + it('should return the correct item type', () => { + expect(metadatumRepresentation.itemType).toEqual(itemType); + }); + }); +}); diff --git a/src/app/core/shared/metadata-representation/metadatum/metadatum-representation.model.ts b/src/app/core/shared/metadata-representation/metadatum/metadatum-representation.model.ts new file mode 100644 index 0000000000..6a8de97733 --- /dev/null +++ b/src/app/core/shared/metadata-representation/metadatum/metadatum-representation.model.ts @@ -0,0 +1,38 @@ +import { Metadatum } from '../../metadatum.model'; +import { MetadataRepresentation, MetadataRepresentationType } from '../metadata-representation.model'; +import { hasValue } from '../../../../shared/empty.util'; + +/** + * This class defines the way the metadatum it extends should be represented + */ +export class MetadatumRepresentation extends Metadatum implements MetadataRepresentation { + + /** + * The type of item this metadatum can be represented as + */ + itemType: string; + + constructor(itemType: string) { + super(); + this.itemType = itemType; + } + + /** + * Fetch the way this metadatum should be rendered as in a list + */ + get representationType(): MetadataRepresentationType { + if (hasValue(this.authority)) { + return MetadataRepresentationType.AuthorityControlled; + } else { + return MetadataRepresentationType.PlainText; + } + } + + /** + * Get the value to display + */ + getPrimaryValue(): string { + return this.value; + } + +} diff --git a/src/app/core/shared/metadatum.model.ts b/src/app/core/shared/metadatum.model.ts index a3c5830608..c4ce8c3101 100644 --- a/src/app/core/shared/metadatum.model.ts +++ b/src/app/core/shared/metadatum.model.ts @@ -20,4 +20,17 @@ export class Metadatum { @autoserialize value: string; + /** + * The place of this Metadatum within his list of metadata + * This is used to render metadata in a specific custom order + */ + @autoserialize + place: number; + + /** + * The authority key used for authority-controlled metadata + */ + @autoserialize + authority: string; + } diff --git a/src/app/shared/items/item-type-decorator.ts b/src/app/shared/items/item-type-decorator.ts index 509a1c754a..c8a1a2df97 100644 --- a/src/app/shared/items/item-type-decorator.ts +++ b/src/app/shared/items/item-type-decorator.ts @@ -1,36 +1,60 @@ import { hasNoValue, hasValue } from '../empty.util'; -import { ElementViewMode } from '../view-mode'; +import { MetadataRepresentationType } from '../../core/shared/metadata-representation/metadata-representation.model'; +import { VIEW_MODE_ELEMENT } from '../../+item-page/simple/related-items/related-items-component'; export const DEFAULT_ITEM_TYPE = 'Default'; +export const DEFAULT_VIEW_MODE = VIEW_MODE_ELEMENT; +export const NO_REPRESENTATION_TYPE = MetadataRepresentationType.None; +export const DEFAULT_REPRESENTATION_TYPE = MetadataRepresentationType.PlainText; const map = new Map(); /** - * Decorator used for rendering simple item pages by type and viewMode + * Decorator used for rendering simple item pages by type and viewMode (and optionally a representationType) * @param type * @param viewMode + * @param representationType */ -export function rendersItemType(type: string, viewMode: ElementViewMode) { +export function rendersItemType(type: string, viewMode: string, representationType?: MetadataRepresentationType) { return function decorator(component: any) { if (hasNoValue(map.get(viewMode))) { map.set(viewMode, new Map()); } - if (hasValue(map.get(viewMode).get(type))) { - throw new Error(`There can't be more than one component to render Items of type "${type}" in view mode "${viewMode}"`); + if (hasNoValue(map.get(viewMode).get(type))) { + map.get(viewMode).set(type, new Map()); } - map.get(viewMode).set(type, component); + if (hasNoValue(representationType)) { + representationType = NO_REPRESENTATION_TYPE; + } + if (hasValue(map.get(viewMode).get(type).get(representationType))) { + throw new Error(`There can't be more than one component to render Metadata of type "${type}" in view mode "${viewMode}" with representation type "${representationType}"`); + } + map.get(viewMode).get(type).set(representationType, component); }; } /** - * Get the component used for rendering an item by type and viewMode + * Get the component used for rendering an item by type and viewMode (and optionally a representationType) * @param type * @param viewMode + * @param representationType */ -export function getComponentByItemType(type: string, viewMode: ElementViewMode) { - let component = map.get(viewMode).get(type); - if (hasNoValue(component)) { - component = map.get(viewMode).get(DEFAULT_ITEM_TYPE); +export function getComponentByItemType(type: string, viewMode: string, representationType?: MetadataRepresentationType) { + if (hasNoValue(representationType)) { + representationType = NO_REPRESENTATION_TYPE; } - return component; + if (hasNoValue(map.get(viewMode))) { + viewMode = DEFAULT_VIEW_MODE; + } + if (hasNoValue(map.get(viewMode).get(type))) { + type = DEFAULT_ITEM_TYPE; + } + let representationComponent = map.get(viewMode).get(type).get(representationType); + if (hasNoValue(representationComponent)) { + representationComponent = map.get(viewMode).get(type).get(DEFAULT_REPRESENTATION_TYPE); + } + if (hasNoValue(representationComponent)) { + representationComponent = map.get(viewMode).get(type).get(NO_REPRESENTATION_TYPE); + } + return representationComponent; } diff --git a/src/app/shared/items/switcher/item-type-switcher.component.spec.ts b/src/app/shared/items/switcher/item-type-switcher.component.spec.ts index 67f5309793..cb657b1625 100644 --- a/src/app/shared/items/switcher/item-type-switcher.component.spec.ts +++ b/src/app/shared/items/switcher/item-type-switcher.component.spec.ts @@ -8,8 +8,10 @@ import { PaginatedList } from '../../../core/data/paginated-list'; import { RemoteData } from '../../../core/data/remote-data'; import * as decorator from '../item-type-decorator'; import { getComponentByItemType } from '../item-type-decorator'; -import { ElementViewMode } from '../../view-mode'; +import { ItemMetadataRepresentation } from '../../../core/shared/metadata-representation/item/item-metadata-representation.model'; import createSpy = jasmine.createSpy; +import { VIEW_MODE_FULL } from '../../../+item-page/simple/item-page.component'; +import { VIEW_MODE_METADATA } from '../../../+item-page/simple/metadata-representation-list/metadata-representation-list.component'; const relationType = 'type'; const mockItem: Item = Object.assign(new Item(), { @@ -26,7 +28,8 @@ const mockItem: Item = Object.assign(new Item(), { value: relationType }] }); -const viewMode = ElementViewMode.Full; +const mockItemMetadataRepresentation = Object.assign(new ItemMetadataRepresentation(relationType), mockItem); +let viewMode = VIEW_MODE_FULL; describe('ItemTypeSwitcherComponent', () => { let comp: ItemTypeSwitcherComponent; @@ -47,13 +50,39 @@ describe('ItemTypeSwitcherComponent', () => { spyOnProperty(decorator, 'getComponentByItemType').and.returnValue(createSpy('getComponentByItemType')) })); - describe('when calling getComponent', () => { + describe('when the injected object is of type Item', () => { beforeEach(() => { - comp.getComponent(); + viewMode = VIEW_MODE_FULL; + comp.object = mockItem; + comp.viewMode = viewMode; }); - it('should call getComponentByItemType with parameters type and viewMode', () => { - expect(decorator.getComponentByItemType).toHaveBeenCalledWith(relationType, viewMode); + describe('when calling getComponent', () => { + beforeEach(() => { + comp.getComponent(); + }); + + it('should call getComponentByItemType with parameters type and viewMode', () => { + expect(decorator.getComponentByItemType).toHaveBeenCalledWith(relationType, viewMode); + }); + }); + }); + + describe('when the injected object is of type MetadataRepresentation', () => { + beforeEach(() => { + viewMode = VIEW_MODE_METADATA; + comp.object = mockItemMetadataRepresentation; + comp.viewMode = viewMode; + }); + + describe('when calling getComponent', () => { + beforeEach(() => { + comp.getComponent(); + }); + + it('should call getComponentByItemType with parameters type, viewMode and representationType', () => { + expect(decorator.getComponentByItemType).toHaveBeenCalledWith(relationType, viewMode, mockItemMetadataRepresentation.representationType); + }); }); }); diff --git a/src/app/shared/items/switcher/item-type-switcher.component.ts b/src/app/shared/items/switcher/item-type-switcher.component.ts index 5599326e98..2e03cb556c 100644 --- a/src/app/shared/items/switcher/item-type-switcher.component.ts +++ b/src/app/shared/items/switcher/item-type-switcher.component.ts @@ -4,7 +4,7 @@ import { Item } from '../../../core/shared/item.model'; import { hasValue } from '../../empty.util'; import { ItemSearchResult } from '../../object-collection/shared/item-search-result.model'; import { getComponentByItemType } from '../item-type-decorator'; -import { ElementViewMode } from '../../view-mode'; +import { MetadataRepresentation } from '../../../core/shared/metadata-representation/metadata-representation.model'; export const ITEM: InjectionToken = new InjectionToken('item'); @@ -18,14 +18,14 @@ export const ITEM: InjectionToken = new InjectionToken('item'); */ export class ItemTypeSwitcherComponent implements OnInit { /** - * The item to determine the component for + * The item or metadata to determine the component for */ - @Input() object: Item | SearchResult; + @Input() object: Item | SearchResult | MetadataRepresentation; /** * The preferred view-mode to display */ - @Input() viewMode: ElementViewMode; + @Input() viewMode: string; /** * The object injector used to inject the item into the child component @@ -48,6 +48,11 @@ export class ItemTypeSwitcherComponent implements OnInit { * @returns {string} */ getComponent(): string { + if (hasValue((this.object as any).representationType)) { + const metadataRepresentation = this.object as MetadataRepresentation; + return getComponentByItemType(metadataRepresentation.itemType, this.viewMode, metadataRepresentation.representationType); + } + let item: Item; if (hasValue((this.object as any).dspaceObject)) { const searchResult = this.object as ItemSearchResult; diff --git a/src/app/shared/object-list/item-list-element/item-list-element.component.html b/src/app/shared/object-list/item-list-element/item-list-element.component.html index 8cdf8cac6a..d433c7acf2 100644 --- a/src/app/shared/object-list/item-list-element/item-list-element.component.html +++ b/src/app/shared/object-list/item-list-element/item-list-element.component.html @@ -1 +1 @@ - + diff --git a/src/app/shared/object-list/item-list-element/item-list-element.component.ts b/src/app/shared/object-list/item-list-element/item-list-element.component.ts index a9677c9777..4d34e75d61 100644 --- a/src/app/shared/object-list/item-list-element/item-list-element.component.ts +++ b/src/app/shared/object-list/item-list-element/item-list-element.component.ts @@ -1,10 +1,10 @@ import { Component } from '@angular/core'; import { Item } from '../../../core/shared/item.model'; -import * as viewMode from '../../../shared/view-mode'; import { renderElementsFor } from '../../object-collection/shared/dso-element-decorator'; import { AbstractListableElementComponent } from '../../object-collection/shared/object-collection-element/abstract-listable-element.component'; import { SetViewMode } from '../../view-mode'; +import { VIEW_MODE_ELEMENT } from '../../../+item-page/simple/related-items/related-items-component'; @Component({ selector: 'ds-item-list-element', @@ -18,5 +18,5 @@ import { SetViewMode } from '../../view-mode'; */ @renderElementsFor(Item, SetViewMode.List) export class ItemListElementComponent extends AbstractListableElementComponent { - ElementViewMode = viewMode.ElementViewMode; + viewMode = VIEW_MODE_ELEMENT; } diff --git a/src/app/shared/object-list/item-list-element/item-types/journal-issue/journal-issue-list-element.component.ts b/src/app/shared/object-list/item-list-element/item-types/journal-issue/journal-issue-list-element.component.ts index 4f18822773..3b1b9eb1c9 100644 --- a/src/app/shared/object-list/item-list-element/item-types/journal-issue/journal-issue-list-element.component.ts +++ b/src/app/shared/object-list/item-list-element/item-types/journal-issue/journal-issue-list-element.component.ts @@ -1,9 +1,9 @@ import { Component } from '@angular/core'; import { rendersItemType } from '../../../../items/item-type-decorator'; -import { ElementViewMode } from '../../../../view-mode'; import { TypedItemSearchResultListElementComponent } from '../typed-item-search-result-list-element.component'; +import { VIEW_MODE_ELEMENT } from '../../../../../+item-page/simple/related-items/related-items-component'; -@rendersItemType('JournalIssue', ElementViewMode.SetElement) +@rendersItemType('JournalIssue', VIEW_MODE_ELEMENT) @Component({ selector: 'ds-journal-issue-list-element', styleUrls: ['./journal-issue-list-element.component.scss'], diff --git a/src/app/shared/object-list/item-list-element/item-types/journal-volume/journal-volume-list-element.component.ts b/src/app/shared/object-list/item-list-element/item-types/journal-volume/journal-volume-list-element.component.ts index a95dca88f9..49a11b2cd9 100644 --- a/src/app/shared/object-list/item-list-element/item-types/journal-volume/journal-volume-list-element.component.ts +++ b/src/app/shared/object-list/item-list-element/item-types/journal-volume/journal-volume-list-element.component.ts @@ -1,9 +1,9 @@ import { Component } from '@angular/core'; import { rendersItemType } from '../../../../items/item-type-decorator'; -import { ElementViewMode } from '../../../../view-mode'; import { TypedItemSearchResultListElementComponent } from '../typed-item-search-result-list-element.component'; +import { VIEW_MODE_ELEMENT } from '../../../../../+item-page/simple/related-items/related-items-component'; -@rendersItemType('JournalVolume', ElementViewMode.SetElement) +@rendersItemType('JournalVolume', VIEW_MODE_ELEMENT) @Component({ selector: 'ds-journal-volume-list-element', styleUrls: ['./journal-volume-list-element.component.scss'], diff --git a/src/app/shared/object-list/item-list-element/item-types/journal/journal-list-element.component.ts b/src/app/shared/object-list/item-list-element/item-types/journal/journal-list-element.component.ts index 28be0d8149..45926c681c 100644 --- a/src/app/shared/object-list/item-list-element/item-types/journal/journal-list-element.component.ts +++ b/src/app/shared/object-list/item-list-element/item-types/journal/journal-list-element.component.ts @@ -1,9 +1,9 @@ import { Component } from '@angular/core'; import { rendersItemType } from '../../../../items/item-type-decorator'; -import { ElementViewMode } from '../../../../view-mode'; import { TypedItemSearchResultListElementComponent } from '../typed-item-search-result-list-element.component'; +import { VIEW_MODE_ELEMENT } from '../../../../../+item-page/simple/related-items/related-items-component'; -@rendersItemType('Journal', ElementViewMode.SetElement) +@rendersItemType('Journal', VIEW_MODE_ELEMENT) @Component({ selector: 'ds-journal-list-element', styleUrls: ['./journal-list-element.component.scss'], diff --git a/src/app/shared/object-list/item-list-element/item-types/orgunit/orgunit-list-element.component.ts b/src/app/shared/object-list/item-list-element/item-types/orgunit/orgunit-list-element.component.ts index e3433f7e76..699cb6dfab 100644 --- a/src/app/shared/object-list/item-list-element/item-types/orgunit/orgunit-list-element.component.ts +++ b/src/app/shared/object-list/item-list-element/item-types/orgunit/orgunit-list-element.component.ts @@ -1,9 +1,9 @@ import { Component } from '@angular/core'; import { rendersItemType } from '../../../../items/item-type-decorator'; -import { ElementViewMode } from '../../../../view-mode'; import { TypedItemSearchResultListElementComponent } from '../typed-item-search-result-list-element.component'; +import { VIEW_MODE_ELEMENT } from '../../../../../+item-page/simple/related-items/related-items-component'; -@rendersItemType('OrgUnit', ElementViewMode.SetElement) +@rendersItemType('OrgUnit', VIEW_MODE_ELEMENT) @Component({ selector: 'ds-orgunit-list-element', styleUrls: ['./orgunit-list-element.component.scss'], diff --git a/src/app/shared/object-list/item-list-element/item-types/person/person-list-element.component.html b/src/app/shared/object-list/item-list-element/item-types/person/person-list-element.component.html index 803674b56e..2d89fda483 100644 --- a/src/app/shared/object-list/item-list-element/item-types/person/person-list-element.component.html +++ b/src/app/shared/object-list/item-list-element/item-types/person/person-list-element.component.html @@ -13,4 +13,3 @@ - diff --git a/src/app/shared/object-list/item-list-element/item-types/person/person-list-element.component.ts b/src/app/shared/object-list/item-list-element/item-types/person/person-list-element.component.ts index b0369458f9..e12cc60813 100644 --- a/src/app/shared/object-list/item-list-element/item-types/person/person-list-element.component.ts +++ b/src/app/shared/object-list/item-list-element/item-types/person/person-list-element.component.ts @@ -1,9 +1,9 @@ import { Component } from '@angular/core'; import { rendersItemType } from '../../../../items/item-type-decorator'; -import { ElementViewMode } from '../../../../view-mode'; import { TypedItemSearchResultListElementComponent } from '../typed-item-search-result-list-element.component'; +import { VIEW_MODE_ELEMENT } from '../../../../../+item-page/simple/related-items/related-items-component'; -@rendersItemType('Person', ElementViewMode.SetElement) +@rendersItemType('Person', VIEW_MODE_ELEMENT) @Component({ selector: 'ds-person-list-element', styleUrls: ['./person-list-element.component.scss'], diff --git a/src/app/shared/object-list/item-list-element/item-types/person/person-metadata-list-element.component.html b/src/app/shared/object-list/item-list-element/item-types/person/person-metadata-list-element.component.html new file mode 100644 index 0000000000..92e57d7ef4 --- /dev/null +++ b/src/app/shared/object-list/item-list-element/item-types/person/person-metadata-list-element.component.html @@ -0,0 +1,15 @@ + + + + + + + + + + + + diff --git a/src/app/shared/object-list/item-list-element/item-types/person/person-metadata-list-element.component.ts b/src/app/shared/object-list/item-list-element/item-types/person/person-metadata-list-element.component.ts new file mode 100644 index 0000000000..1f3d736d1c --- /dev/null +++ b/src/app/shared/object-list/item-list-element/item-types/person/person-metadata-list-element.component.ts @@ -0,0 +1,16 @@ +import { rendersItemType } from '../../../../items/item-type-decorator'; +import { VIEW_MODE_ELEMENT } from '../../../../../+item-page/simple/related-items/related-items-component'; +import { Component } from '@angular/core'; +import { TypedItemSearchResultListElementComponent } from '../typed-item-search-result-list-element.component'; +import { MetadataRepresentationType } from '../../../../../core/shared/metadata-representation/metadata-representation.model'; + +@rendersItemType('Person', VIEW_MODE_ELEMENT, MetadataRepresentationType.Item) +@Component({ + selector: 'ds-person-metadata-list-element', + templateUrl: './person-metadata-list-element.component.html' +}) +/** + * The component for displaying a list element for an item of the type Person + */ +export class PersonMetadataListElementComponent extends TypedItemSearchResultListElementComponent { +} diff --git a/src/app/shared/object-list/item-list-element/item-types/project/project-list-element.component.ts b/src/app/shared/object-list/item-list-element/item-types/project/project-list-element.component.ts index 6b130e4786..e688056bc6 100644 --- a/src/app/shared/object-list/item-list-element/item-types/project/project-list-element.component.ts +++ b/src/app/shared/object-list/item-list-element/item-types/project/project-list-element.component.ts @@ -1,9 +1,9 @@ import { Component } from '@angular/core'; import { rendersItemType } from '../../../../items/item-type-decorator'; -import { ElementViewMode } from '../../../../view-mode'; import { TypedItemSearchResultListElementComponent } from '../typed-item-search-result-list-element.component'; +import { VIEW_MODE_ELEMENT } from '../../../../../+item-page/simple/related-items/related-items-component'; -@rendersItemType('Project', ElementViewMode.SetElement) +@rendersItemType('Project', VIEW_MODE_ELEMENT) @Component({ selector: 'ds-project-list-element', styleUrls: ['./project-list-element.component.scss'], diff --git a/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.ts b/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.ts index 4575ab5cca..58a0568931 100644 --- a/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.ts +++ b/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.ts @@ -1,10 +1,10 @@ import { Component } from '@angular/core'; import { DEFAULT_ITEM_TYPE, rendersItemType } from '../../../../items/item-type-decorator'; -import { ElementViewMode } from '../../../../view-mode'; import { TypedItemSearchResultListElementComponent } from '../typed-item-search-result-list-element.component'; +import { VIEW_MODE_ELEMENT } from '../../../../../+item-page/simple/related-items/related-items-component'; -@rendersItemType('Publication', ElementViewMode.SetElement) -@rendersItemType(DEFAULT_ITEM_TYPE, ElementViewMode.SetElement) +@rendersItemType('Publication', VIEW_MODE_ELEMENT) +@rendersItemType(DEFAULT_ITEM_TYPE, VIEW_MODE_ELEMENT) @Component({ selector: 'ds-publication-list-element', styleUrls: ['./publication-list-element.component.scss'], diff --git a/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.html b/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.html new file mode 100644 index 0000000000..764fdc1064 --- /dev/null +++ b/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.html @@ -0,0 +1,2 @@ + + diff --git a/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.spec.ts b/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.spec.ts new file mode 100644 index 0000000000..90de549800 --- /dev/null +++ b/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.spec.ts @@ -0,0 +1,38 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ITEM } from '../../../items/switcher/item-type-switcher.component'; +import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; +import { ItemMetadataListElementComponent } from './item-metadata-list-element.component'; +import { By } from '@angular/platform-browser'; +import { ItemMetadataRepresentation } from '../../../../core/shared/metadata-representation/item/item-metadata-representation.model'; + +const mockItemMetadataRepresentation = new ItemMetadataRepresentation('type'); + +describe('ItemMetadataListElementComponent', () => { + let comp: ItemMetadataListElementComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [], + declarations: [ItemMetadataListElementComponent], + providers: [ + { provide: ITEM, useValue: mockItemMetadataRepresentation } + ], + schemas: [NO_ERRORS_SCHEMA] + }).overrideComponent(ItemMetadataListElementComponent, { + set: {changeDetection: ChangeDetectionStrategy.Default} + }).compileComponents(); + })); + + beforeEach(async(() => { + fixture = TestBed.createComponent(ItemMetadataListElementComponent); + comp = fixture.componentInstance; + fixture.detectChanges(); + })); + + it('should call an item-type-switcher component and pass the item-metadata-representation', () => { + const itemTypeSwitcher = fixture.debugElement.query(By.css('ds-item-type-switcher')).nativeElement; + expect(itemTypeSwitcher.object).toBe(mockItemMetadataRepresentation); + }); + +}); diff --git a/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.ts b/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.ts new file mode 100644 index 0000000000..a5900cc763 --- /dev/null +++ b/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-list-element.component.ts @@ -0,0 +1,25 @@ +import * as viewMode from '../../../view-mode'; +import { MetadataRepresentationType } from '../../../../core/shared/metadata-representation/metadata-representation.model'; +import { Component } from '@angular/core'; +import { MetadataRepresentationListElementComponent } from '../metadata-representation-list-element.component'; +import { DEFAULT_ITEM_TYPE, rendersItemType } from '../../../items/item-type-decorator'; +import { VIEW_MODE_METADATA } from '../../../../+item-page/simple/metadata-representation-list/metadata-representation-list.component'; +import { VIEW_MODE_ELEMENT } from '../../../../+item-page/simple/related-items/related-items-component'; + +@rendersItemType(DEFAULT_ITEM_TYPE, VIEW_MODE_METADATA, MetadataRepresentationType.Item) +@Component({ + selector: 'ds-item-metadata-list-element', + templateUrl: './item-metadata-list-element.component.html' +}) +/** + * A component for displaying MetadataRepresentation objects in the form of items + * It will send the MetadataRepresentation object along with ElementViewMode.SetElement to the ItemTypeSwitcherComponent, + * which will in his turn decide how to render the item as metadata. + */ +export class ItemMetadataListElementComponent extends MetadataRepresentationListElementComponent { + /** + * The view-mode we're currently on + * @type {ElementViewMode} + */ + viewMode = VIEW_MODE_ELEMENT; +} diff --git a/src/app/shared/object-list/metadata-representation-list-element/metadata-representation-list-element.component.ts b/src/app/shared/object-list/metadata-representation-list-element/metadata-representation-list-element.component.ts new file mode 100644 index 0000000000..2488db50b1 --- /dev/null +++ b/src/app/shared/object-list/metadata-representation-list-element/metadata-representation-list-element.component.ts @@ -0,0 +1,15 @@ +import { Component, Inject } from '@angular/core'; +import { MetadataRepresentation } from '../../../core/shared/metadata-representation/metadata-representation.model'; +import { ITEM } from '../../items/switcher/item-type-switcher.component'; + +@Component({ + selector: 'ds-metadata-representation-list-element', + template: '' +}) +/** + * An abstract class for displaying a single MetadataRepresentation + */ +export class MetadataRepresentationListElementComponent { + constructor(@Inject(ITEM) public metadataRepresentation: MetadataRepresentation) { + } +} diff --git a/src/app/shared/object-list/metadata-representation-list-element/plain-text/plain-text-metadata-list-element.component.html b/src/app/shared/object-list/metadata-representation-list-element/plain-text/plain-text-metadata-list-element.component.html new file mode 100644 index 0000000000..2533cf834b --- /dev/null +++ b/src/app/shared/object-list/metadata-representation-list-element/plain-text/plain-text-metadata-list-element.component.html @@ -0,0 +1,3 @@ +
+ {{metadataRepresentation.getPrimaryValue()}} +
diff --git a/src/app/shared/object-list/metadata-representation-list-element/plain-text/plain-text-metadata-list-element.component.spec.ts b/src/app/shared/object-list/metadata-representation-list-element/plain-text/plain-text-metadata-list-element.component.spec.ts new file mode 100644 index 0000000000..42b9abde16 --- /dev/null +++ b/src/app/shared/object-list/metadata-representation-list-element/plain-text/plain-text-metadata-list-element.component.spec.ts @@ -0,0 +1,39 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; +import { PlainTextMetadataListElementComponent } from './plain-text-metadata-list-element.component'; +import { MetadatumRepresentation } from '../../../../core/shared/metadata-representation/metadatum/metadatum-representation.model'; +import { ITEM } from '../../../items/switcher/item-type-switcher.component'; + +const mockMetadataRepresentation = Object.assign(new MetadatumRepresentation('type'), { + key: 'dc.contributor.author', + value: 'Test Author' +}); + +describe('PlainTextMetadataListElementComponent', () => { + let comp: PlainTextMetadataListElementComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [], + declarations: [PlainTextMetadataListElementComponent], + providers: [ + { provide: ITEM, useValue: mockMetadataRepresentation } + ], + schemas: [NO_ERRORS_SCHEMA] + }).overrideComponent(PlainTextMetadataListElementComponent, { + set: {changeDetection: ChangeDetectionStrategy.Default} + }).compileComponents(); + })); + + beforeEach(async(() => { + fixture = TestBed.createComponent(PlainTextMetadataListElementComponent); + comp = fixture.componentInstance; + fixture.detectChanges(); + })); + + it('should contain the value as plain text', () => { + expect(fixture.debugElement.nativeElement.textContent).toContain(mockMetadataRepresentation.value); + }); + +}); diff --git a/src/app/shared/object-list/metadata-representation-list-element/plain-text/plain-text-metadata-list-element.component.ts b/src/app/shared/object-list/metadata-representation-list-element/plain-text/plain-text-metadata-list-element.component.ts new file mode 100644 index 0000000000..e7cf235c75 --- /dev/null +++ b/src/app/shared/object-list/metadata-representation-list-element/plain-text/plain-text-metadata-list-element.component.ts @@ -0,0 +1,19 @@ +import { MetadataRepresentationType } from '../../../../core/shared/metadata-representation/metadata-representation.model'; +import { Component } from '@angular/core'; +import { MetadataRepresentationListElementComponent } from '../metadata-representation-list-element.component'; +import { DEFAULT_ITEM_TYPE, rendersItemType } from '../../../items/item-type-decorator'; +import { VIEW_MODE_METADATA } from '../../../../+item-page/simple/metadata-representation-list/metadata-representation-list.component'; + +@rendersItemType(DEFAULT_ITEM_TYPE, VIEW_MODE_METADATA, MetadataRepresentationType.PlainText) +// For now, authority controlled fields are rendered the same way as plain text fields +@rendersItemType(DEFAULT_ITEM_TYPE, VIEW_MODE_METADATA, MetadataRepresentationType.AuthorityControlled) +@Component({ + selector: 'ds-plain-text-metadata-list-element', + templateUrl: './plain-text-metadata-list-element.component.html' +}) +/** + * A component for displaying MetadataRepresentation objects in the form of plain text + * It will simply use the value retrieved from MetadataRepresentation.getPrimaryValue() to display as plain text + */ +export class PlainTextMetadataListElementComponent extends MetadataRepresentationListElementComponent { +} diff --git a/src/app/shared/object-list/search-result-list-element/item-search-result/item-search-result-list-element.component.html b/src/app/shared/object-list/search-result-list-element/item-search-result/item-search-result-list-element.component.html index 8cdf8cac6a..d433c7acf2 100644 --- a/src/app/shared/object-list/search-result-list-element/item-search-result/item-search-result-list-element.component.html +++ b/src/app/shared/object-list/search-result-list-element/item-search-result/item-search-result-list-element.component.html @@ -1 +1 @@ - + diff --git a/src/app/shared/object-list/search-result-list-element/item-search-result/item-search-result-list-element.component.ts b/src/app/shared/object-list/search-result-list-element/item-search-result/item-search-result-list-element.component.ts index b9ac52ca40..a164e5a65b 100644 --- a/src/app/shared/object-list/search-result-list-element/item-search-result/item-search-result-list-element.component.ts +++ b/src/app/shared/object-list/search-result-list-element/item-search-result/item-search-result-list-element.component.ts @@ -4,9 +4,9 @@ import { focusBackground } from '../../../animations/focus'; import { renderElementsFor } from '../../../object-collection/shared/dso-element-decorator'; import { ItemSearchResult } from '../../../object-collection/shared/item-search-result.model'; -import * as viewMode from '../../../../shared/view-mode'; import { SetViewMode } from '../../../view-mode'; import { SearchResultListElementComponent } from '../search-result-list-element.component'; +import { VIEW_MODE_ELEMENT } from '../../../../+item-page/simple/related-items/related-items-component'; @Component({ selector: 'ds-item-search-result-list-element', @@ -18,5 +18,5 @@ import { SearchResultListElementComponent } from '../search-result-list-element. @renderElementsFor(ItemSearchResult, SetViewMode.List) export class ItemSearchResultListElementComponent extends SearchResultListElementComponent { - ElementViewMode = viewMode.ElementViewMode; + viewMode = VIEW_MODE_ELEMENT; } diff --git a/src/app/shared/shared.module.ts b/src/app/shared/shared.module.ts index e467839b57..1c40e86680 100644 --- a/src/app/shared/shared.module.ts +++ b/src/app/shared/shared.module.ts @@ -94,6 +94,11 @@ import { CapitalizePipe } from './utils/capitalize.pipe'; import { ObjectKeysPipe } from './utils/object-keys-pipe'; import { MomentModule } from 'ngx-moment'; import { NouisliderModule } from 'ng2-nouislider'; +import { PlainTextMetadataListElementComponent } from './object-list/metadata-representation-list-element/plain-text/plain-text-metadata-list-element.component'; +import { ItemMetadataListElementComponent } from './object-list/metadata-representation-list-element/item/item-metadata-list-element.component'; +import { TooltipModule } from 'ngx-bootstrap'; +import { PersonMetadataListElementComponent } from './object-list/item-list-element/item-types/person/person-metadata-list-element.component'; +import { MetadataRepresentationListElementComponent } from './object-list/metadata-representation-list-element/metadata-representation-list-element.component'; const MODULES = [ // Do NOT include UniversalModule, HttpModule, or JsonpModule here @@ -117,6 +122,10 @@ const MODULES = [ TextMaskModule ]; +const ROOT_MODULES = [ + TooltipModule.forRoot() +]; + const PIPES = [ // put shared pipes here EnumKeysPipe, @@ -184,12 +193,16 @@ const ENTRY_COMPONENTS = [ SearchResultGridElementComponent, PublicationListElementComponent, PersonListElementComponent, + PersonMetadataListElementComponent, OrgUnitListElementComponent, ProjectListElementComponent, JournalListElementComponent, JournalVolumeListElementComponent, JournalIssueListElementComponent, - BrowseEntryListElementComponent + BrowseEntryListElementComponent, + PlainTextMetadataListElementComponent, + ItemMetadataListElementComponent, + MetadataRepresentationListElementComponent ]; const PROVIDERS = [ @@ -206,7 +219,8 @@ const DIRECTIVES = [ @NgModule({ imports: [ - ...MODULES + ...MODULES, + ...ROOT_MODULES ], declarations: [ ...PIPES, diff --git a/src/app/shared/view-mode.ts b/src/app/shared/view-mode.ts index 2825f20c50..d36764a6e8 100644 --- a/src/app/shared/view-mode.ts +++ b/src/app/shared/view-mode.ts @@ -8,17 +8,7 @@ export enum SetViewMode { Grid = 'grid' } -/** - * Enum used for defining the view-mode of a single element - * Full Display the full element - * SetElement Display the element as part of a set - */ -export enum ElementViewMode { - Full, - SetElement -} - /** * ViewMode refers to either a SetViewMode or ElementViewMode */ -export type ViewMode = SetViewMode | ElementViewMode; +export type ViewMode = SetViewMode; From 9982254ca26de0d6ab3f6dfe82e5051eaba6b222 Mon Sep 17 00:00:00 2001 From: Art Lowel Date: Tue, 22 Jan 2019 16:13:49 +0100 Subject: [PATCH 5/6] roll back a merge mistake --- resources/i18n/en.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/i18n/en.json b/resources/i18n/en.json index 1b2e6a5ca2..e296326b72 100644 --- a/resources/i18n/en.json +++ b/resources/i18n/en.json @@ -334,7 +334,7 @@ "f.dateIssued.max": "End date", "f.subject": "Subject", "f.has_content_in_original_bundle": "Has files", - "f.entityType": "Entity Type" + "f.entityType": "Item Type" }, "filter": { "show-more": "Show more", @@ -364,8 +364,8 @@ "head": "Has files" }, "entityType": { - "placeholder": "Entity Type", - "head": "Entity Type" + "placeholder": "Item Type", + "head": "Item Type" } } } From 11b09a22697b119d38e34f15f3d8515abbc5c11f Mon Sep 17 00:00:00 2001 From: Art Lowel Date: Tue, 29 Jan 2019 18:23:01 +0100 Subject: [PATCH 6/6] rename getPrimaryValue to getValue, improve doccomments and move virtual metadata code to the Metadatum model --- .../item-types/shared/item.component.spec.ts | 8 +-- .../item-types/shared/item.component.ts | 9 +-- ...item-metadata-representation.model.spec.ts | 14 ++-- .../item-metadata-representation.model.ts | 14 ++-- .../metadata-representation.model.ts | 4 +- .../metadatum-representation.model.spec.ts | 6 +- .../metadatum-representation.model.ts | 2 +- src/app/core/shared/metadatum.model.spec.ts | 67 +++++++++++++++++++ src/app/core/shared/metadatum.model.ts | 28 ++++++++ ...-text-metadata-list-element.component.html | 2 +- ...in-text-metadata-list-element.component.ts | 2 +- 11 files changed, 126 insertions(+), 30 deletions(-) create mode 100644 src/app/core/shared/metadatum.model.spec.ts diff --git a/src/app/+item-page/simple/item-types/shared/item.component.spec.ts b/src/app/+item-page/simple/item-types/shared/item.component.spec.ts index 8c6cf15ee9..28bd8e33e3 100644 --- a/src/app/+item-page/simple/item-types/shared/item.component.spec.ts +++ b/src/app/+item-page/simple/item-types/shared/item.component.spec.ts @@ -411,10 +411,10 @@ describe('ItemComponent', () => { it('should have all the representations in the correct order', () => { representations.subscribe((reps: MetadataRepresentation[]) => { - expect(reps[0].getPrimaryValue()).toEqual('First value'); - expect(reps[1].getPrimaryValue()).toEqual('Second value'); - expect(reps[2].getPrimaryValue()).toEqual('related item'); - expect(reps[3].getPrimaryValue()).toEqual('Fourth value'); + expect(reps[0].getValue()).toEqual('First value'); + expect(reps[1].getValue()).toEqual('Second value'); + expect(reps[2].getValue()).toEqual('related item'); + expect(reps[3].getValue()).toEqual('Fourth value'); }); }); diff --git a/src/app/+item-page/simple/item-types/shared/item.component.ts b/src/app/+item-page/simple/item-types/shared/item.component.ts index c5aae65f13..3cea15c251 100644 --- a/src/app/+item-page/simple/item-types/shared/item.component.ts +++ b/src/app/+item-page/simple/item-types/shared/item.component.ts @@ -99,10 +99,11 @@ export const relationsToRepresentations = (thisId: string, itemType: string, met source.pipe( flatMap((rels: Relationship[]) => observableZip( - ...metadata.map((metadatum: Metadatum) => { - const prefix = 'virtual::'; - if (hasValue(metadatum.authority) && metadatum.authority.startsWith(prefix)) { - const matchingRels = rels.filter((rel: Relationship) => ('' + rel.id) === metadatum.authority.substring(metadatum.authority.indexOf(prefix) + prefix.length)); + ...metadata + .map((metadatum: any) => Object.assign(new Metadatum(), metadatum)) + .map((metadatum: Metadatum) => { + if (metadatum.isVirtual) { + const matchingRels = rels.filter((rel: Relationship) => ('' + rel.id) === metadatum.virtualValue); if (matchingRels.length > 0) { const matchingRel = matchingRels[0]; let queryId = matchingRel.leftId; diff --git a/src/app/core/shared/metadata-representation/item/item-metadata-representation.model.spec.ts b/src/app/core/shared/metadata-representation/item/item-metadata-representation.model.spec.ts index 4afe5a783f..cd153153de 100644 --- a/src/app/core/shared/metadata-representation/item/item-metadata-representation.model.spec.ts +++ b/src/app/core/shared/metadata-representation/item/item-metadata-representation.model.spec.ts @@ -1,5 +1,5 @@ import { MetadataRepresentationType } from '../metadata-representation.model'; -import { ItemMetadataRepresentation, ItemTypeToPrimaryValue } from './item-metadata-representation.model'; +import { ItemMetadataRepresentation, ItemTypeToValue } from './item-metadata-representation.model'; import { Item } from '../../item.model'; import { Metadatum } from '../../metadatum.model'; @@ -7,14 +7,14 @@ describe('ItemMetadataRepresentation', () => { const valuePrefix = 'Test value for '; const item = new Item(); let itemMetadataRepresentation: ItemMetadataRepresentation; - item.metadata = Object.keys(ItemTypeToPrimaryValue).map((key: string) => { + item.metadata = Object.keys(ItemTypeToValue).map((key: string) => { return Object.assign(new Metadatum(), { - key: ItemTypeToPrimaryValue[key], - value: `${valuePrefix}${ItemTypeToPrimaryValue[key]}` + key: ItemTypeToValue[key], + value: `${valuePrefix}${ItemTypeToValue[key]}` }); }); - for (const itemType of Object.keys(ItemTypeToPrimaryValue)) { + for (const itemType of Object.keys(ItemTypeToValue)) { describe(`when creating an ItemMetadataRepresentation with item-type "${itemType}"`, () => { beforeEach(() => { itemMetadataRepresentation = Object.assign(new ItemMetadataRepresentation(itemType), item); @@ -24,8 +24,8 @@ describe('ItemMetadataRepresentation', () => { expect(itemMetadataRepresentation.representationType).toEqual(MetadataRepresentationType.Item); }); - it('should return the correct value when calling getPrimaryValue', () => { - expect(itemMetadataRepresentation.getPrimaryValue()).toEqual(`${valuePrefix}${ItemTypeToPrimaryValue[itemType]}`); + it('should return the correct value when calling getValue', () => { + expect(itemMetadataRepresentation.getValue()).toEqual(`${valuePrefix}${ItemTypeToValue[itemType]}`); }); it('should return the correct item type', () => { diff --git a/src/app/core/shared/metadata-representation/item/item-metadata-representation.model.ts b/src/app/core/shared/metadata-representation/item/item-metadata-representation.model.ts index 9ff72d5cf6..2d4f3fdf75 100644 --- a/src/app/core/shared/metadata-representation/item/item-metadata-representation.model.ts +++ b/src/app/core/shared/metadata-representation/item/item-metadata-representation.model.ts @@ -3,15 +3,15 @@ import { MetadataRepresentation, MetadataRepresentationType } from '../metadata- import { hasValue } from '../../../../shared/empty.util'; /** - * An object to convert item types into the metadata field it should render for the item's primary value + * An object to convert item types into the metadata field it should render for the item's value */ -export const ItemTypeToPrimaryValue = { +export const ItemTypeToValue = { Default: 'dc.title', Person: 'dc.contributor.author' }; /** - * This class defines the way the item it extends should be represented as metadata + * This class determines which fields to use when rendering an Item as a metadata value. */ export class ItemMetadataRepresentation extends Item implements MetadataRepresentation { @@ -35,12 +35,12 @@ export class ItemMetadataRepresentation extends Item implements MetadataRepresen /** * Get the value to display, depending on the itemType */ - getPrimaryValue(): string { + getValue(): string { let metadata; - if (hasValue(ItemTypeToPrimaryValue[this.itemType])) { - metadata = ItemTypeToPrimaryValue[this.itemType]; + if (hasValue(ItemTypeToValue[this.itemType])) { + metadata = ItemTypeToValue[this.itemType]; } else { - metadata = ItemTypeToPrimaryValue.Default; + metadata = ItemTypeToValue.Default; } return this.findMetadata(metadata); } diff --git a/src/app/core/shared/metadata-representation/metadata-representation.model.ts b/src/app/core/shared/metadata-representation/metadata-representation.model.ts index 770c462e8d..58e5bf906f 100644 --- a/src/app/core/shared/metadata-representation/metadata-representation.model.ts +++ b/src/app/core/shared/metadata-representation/metadata-representation.model.ts @@ -25,7 +25,7 @@ export interface MetadataRepresentation { representationType: MetadataRepresentationType, /** - * Fetches the primary value to be displayed + * Fetches the value to be displayed */ - getPrimaryValue(): string + getValue(): string } diff --git a/src/app/core/shared/metadata-representation/metadatum/metadatum-representation.model.spec.ts b/src/app/core/shared/metadata-representation/metadatum/metadatum-representation.model.spec.ts index 7356a79bbd..c55ff7f9f3 100644 --- a/src/app/core/shared/metadata-representation/metadatum/metadatum-representation.model.spec.ts +++ b/src/app/core/shared/metadata-representation/metadatum/metadatum-representation.model.spec.ts @@ -26,7 +26,7 @@ describe('MetadatumRepresentation', () => { }); it('should return the correct value when calling getPrimaryValue', () => { - expect(metadatumRepresentation.getPrimaryValue()).toEqual(normalMetadatum.value); + expect(metadatumRepresentation.getValue()).toEqual(normalMetadatum.value); }); it('should return the correct item type', () => { @@ -43,8 +43,8 @@ describe('MetadatumRepresentation', () => { expect(metadatumRepresentation.representationType).toEqual(MetadataRepresentationType.AuthorityControlled); }); - it('should return the correct value when calling getPrimaryValue', () => { - expect(metadatumRepresentation.getPrimaryValue()).toEqual(authorityMetadatum.value); + it('should return the correct value when calling getValue', () => { + expect(metadatumRepresentation.getValue()).toEqual(authorityMetadatum.value); }); it('should return the correct item type', () => { diff --git a/src/app/core/shared/metadata-representation/metadatum/metadatum-representation.model.ts b/src/app/core/shared/metadata-representation/metadatum/metadatum-representation.model.ts index 6a8de97733..08ae041706 100644 --- a/src/app/core/shared/metadata-representation/metadatum/metadatum-representation.model.ts +++ b/src/app/core/shared/metadata-representation/metadatum/metadatum-representation.model.ts @@ -31,7 +31,7 @@ export class MetadatumRepresentation extends Metadatum implements MetadataRepres /** * Get the value to display */ - getPrimaryValue(): string { + getValue(): string { return this.value; } diff --git a/src/app/core/shared/metadatum.model.spec.ts b/src/app/core/shared/metadatum.model.spec.ts new file mode 100644 index 0000000000..0b552eed56 --- /dev/null +++ b/src/app/core/shared/metadatum.model.spec.ts @@ -0,0 +1,67 @@ +import { Metadatum } from './metadatum.model'; + +describe('Metadatum', () => { + let metadatum: Metadatum ; + + beforeEach(() => { + metadatum = new Metadatum(); + }); + + describe('isVirtual', () => { + describe('when the metadatum has no authority key', () => { + beforeEach(() => { + metadatum.authority = undefined; + }); + + it('should return false', () => { + expect(metadatum.isVirtual).toBe(false); + }); + }); + + describe('when the metadatum has an authority key', () => { + describe('but it doesn\'t start with the virtual prefix', () => { + beforeEach(() => { + metadatum.authority = 'value'; + }); + + it('should return false', () => { + expect(metadatum.isVirtual).toBe(false); + }); + }); + + describe('and it starts with the virtual prefix', () => { + beforeEach(() => { + metadatum.authority = 'virtual::value'; + }); + + it('should return true', () => { + expect(metadatum.isVirtual).toBe(true); + }); + }); + + }); + + }); + + describe('virtualValue', () => { + describe('when the metadatum isn\'t virtual', () => { + beforeEach(() => { + metadatum.authority = 'value'; + }); + + it('should return undefined', () => { + expect(metadatum.virtualValue).toBeUndefined(); + }); + }); + + describe('when the metadatum is virtual', () => { + beforeEach(() => { + metadatum.authority = 'virtual::value'; + }); + + it('should return everything in the authority key after virtual::', () => { + expect(metadatum.virtualValue).toBe('value'); + }); + }); + }); +}); diff --git a/src/app/core/shared/metadatum.model.ts b/src/app/core/shared/metadatum.model.ts index c4ce8c3101..f8cac4fd51 100644 --- a/src/app/core/shared/metadatum.model.ts +++ b/src/app/core/shared/metadatum.model.ts @@ -1,4 +1,7 @@ import { autoserialize } from 'cerialize'; +import { hasValue } from '../../shared/empty.util'; + +const VIRTUAL_METADATA_PREFIX = 'virtual::'; export class Metadatum { @@ -33,4 +36,29 @@ export class Metadatum { @autoserialize authority: string; + /** + * The authority confidence value + */ + @autoserialize + confidence: number; + + /** + * Returns true if this Metadatum's authority key starts with 'virtual::' + */ + get isVirtual(): boolean { + return hasValue(this.authority) && this.authority.startsWith(VIRTUAL_METADATA_PREFIX); + } + + /** + * If this is a virtual Metadatum, it returns everything in the authority key after 'virtual::'. + * Returns undefined otherwise. + */ + get virtualValue(): string { + if (this.isVirtual) { + return this.authority.substring(this.authority.indexOf(VIRTUAL_METADATA_PREFIX) + VIRTUAL_METADATA_PREFIX.length); + } else { + return undefined; + } + } + } diff --git a/src/app/shared/object-list/metadata-representation-list-element/plain-text/plain-text-metadata-list-element.component.html b/src/app/shared/object-list/metadata-representation-list-element/plain-text/plain-text-metadata-list-element.component.html index 2533cf834b..3e017e1ae8 100644 --- a/src/app/shared/object-list/metadata-representation-list-element/plain-text/plain-text-metadata-list-element.component.html +++ b/src/app/shared/object-list/metadata-representation-list-element/plain-text/plain-text-metadata-list-element.component.html @@ -1,3 +1,3 @@
- {{metadataRepresentation.getPrimaryValue()}} + {{metadataRepresentation.getValue()}}
diff --git a/src/app/shared/object-list/metadata-representation-list-element/plain-text/plain-text-metadata-list-element.component.ts b/src/app/shared/object-list/metadata-representation-list-element/plain-text/plain-text-metadata-list-element.component.ts index e7cf235c75..e86210a961 100644 --- a/src/app/shared/object-list/metadata-representation-list-element/plain-text/plain-text-metadata-list-element.component.ts +++ b/src/app/shared/object-list/metadata-representation-list-element/plain-text/plain-text-metadata-list-element.component.ts @@ -13,7 +13,7 @@ import { VIEW_MODE_METADATA } from '../../../../+item-page/simple/metadata-repre }) /** * A component for displaying MetadataRepresentation objects in the form of plain text - * It will simply use the value retrieved from MetadataRepresentation.getPrimaryValue() to display as plain text + * It will simply use the value retrieved from MetadataRepresentation.getValue() to display as plain text */ export class PlainTextMetadataListElementComponent extends MetadataRepresentationListElementComponent { }