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 451eff457f..56bd56cc0f 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 @@ -41,7 +41,7 @@ export const relationsToRepresentations = (thisId: string, itemType: string, met } return ids.findById(queryId).pipe( getSucceededRemoteData(), - map((d: RemoteData) => Object.assign(new ItemMetadataRepresentation(itemType), d.payload)) + map((d: RemoteData) => Object.assign(new ItemMetadataRepresentation(), d.payload)) ); } } else { 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 index 77ba30778e..f02625e8c7 100644 --- 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 @@ -7,7 +7,7 @@ import { ItemMetadataRepresentation } from '../../../core/shared/metadata-repres const itemType = 'type'; const metadataRepresentation1 = new MetadatumRepresentation(itemType); -const metadataRepresentation2 = new ItemMetadataRepresentation(itemType); +const metadataRepresentation2 = new ItemMetadataRepresentation(); const representations = [metadataRepresentation1, metadataRepresentation2]; describe('MetadataRepresentationListComponent', () => { 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 d8f0e1c612..f31f8617ad 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 @@ -16,9 +16,15 @@ describe('ItemMetadataRepresentation', () => { item.metadata = metadataMap; for (const itemType of Object.keys(ItemTypeToValue)) { - describe(`when creating an ItemMetadataRepresentation with item-type "${itemType}"`, () => { + describe(`when creating an ItemMetadataRepresentation`, () => { beforeEach(() => { - itemMetadataRepresentation = Object.assign(new ItemMetadataRepresentation(itemType), item); + item.metadata['relationship.type'] = [ + Object.assign(new MetadataValue(), { + value: itemType + }) + ]; + + itemMetadataRepresentation = Object.assign(new ItemMetadataRepresentation(), item); }); it('should have a representation type of item', () => { @@ -30,7 +36,7 @@ describe('ItemMetadataRepresentation', () => { }); it('should return the correct item type', () => { - expect(itemMetadataRepresentation.itemType).toEqual(itemType); + expect(itemMetadataRepresentation.itemType).toEqual(item.firstMetadataValue('relationship.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 b1c63ebee6..7ec1445613 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 @@ -7,7 +7,8 @@ import { hasValue } from '../../../../shared/empty.util'; */ export const ItemTypeToValue = { Default: 'dc.title', - Person: 'dc.contributor.author' + Person: 'dc.contributor.author', + OrgUnit: 'dc.title' }; /** @@ -18,11 +19,8 @@ export class ItemMetadataRepresentation extends Item implements MetadataRepresen /** * The type of item this item can be represented as */ - itemType: string; - - constructor(itemType: string) { - super(); - this.itemType = itemType; + get itemType(): string { + return this.firstMetadataValue('relationship.type'); } /** 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 b083a3a0f9..3b13abf2ef 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 @@ -29,7 +29,7 @@ const mockItem: Item = Object.assign(new Item(), { ] } }); -const mockItemMetadataRepresentation = Object.assign(new ItemMetadataRepresentation(relationType), mockItem); +const mockItemMetadataRepresentation = Object.assign(new ItemMetadataRepresentation(), mockItem); let viewMode = ItemViewMode.Full; describe('ItemTypeSwitcherComponent', () => { diff --git a/src/app/shared/object-list/item-list-element/item-types/orgunit/orgunit-metadata-list-element.component.html b/src/app/shared/object-list/item-list-element/item-types/orgunit/orgunit-metadata-list-element.component.html new file mode 100644 index 0000000000..463770c0ae --- /dev/null +++ b/src/app/shared/object-list/item-list-element/item-types/orgunit/orgunit-metadata-list-element.component.html @@ -0,0 +1,13 @@ + + + + + + + + + + diff --git a/src/app/shared/object-list/item-list-element/item-types/orgunit/orgunit-metadata-list-element.component.ts b/src/app/shared/object-list/item-list-element/item-types/orgunit/orgunit-metadata-list-element.component.ts new file mode 100644 index 0000000000..42c6c6f6a2 --- /dev/null +++ b/src/app/shared/object-list/item-list-element/item-types/orgunit/orgunit-metadata-list-element.component.ts @@ -0,0 +1,15 @@ +import { ItemViewMode, rendersItemType } from '../../../../items/item-type-decorator'; +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('OrgUnit', ItemViewMode.Element, MetadataRepresentationType.Item) +@Component({ + selector: 'ds-orgunit-metadata-list-element', + templateUrl: './orgunit-metadata-list-element.component.html' +}) +/** + * The component for displaying a list element for an item of the type OrgUnit + */ +export class OrgUnitMetadataListElementComponent extends TypedItemSearchResultListElementComponent { +} 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 index 90de549800..5ffa068951 100644 --- 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 @@ -5,7 +5,7 @@ import { ItemMetadataListElementComponent } from './item-metadata-list-element.c import { By } from '@angular/platform-browser'; import { ItemMetadataRepresentation } from '../../../../core/shared/metadata-representation/item/item-metadata-representation.model'; -const mockItemMetadataRepresentation = new ItemMetadataRepresentation('type'); +const mockItemMetadataRepresentation = new ItemMetadataRepresentation(); describe('ItemMetadataListElementComponent', () => { let comp: ItemMetadataListElementComponent; diff --git a/src/app/shared/shared.module.ts b/src/app/shared/shared.module.ts index d86d258a63..329a588f43 100644 --- a/src/app/shared/shared.module.ts +++ b/src/app/shared/shared.module.ts @@ -10,6 +10,7 @@ import { TranslateModule } from '@ngx-translate/core'; import { NgxPaginationModule } from 'ngx-pagination'; import { ItemTypeSwitcherComponent } from './items/switcher/item-type-switcher.component'; +import { OrgUnitMetadataListElementComponent } from './object-list/item-list-element/item-types/orgunit/orgunit-metadata-list-element.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'; @@ -247,6 +248,7 @@ const ENTRY_COMPONENTS = [ PublicationListElementComponent, PersonListElementComponent, PersonMetadataListElementComponent, + OrgUnitMetadataListElementComponent, OrgUnitListElementComponent, ProjectListElementComponent, JournalListElementComponent,