From 7f50d7b23de791217f5d550cfca5ae7e175d666f Mon Sep 17 00:00:00 2001 From: Kristof De Langhe Date: Wed, 9 Oct 2019 17:08:59 +0200 Subject: [PATCH 1/9] 65529: ItemMetadataRepresentation using the virtual metadata value to display names --- .../publication/publication.component.html | 8 ++-- .../publication/publication.component.ts | 6 +-- .../shared/item-relationships-utils.ts | 5 +-- .../item-types/shared/item.component.spec.ts | 2 +- .../item-types/shared/item.component.ts | 45 +------------------ ...item-metadata-representation.model.spec.ts | 31 +++++++------ .../item-metadata-representation.model.ts | 29 +++++------- ...gunit-metadata-list-element.component.html | 12 ++--- ...orgunit-metadata-list-element.component.ts | 4 +- ...erson-metadata-list-element.component.html | 12 ++--- .../person-metadata-list-element.component.ts | 8 ++-- ...a-representation-list-element.component.ts | 17 +++++++ .../publication/publication.component.html | 8 ++-- 13 files changed, 80 insertions(+), 107 deletions(-) create mode 100644 src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-representation-list-element.component.ts 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 abf5225c27..ecc1f73b8e 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 @@ -35,10 +35,10 @@ [items]="projects$ | async" [label]="'relationships.isProjectOf' | translate"> - - + + 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 81e2726e0c..eb0eb9f70a 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 @@ -31,7 +31,7 @@ export class PublicationComponent extends ItemComponent implements OnInit { /** * The organisation units related to this publication */ - orgUnits$: Observable; + orgUnits$: Observable; /** * The journal issues related to this publication @@ -49,9 +49,7 @@ export class PublicationComponent extends ItemComponent implements OnInit { getRelatedItemsByTypeLabel(this.item.id, 'isProjectOfPublication') ); - this.orgUnits$ = this.resolvedRelsAndTypes$.pipe( - getRelatedItemsByTypeLabel(this.item.id, 'isOrgUnitOfPublication') - ); + this.orgUnits$ = this.buildRepresentations('OrgUnit', 'dc.contributor.other'); this.journalIssues$ = this.resolvedRelsAndTypes$.pipe( getRelatedItemsByTypeLabel(this.item.id, 'isJournalIssueOfPublication') diff --git a/src/app/+item-page/simple/item-types/shared/item-relationships-utils.ts b/src/app/+item-page/simple/item-types/shared/item-relationships-utils.ts index 9f120a87dd..228b52d7c7 100644 --- a/src/app/+item-page/simple/item-types/shared/item-relationships-utils.ts +++ b/src/app/+item-page/simple/item-types/shared/item-relationships-utils.ts @@ -117,9 +117,8 @@ export const getRelatedItemsByTypeLabel = (thisId: string, label: string) => * @param parentId 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 = (parentId: string, itemType: string, metadata: MetadataValue[], ids: ItemDataService) => +export const relationsToRepresentations = (parentId: string, itemType: string, metadata: MetadataValue[]) => (source: Observable): Observable => source.pipe( flatMap((rels: Relationship[]) => @@ -139,7 +138,7 @@ export const relationsToRepresentations = (parentId: string, itemType: string, m return leftItem.payload; } }), - map((item: Item) => Object.assign(new ItemMetadataRepresentation(), item)) + map((item: Item) => Object.assign(new ItemMetadataRepresentation(metadatum), item)) ); } } else { 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 3f525e6a25..4414d9a713 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 @@ -413,7 +413,7 @@ describe('ItemComponent', () => { representations.subscribe((reps: MetadataRepresentation[]) => { expect(reps[0].getValue()).toEqual('First value'); expect(reps[1].getValue()).toEqual('Second value'); - expect(reps[2].getValue()).toEqual('related item'); + expect(reps[2].getValue()).toEqual('Third value'); 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 556496fe49..297a333eeb 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 @@ -1,7 +1,6 @@ import { Component, Inject, OnInit } from '@angular/core'; import { Observable , zip as observableZip, combineLatest as observableCombineLatest } from 'rxjs'; 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/item-relationships/relationship-type.model'; @@ -10,49 +9,7 @@ import { Item } from '../../../../core/shared/item.model'; import { getRemoteDataPayload, getSucceededRemoteData } from '../../../../core/shared/operators'; 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 { MetadatumRepresentation } from '../../../../core/shared/metadata-representation/metadatum/metadatum-representation.model'; -import { of } from 'rxjs/internal/observable/of'; -import { MetadataValue } from '../../../../core/shared/metadata.models'; -import { compareArraysUsingIds } from './item-relationships-utils'; - -/** - * 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 - */ -export const relationsToRepresentations = (thisId: string, itemType: string, metadata: MetadataValue[]) => - (source: Observable): Observable => - source.pipe( - flatMap((rels: Relationship[]) => - observableZip( - ...metadata - .map((metadatum: any) => Object.assign(new MetadataValue(), metadatum)) - .map((metadatum: MetadataValue) => { - if (metadatum.isVirtual) { - const matchingRels = rels.filter((rel: Relationship) => ('' + rel.id) === metadatum.virtualValue); - if (matchingRels.length > 0) { - const matchingRel = matchingRels[0]; - return observableCombineLatest(matchingRel.leftItem, matchingRel.rightItem).pipe( - filter(([leftItem, rightItem]) => leftItem.hasSucceeded && rightItem.hasSucceeded), - map(([leftItem, rightItem]) => { - if (leftItem.payload.id === thisId) { - return rightItem.payload; - } else if (rightItem.payload.id === thisId) { - return leftItem.payload; - } - }), - map((item: Item) => Object.assign(new ItemMetadataRepresentation(), item)) - ); - } - } else { - return of(Object.assign(new MetadatumRepresentation(itemType), metadatum)); - } - }) - ) - ) - ); +import { compareArraysUsingIds, relationsToRepresentations } from './item-relationships-utils'; @Component({ selector: 'ds-item', 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 f31f8617ad..791fc43fbe 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,21 +1,27 @@ import { MetadataRepresentationType } from '../metadata-representation.model'; -import { ItemMetadataRepresentation, ItemTypeToValue } from './item-metadata-representation.model'; +import { ItemMetadataRepresentation } from './item-metadata-representation.model'; import { Item } from '../../item.model'; -import { MetadataMap, MetadataValue } from '../../metadata.models'; +import { MetadataValue } from '../../metadata.models'; describe('ItemMetadataRepresentation', () => { const valuePrefix = 'Test value for '; const item = new Item(); + const itemType = 'Item Type'; let itemMetadataRepresentation: ItemMetadataRepresentation; - const metadataMap = new MetadataMap(); - for (const key of Object.keys(ItemTypeToValue)) { - metadataMap[ItemTypeToValue[key]] = [Object.assign(new MetadataValue(), { - value: `${valuePrefix}${ItemTypeToValue[key]}` - })]; - } - item.metadata = metadataMap; + item.metadata = { + 'dc.title': [ + { + value: `${valuePrefix}dc.title` + } + ] as MetadataValue[], + 'dc.contributor.author': [ + { + value: `${valuePrefix}dc.contributor.author` + } + ] as MetadataValue[] + }; - for (const itemType of Object.keys(ItemTypeToValue)) { + for (const metadataField of Object.keys(item.metadata)) { describe(`when creating an ItemMetadataRepresentation`, () => { beforeEach(() => { item.metadata['relationship.type'] = [ @@ -23,8 +29,7 @@ describe('ItemMetadataRepresentation', () => { value: itemType }) ]; - - itemMetadataRepresentation = Object.assign(new ItemMetadataRepresentation(), item); + itemMetadataRepresentation = Object.assign(new ItemMetadataRepresentation(item.metadata[metadataField][0]), item); }); it('should have a representation type of item', () => { @@ -32,7 +37,7 @@ describe('ItemMetadataRepresentation', () => { }); it('should return the correct value when calling getValue', () => { - expect(itemMetadataRepresentation.getValue()).toEqual(`${valuePrefix}${ItemTypeToValue[itemType]}`); + expect(itemMetadataRepresentation.getValue()).toEqual(`${valuePrefix}${metadataField}`); }); 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 7ec1445613..b688673b65 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 @@ -1,21 +1,22 @@ 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 value - */ -export const ItemTypeToValue = { - Default: 'dc.title', - Person: 'dc.contributor.author', - OrgUnit: 'dc.title' -}; +import { MetadataValue } from '../../metadata.models'; /** * This class determines which fields to use when rendering an Item as a metadata value. */ export class ItemMetadataRepresentation extends Item implements MetadataRepresentation { + /** + * The virtual metadata value representing this item + */ + virtualMetadata: MetadataValue; + + constructor(virtualMetadata: MetadataValue) { + super(); + this.virtualMetadata = virtualMetadata; + } + /** * The type of item this item can be represented as */ @@ -34,13 +35,7 @@ export class ItemMetadataRepresentation extends Item implements MetadataRepresen * Get the value to display, depending on the itemType */ getValue(): string { - let metadata; - if (hasValue(ItemTypeToValue[this.itemType])) { - metadata = ItemTypeToValue[this.itemType]; - } else { - metadata = ItemTypeToValue.Default; - } - return this.firstMetadataValue(metadata); + return this.virtualMetadata.value; } } diff --git a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-metadata-list-element.component.html b/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-metadata-list-element.component.html index ea429e87c6..0977413722 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-metadata-list-element.component.html +++ b/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-metadata-list-element.component.html @@ -1,13 +1,13 @@ - - + - - + + diff --git a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-metadata-list-element.component.ts b/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-metadata-list-element.component.ts index d59e5c6cc3..21d0d9f86b 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-metadata-list-element.component.ts +++ b/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-metadata-list-element.component.ts @@ -1,7 +1,7 @@ import { Component } from '@angular/core'; import { MetadataRepresentationType } from '../../../../core/shared/metadata-representation/metadata-representation.model'; import { ItemViewMode, rendersItemType } from '../../../../shared/items/item-type-decorator'; -import { TypedItemSearchResultListElementComponent } from '../../../../shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component'; +import { ItemMetadataRepresentationListElementComponent } from '../../../../shared/object-list/metadata-representation-list-element/item/item-metadata-representation-list-element.component'; @rendersItemType('OrgUnit', ItemViewMode.Element, MetadataRepresentationType.Item) @Component({ @@ -11,5 +11,5 @@ import { TypedItemSearchResultListElementComponent } from '../../../../shared/ob /** * The component for displaying a list element for an item of the type OrgUnit */ -export class OrgUnitMetadataListElementComponent extends TypedItemSearchResultListElementComponent { +export class OrgUnitMetadataListElementComponent extends ItemMetadataRepresentationListElementComponent { } diff --git a/src/app/entity-groups/research-entities/item-list-elements/person/person-metadata-list-element.component.html b/src/app/entity-groups/research-entities/item-list-elements/person/person-metadata-list-element.component.html index 1125c2fb9b..69cf463b3f 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/person/person-metadata-list-element.component.html +++ b/src/app/entity-groups/research-entities/item-list-elements/person/person-metadata-list-element.component.html @@ -1,15 +1,15 @@ - - + - - + + diff --git a/src/app/entity-groups/research-entities/item-list-elements/person/person-metadata-list-element.component.ts b/src/app/entity-groups/research-entities/item-list-elements/person/person-metadata-list-element.component.ts index b036768d0a..b69b70c7f1 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/person/person-metadata-list-element.component.ts +++ b/src/app/entity-groups/research-entities/item-list-elements/person/person-metadata-list-element.component.ts @@ -1,7 +1,9 @@ import { Component } from '@angular/core'; import { ItemViewMode, rendersItemType } from '../../../../shared/items/item-type-decorator'; -import { MetadataRepresentationType } from '../../../../core/shared/metadata-representation/metadata-representation.model'; -import { TypedItemSearchResultListElementComponent } from '../../../../shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component'; +import { + MetadataRepresentationType +} from '../../../../core/shared/metadata-representation/metadata-representation.model'; +import { ItemMetadataRepresentationListElementComponent } from '../../../../shared/object-list/metadata-representation-list-element/item/item-metadata-representation-list-element.component'; @rendersItemType('Person', ItemViewMode.Element, MetadataRepresentationType.Item) @Component({ @@ -11,5 +13,5 @@ import { TypedItemSearchResultListElementComponent } from '../../../../shared/ob /** * The component for displaying a list element for an item of the type Person */ -export class PersonMetadataListElementComponent extends TypedItemSearchResultListElementComponent { +export class PersonMetadataListElementComponent extends ItemMetadataRepresentationListElementComponent { } diff --git a/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-representation-list-element.component.ts b/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-representation-list-element.component.ts new file mode 100644 index 0000000000..4d07014384 --- /dev/null +++ b/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-representation-list-element.component.ts @@ -0,0 +1,17 @@ +import { MetadataRepresentationListElementComponent } from '../metadata-representation-list-element.component'; +import { Component, Inject } from '@angular/core'; +import { ITEM } from '../../../items/switcher/item-type-switcher.component'; +import { MetadataRepresentation } from '../../../../core/shared/metadata-representation/metadata-representation.model'; + +@Component({ + selector: 'ds-item-metadata-representation-list-element', + template: '' +}) +/** + * An abstract class for displaying a single ItemMetadataRepresentation + */ +export class ItemMetadataRepresentationListElementComponent extends MetadataRepresentationListElementComponent { + constructor(@Inject(ITEM) public metadataRepresentation: MetadataRepresentation) { + super(metadataRepresentation); + } +} diff --git a/themes/mantis/app/+item-page/simple/item-types/publication/publication.component.html b/themes/mantis/app/+item-page/simple/item-types/publication/publication.component.html index 6b6f484183..f7e71d248f 100644 --- a/themes/mantis/app/+item-page/simple/item-types/publication/publication.component.html +++ b/themes/mantis/app/+item-page/simple/item-types/publication/publication.component.html @@ -67,10 +67,10 @@
- - + +
Date: Thu, 10 Oct 2019 10:12:28 +0200 Subject: [PATCH 2/9] 65529: Revert OrgUnit list changes on publication --- .../item-types/publication/publication.component.html | 8 ++++---- .../item-types/publication/publication.component.ts | 6 ++++-- .../item-types/publication/publication.component.html | 8 ++++---- 3 files changed, 12 insertions(+), 10 deletions(-) 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 ecc1f73b8e..abf5225c27 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 @@ -35,10 +35,10 @@ [items]="projects$ | async" [label]="'relationships.isProjectOf' | translate"> - - + + 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 eb0eb9f70a..81e2726e0c 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 @@ -31,7 +31,7 @@ export class PublicationComponent extends ItemComponent implements OnInit { /** * The organisation units related to this publication */ - orgUnits$: Observable; + orgUnits$: Observable; /** * The journal issues related to this publication @@ -49,7 +49,9 @@ export class PublicationComponent extends ItemComponent implements OnInit { getRelatedItemsByTypeLabel(this.item.id, 'isProjectOfPublication') ); - this.orgUnits$ = this.buildRepresentations('OrgUnit', 'dc.contributor.other'); + this.orgUnits$ = this.resolvedRelsAndTypes$.pipe( + getRelatedItemsByTypeLabel(this.item.id, 'isOrgUnitOfPublication') + ); this.journalIssues$ = this.resolvedRelsAndTypes$.pipe( getRelatedItemsByTypeLabel(this.item.id, 'isJournalIssueOfPublication') diff --git a/themes/mantis/app/+item-page/simple/item-types/publication/publication.component.html b/themes/mantis/app/+item-page/simple/item-types/publication/publication.component.html index f7e71d248f..6b6f484183 100644 --- a/themes/mantis/app/+item-page/simple/item-types/publication/publication.component.html +++ b/themes/mantis/app/+item-page/simple/item-types/publication/publication.component.html @@ -67,10 +67,10 @@
- - + +
Date: Tue, 15 Oct 2019 13:58:03 +0200 Subject: [PATCH 3/9] 65529: AoT build error fixes --- .../metadata-representation-list.component.spec.ts | 2 +- .../items/switcher/item-type-switcher.component.spec.ts | 2 +- .../item/item-metadata-list-element.component.spec.ts | 2 +- .../item-metadata-representation-list-element.component.ts | 4 ++-- src/app/shared/shared.module.ts | 4 +++- 5 files changed, 8 insertions(+), 6 deletions(-) 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 f02625e8c7..da2af9f2c1 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(); +const metadataRepresentation2 = new ItemMetadataRepresentation(Object.assign({})); const representations = [metadataRepresentation1, metadataRepresentation2]; describe('MetadataRepresentationListComponent', () => { 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 76389201c5..1c1612744a 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 @@ -28,7 +28,7 @@ const mockItem: Item = Object.assign(new Item(), { ] } }); -const mockItemMetadataRepresentation = Object.assign(new ItemMetadataRepresentation(), mockItem); +const mockItemMetadataRepresentation = Object.assign(new ItemMetadataRepresentation(Object.assign({})), mockItem); let viewMode = ItemViewMode.Full; describe('ItemTypeSwitcherComponent', () => { 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 5ffa068951..269207bef8 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(); +const mockItemMetadataRepresentation = new ItemMetadataRepresentation(Object.assign({})); describe('ItemMetadataListElementComponent', () => { let comp: ItemMetadataListElementComponent; diff --git a/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-representation-list-element.component.ts b/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-representation-list-element.component.ts index 4d07014384..0fdca0d429 100644 --- a/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-representation-list-element.component.ts +++ b/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-representation-list-element.component.ts @@ -1,7 +1,7 @@ import { MetadataRepresentationListElementComponent } from '../metadata-representation-list-element.component'; import { Component, Inject } from '@angular/core'; import { ITEM } from '../../../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'; @Component({ selector: 'ds-item-metadata-representation-list-element', @@ -11,7 +11,7 @@ import { MetadataRepresentation } from '../../../../core/shared/metadata-represe * An abstract class for displaying a single ItemMetadataRepresentation */ export class ItemMetadataRepresentationListElementComponent extends MetadataRepresentationListElementComponent { - constructor(@Inject(ITEM) public metadataRepresentation: MetadataRepresentation) { + constructor(@Inject(ITEM) public metadataRepresentation: ItemMetadataRepresentation) { super(metadataRepresentation); } } diff --git a/src/app/shared/shared.module.ts b/src/app/shared/shared.module.ts index 2367652dd3..2d9fb1588a 100644 --- a/src/app/shared/shared.module.ts +++ b/src/app/shared/shared.module.ts @@ -143,6 +143,7 @@ import { DsoInputSuggestionsComponent } from './input-suggestions/dso-input-sugg import { TypedItemSearchResultGridElementComponent } from './object-grid/item-grid-element/item-types/typed-item-search-result-grid-element.component'; import { PublicationGridElementComponent } from './object-grid/item-grid-element/item-types/publication/publication-grid-element.component'; import { ItemTypeBadgeComponent } from './object-list/item-type-badge/item-type-badge.component'; +import { ItemMetadataRepresentationListElementComponent } from './object-list/metadata-representation-list-element/item/item-metadata-representation-list-element.component'; const MODULES = [ // Do NOT include UniversalModule, HttpModule, or JsonpModule here @@ -310,7 +311,8 @@ const ENTRY_COMPONENTS = [ StartsWithTextComponent, PlainTextMetadataListElementComponent, ItemMetadataListElementComponent, - MetadataRepresentationListElementComponent + MetadataRepresentationListElementComponent, + ItemMetadataRepresentationListElementComponent ]; const SHARED_ITEM_PAGE_COMPONENTS = [ From d5198283ffcaeac3a353a2e01b8ff0ebafcb4e5b Mon Sep 17 00:00:00 2001 From: Kristof De Langhe Date: Thu, 24 Oct 2019 12:00:20 +0200 Subject: [PATCH 4/9] 65529: Remove line-break from imports --- .../person/person-metadata-list-element.component.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/app/entity-groups/research-entities/item-list-elements/person/person-metadata-list-element.component.ts b/src/app/entity-groups/research-entities/item-list-elements/person/person-metadata-list-element.component.ts index b69b70c7f1..35fbcd1173 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/person/person-metadata-list-element.component.ts +++ b/src/app/entity-groups/research-entities/item-list-elements/person/person-metadata-list-element.component.ts @@ -1,8 +1,6 @@ import { Component } from '@angular/core'; import { ItemViewMode, rendersItemType } from '../../../../shared/items/item-type-decorator'; -import { - MetadataRepresentationType -} from '../../../../core/shared/metadata-representation/metadata-representation.model'; +import { MetadataRepresentationType } from '../../../../core/shared/metadata-representation/metadata-representation.model'; import { ItemMetadataRepresentationListElementComponent } from '../../../../shared/object-list/metadata-representation-list-element/item/item-metadata-representation-list-element.component'; @rendersItemType('Person', ItemViewMode.Element, MetadataRepresentationType.Item) From 95b2feb868595847ef3913ab27362946299e10e6 Mon Sep 17 00:00:00 2001 From: Antoine Snyers Date: Thu, 24 Oct 2019 12:48:22 +0200 Subject: [PATCH 5/9] Update webdriver-manager library --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 66cc55087f..34e77a8928 100644 --- a/package.json +++ b/package.json @@ -236,7 +236,7 @@ "tslint": "5.11.0", "typedoc": "^0.9.0", "typescript": "^2.9.1", - "webdriver-manager": "^12.1.6", + "webdriver-manager": "^12.1.7", "webpack": "^4.17.1", "webpack-bundle-analyzer": "^3.3.2", "webpack-dev-middleware": "3.2.0", diff --git a/yarn.lock b/yarn.lock index 66346c8438..854c6add88 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11355,10 +11355,10 @@ webdriver-manager@^12.0.6: semver "^5.3.0" xml2js "^0.4.17" -webdriver-manager@^12.1.6: - version "12.1.6" - resolved "https://registry.yarnpkg.com/webdriver-manager/-/webdriver-manager-12.1.6.tgz#9e5410c506d1a7e0a7aa6af91ba3d5bb37f362b6" - integrity sha512-B1mOycNCrbk7xODw7Jgq/mdD3qzPxMaTsnKIQDy2nXlQoyjTrJTTD0vRpEZI9b8RibPEyQvh9zIZ0M1mpOxS3w== +webdriver-manager@^12.1.7: + version "12.1.7" + resolved "https://registry.yarnpkg.com/webdriver-manager/-/webdriver-manager-12.1.7.tgz#ed4eaee8f906b33c146e869b55e850553a1b1162" + integrity sha512-XINj6b8CYuUYC93SG3xPkxlyUc3IJbD6Vvo75CVGuG9uzsefDzWQrhz0Lq8vbPxtb4d63CZdYophF8k8Or/YiA== dependencies: adm-zip "^0.4.9" chalk "^1.1.1" From bbb2570f8788bb3b6cb563fa145c6f69e559196a Mon Sep 17 00:00:00 2001 From: Antoine Snyers Date: Thu, 24 Oct 2019 12:48:22 +0200 Subject: [PATCH 6/9] Update webdriver-manager library --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 66cc55087f..34e77a8928 100644 --- a/package.json +++ b/package.json @@ -236,7 +236,7 @@ "tslint": "5.11.0", "typedoc": "^0.9.0", "typescript": "^2.9.1", - "webdriver-manager": "^12.1.6", + "webdriver-manager": "^12.1.7", "webpack": "^4.17.1", "webpack-bundle-analyzer": "^3.3.2", "webpack-dev-middleware": "3.2.0", diff --git a/yarn.lock b/yarn.lock index 66346c8438..854c6add88 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11355,10 +11355,10 @@ webdriver-manager@^12.0.6: semver "^5.3.0" xml2js "^0.4.17" -webdriver-manager@^12.1.6: - version "12.1.6" - resolved "https://registry.yarnpkg.com/webdriver-manager/-/webdriver-manager-12.1.6.tgz#9e5410c506d1a7e0a7aa6af91ba3d5bb37f362b6" - integrity sha512-B1mOycNCrbk7xODw7Jgq/mdD3qzPxMaTsnKIQDy2nXlQoyjTrJTTD0vRpEZI9b8RibPEyQvh9zIZ0M1mpOxS3w== +webdriver-manager@^12.1.7: + version "12.1.7" + resolved "https://registry.yarnpkg.com/webdriver-manager/-/webdriver-manager-12.1.7.tgz#ed4eaee8f906b33c146e869b55e850553a1b1162" + integrity sha512-XINj6b8CYuUYC93SG3xPkxlyUc3IJbD6Vvo75CVGuG9uzsefDzWQrhz0Lq8vbPxtb4d63CZdYophF8k8Or/YiA== dependencies: adm-zip "^0.4.9" chalk "^1.1.1" From b1ff5765a61da372d463c9bac00fe3084459b765 Mon Sep 17 00:00:00 2001 From: lotte Date: Thu, 7 Nov 2019 16:41:28 +0100 Subject: [PATCH 7/9] Fixes after merge --- .../search-filters/search-filters.component.ts | 2 +- .../journal-issue/journal-issue.component.spec.ts | 7 +------ ...rg-unit-item-metadata-list-element.component.html | 4 ++-- ...unit-item-metadata-list-element.component.spec.ts | 4 +++- .../org-unit-item-metadata-list-element.component.ts | 5 ++--- .../person-item-metadata-list-element.component.html | 4 ++-- ...rson-item-metadata-list-element.component.spec.ts | 5 ++++- .../person-item-metadata-list-element.component.ts | 5 ++--- .../metadata-representation.decorator.spec.ts | 8 ++++---- .../listable-object.decorator.spec.ts | 12 ++++++------ ...metadata-representation-list-element.component.ts | 7 ++----- 11 files changed, 29 insertions(+), 34 deletions(-) diff --git a/src/app/+search-page/search-filters/search-filters.component.ts b/src/app/+search-page/search-filters/search-filters.component.ts index 9d0dfceb15..69bbb6234b 100644 --- a/src/app/+search-page/search-filters/search-filters.component.ts +++ b/src/app/+search-page/search-filters/search-filters.component.ts @@ -71,7 +71,7 @@ export class SearchFiltersComponent implements OnInit { /** * @returns {string} The base path to the search page, or the current page when inPlaceSearch is true */ - private getSearchLink(): string { + getSearchLink(): string { if (this.inPlaceSearch) { return './'; } diff --git a/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.spec.ts b/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.spec.ts index 00403473a7..4c67708b8b 100644 --- a/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.spec.ts +++ b/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.spec.ts @@ -1,13 +1,8 @@ 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 { JournalIssueComponent } from './journal-issue.component'; -import { of as observableOf } from 'rxjs'; -import { - createRelationshipsObservable, - getItemPageFieldsTest -} from '../../../../+item-page/simple/item-types/shared/item.component.spec'; +import { createRelationshipsObservable, getItemPageFieldsTest } from '../../../../+item-page/simple/item-types/shared/item.component.spec'; import { createSuccessfulRemoteDataObject$ } from '../../../../shared/testing/utils'; const mockItem: Item = Object.assign(new Item(), { diff --git a/src/app/entity-groups/research-entities/metadata-representations/org-unit/org-unit-item-metadata-list-element.component.html b/src/app/entity-groups/research-entities/metadata-representations/org-unit/org-unit-item-metadata-list-element.component.html index bdeb37dcd8..0977413722 100644 --- a/src/app/entity-groups/research-entities/metadata-representations/org-unit/org-unit-item-metadata-list-element.component.html +++ b/src/app/entity-groups/research-entities/metadata-representations/org-unit/org-unit-item-metadata-list-element.component.html @@ -8,6 +8,6 @@ + [innerHTML]="metadataRepresentation.getValue()" + [tooltip]="metadataRepresentation.allMetadata(['dc.description']).length > 0 ? descTemplate : null"> diff --git a/src/app/entity-groups/research-entities/metadata-representations/org-unit/org-unit-item-metadata-list-element.component.spec.ts b/src/app/entity-groups/research-entities/metadata-representations/org-unit/org-unit-item-metadata-list-element.component.spec.ts index 8616e4fa01..7d27b605ec 100644 --- a/src/app/entity-groups/research-entities/metadata-representations/org-unit/org-unit-item-metadata-list-element.component.spec.ts +++ b/src/app/entity-groups/research-entities/metadata-representations/org-unit/org-unit-item-metadata-list-element.component.spec.ts @@ -5,11 +5,13 @@ import { ItemMetadataRepresentation } from '../../../../core/shared/metadata-rep import { OrgUnitItemMetadataListElementComponent } from './org-unit-item-metadata-list-element.component'; import { Item } from '../../../../core/shared/item.model'; import { TooltipModule } from 'ngx-bootstrap'; +import { MetadataValue } from '../../../../core/shared/metadata.models'; const description = 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.'; const organisation = 'Anonymous'; const mockItem = Object.assign(new Item(), { metadata: { 'dc.description': [{ value: description }], 'organization.legalName': [{ value: organisation }] } }); -const mockItemMetadataRepresentation = Object.assign(new ItemMetadataRepresentation(), mockItem); +const virtMD = Object.assign(new MetadataValue(), { value: organisation }); +const mockItemMetadataRepresentation = Object.assign(new ItemMetadataRepresentation(virtMD), mockItem); describe('OrgUnitItemMetadataListElementComponent', () => { let comp: OrgUnitItemMetadataListElementComponent; diff --git a/src/app/entity-groups/research-entities/metadata-representations/org-unit/org-unit-item-metadata-list-element.component.ts b/src/app/entity-groups/research-entities/metadata-representations/org-unit/org-unit-item-metadata-list-element.component.ts index e0bb542241..183bebe10c 100644 --- a/src/app/entity-groups/research-entities/metadata-representations/org-unit/org-unit-item-metadata-list-element.component.ts +++ b/src/app/entity-groups/research-entities/metadata-representations/org-unit/org-unit-item-metadata-list-element.component.ts @@ -1,7 +1,7 @@ import { Component } from '@angular/core'; import { metadataRepresentationComponent } from '../../../../shared/metadata-representation/metadata-representation.decorator'; import { MetadataRepresentationType } from '../../../../core/shared/metadata-representation/metadata-representation.model'; -import { ItemMetadataRepresentation } from '../../../../core/shared/metadata-representation/item/item-metadata-representation.model'; +import { ItemMetadataRepresentationListElementComponent } from '../../../../shared/object-list/metadata-representation-list-element/item/item-metadata-representation-list-element.component'; @metadataRepresentationComponent('OrgUnit', MetadataRepresentationType.Item) @Component({ @@ -11,6 +11,5 @@ import { ItemMetadataRepresentation } from '../../../../core/shared/metadata-rep /** * The component for displaying an item of the type OrgUnit as a metadata field */ -export class OrgUnitItemMetadataListElementComponent { - metadataRepresentation: ItemMetadataRepresentation; +export class OrgUnitItemMetadataListElementComponent extends ItemMetadataRepresentationListElementComponent { } diff --git a/src/app/entity-groups/research-entities/metadata-representations/person/person-item-metadata-list-element.component.html b/src/app/entity-groups/research-entities/metadata-representations/person/person-item-metadata-list-element.component.html index fdc9dd8943..69cf463b3f 100644 --- a/src/app/entity-groups/research-entities/metadata-representations/person/person-item-metadata-list-element.component.html +++ b/src/app/entity-groups/research-entities/metadata-representations/person/person-item-metadata-list-element.component.html @@ -10,6 +10,6 @@ + [innerHTML]="metadataRepresentation.getValue()" + [tooltip]="metadataRepresentation.allMetadata(['person.jobTitle']).length > 0 ? descTemplate : null"> diff --git a/src/app/entity-groups/research-entities/metadata-representations/person/person-item-metadata-list-element.component.spec.ts b/src/app/entity-groups/research-entities/metadata-representations/person/person-item-metadata-list-element.component.spec.ts index 0d4786f37e..1081e45884 100644 --- a/src/app/entity-groups/research-entities/metadata-representations/person/person-item-metadata-list-element.component.spec.ts +++ b/src/app/entity-groups/research-entities/metadata-representations/person/person-item-metadata-list-element.component.spec.ts @@ -5,12 +5,15 @@ import { ItemMetadataRepresentation } from '../../../../core/shared/metadata-rep import { Item } from '../../../../core/shared/item.model'; import { PersonItemMetadataListElementComponent } from './person-item-metadata-list-element.component'; import { TooltipModule } from 'ngx-bootstrap'; +import { MetadataValue } from '../../../../core/shared/metadata.models'; const jobTitle ='Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.'; const firstName = 'Joe'; const lastName = 'Anonymous'; const mockItem = Object.assign(new Item(), { metadata: { 'person.jobTitle': [{ value: jobTitle }], 'person.givenName': [{ value: firstName }], 'person.familyName': [{ value: lastName }] } }); -const mockItemMetadataRepresentation = Object.assign(new ItemMetadataRepresentation(), mockItem); +const virtMD = Object.assign(new MetadataValue(), { value: lastName + ', ' + firstName }); + +const mockItemMetadataRepresentation = Object.assign(new ItemMetadataRepresentation(virtMD), mockItem); describe('PersonItemMetadataListElementComponent', () => { let comp: PersonItemMetadataListElementComponent; diff --git a/src/app/entity-groups/research-entities/metadata-representations/person/person-item-metadata-list-element.component.ts b/src/app/entity-groups/research-entities/metadata-representations/person/person-item-metadata-list-element.component.ts index e39eb05948..f3d0a28fda 100644 --- a/src/app/entity-groups/research-entities/metadata-representations/person/person-item-metadata-list-element.component.ts +++ b/src/app/entity-groups/research-entities/metadata-representations/person/person-item-metadata-list-element.component.ts @@ -1,7 +1,7 @@ import { Component } from '@angular/core'; import { metadataRepresentationComponent } from '../../../../shared/metadata-representation/metadata-representation.decorator'; import { MetadataRepresentationType } from '../../../../core/shared/metadata-representation/metadata-representation.model'; -import { ItemMetadataRepresentation } from '../../../../core/shared/metadata-representation/item/item-metadata-representation.model'; +import { ItemMetadataRepresentationListElementComponent } from '../../../../shared/object-list/metadata-representation-list-element/item/item-metadata-representation-list-element.component'; @metadataRepresentationComponent('Person', MetadataRepresentationType.Item) @Component({ @@ -11,6 +11,5 @@ import { ItemMetadataRepresentation } from '../../../../core/shared/metadata-rep /** * The component for displaying an item of the type Person as a metadata field */ -export class PersonItemMetadataListElementComponent { - metadataRepresentation: ItemMetadataRepresentation; +export class PersonItemMetadataListElementComponent extends ItemMetadataRepresentationListElementComponent { } diff --git a/src/app/shared/metadata-representation/metadata-representation.decorator.spec.ts b/src/app/shared/metadata-representation/metadata-representation.decorator.spec.ts index 38d64d9ff5..0ca7ebb9b9 100644 --- a/src/app/shared/metadata-representation/metadata-representation.decorator.spec.ts +++ b/src/app/shared/metadata-representation/metadata-representation.decorator.spec.ts @@ -27,14 +27,14 @@ describe('MetadataRepresentation decorator function', () => { metadataRepresentationComponent(key + type1, MetadataRepresentationType.AuthorityControlled)(Test1Authority); metadataRepresentationComponent(key + type2, MetadataRepresentationType.Item)(Test2Item); - metadataRepresentationComponent(key + type2, MetadataRepresentationType.Item, Context.Submission)(Test2ItemSubmission); + metadataRepresentationComponent(key + type2, MetadataRepresentationType.Item, Context.Workspace)(Test2ItemSubmission); - metadataRepresentationComponent(key + type3, MetadataRepresentationType.Item, Context.Submission)(Test3ItemSubmission); + metadataRepresentationComponent(key + type3, MetadataRepresentationType.Item, Context.Workspace)(Test3ItemSubmission); } describe('If there\'s an exact match', () => { it('should return the matching class', () => { - const component = getMetadataRepresentationComponent(prefix + type3, MetadataRepresentationType.Item, Context.Submission); + const component = getMetadataRepresentationComponent(prefix + type3, MetadataRepresentationType.Item, Context.Workspace); expect(component).toEqual(Test3ItemSubmission); }); }); @@ -42,7 +42,7 @@ describe('MetadataRepresentation decorator function', () => { describe('If there isn\'nt an exact match', () => { describe('If there is a match for the entity type and representation type', () => { it('should return the class with the matching entity type and representation type and default context', () => { - const component = getMetadataRepresentationComponent(prefix + type1, MetadataRepresentationType.AuthorityControlled, Context.Submission); + const component = getMetadataRepresentationComponent(prefix + type1, MetadataRepresentationType.AuthorityControlled, Context.Workspace); expect(component).toEqual(Test1Authority); }); }); diff --git a/src/app/shared/object-collection/shared/listable-object/listable-object.decorator.spec.ts b/src/app/shared/object-collection/shared/listable-object/listable-object.decorator.spec.ts index 2873c4fce8..0143984bd6 100644 --- a/src/app/shared/object-collection/shared/listable-object/listable-object.decorator.spec.ts +++ b/src/app/shared/object-collection/shared/listable-object/listable-object.decorator.spec.ts @@ -22,10 +22,10 @@ describe('ListableObject decorator function', () => { listableObjectComponent(type1, ViewMode.GridElement)(Test1Grid); listableObjectComponent(type2, ViewMode.ListElement)(Test2List); - listableObjectComponent(type2, ViewMode.ListElement, Context.Submission)(Test2ListSubmission); + listableObjectComponent(type2, ViewMode.ListElement, Context.Workspace)(Test2ListSubmission); listableObjectComponent(type3, ViewMode.ListElement)(Test3List); - listableObjectComponent(type3, ViewMode.DetailedListElement, Context.Submission)(Test3DetailedSubmission); + listableObjectComponent(type3, ViewMode.DetailedListElement, Context.Workspace)(Test3DetailedSubmission); }); const gridDecorator = listableObjectComponent('Item', ViewMode.GridElement); @@ -40,10 +40,10 @@ describe('ListableObject decorator function', () => { describe('If there\'s an exact match', () => { it('should return the matching class', () => { - const component = getListableObjectComponent([type3], ViewMode.DetailedListElement, Context.Submission); + const component = getListableObjectComponent([type3], ViewMode.DetailedListElement, Context.Workspace); expect(component).toEqual(Test3DetailedSubmission); - const component2 = getListableObjectComponent([type3, type2], ViewMode.ListElement, Context.Submission); + const component2 = getListableObjectComponent([type3, type2], ViewMode.ListElement, Context.Workspace); expect(component2).toEqual(Test2ListSubmission); }); }); @@ -51,10 +51,10 @@ describe('ListableObject decorator function', () => { describe('If there isn\'nt an exact match', () => { describe('If there is a match for one of the entity types and the view mode', () => { it('should return the class with the matching entity type and view mode and default context', () => { - const component = getListableObjectComponent([type3], ViewMode.ListElement, Context.Submission); + const component = getListableObjectComponent([type3], ViewMode.ListElement, Context.Workspace); expect(component).toEqual(Test3List); - const component2 = getListableObjectComponent([type3, type1], ViewMode.GridElement, Context.Submission); + const component2 = getListableObjectComponent([type3, type1], ViewMode.GridElement, Context.Workspace); expect(component2).toEqual(Test1Grid); }); }); diff --git a/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-representation-list-element.component.ts b/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-representation-list-element.component.ts index 0fdca0d429..6c4d300e99 100644 --- a/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-representation-list-element.component.ts +++ b/src/app/shared/object-list/metadata-representation-list-element/item/item-metadata-representation-list-element.component.ts @@ -1,6 +1,5 @@ import { MetadataRepresentationListElementComponent } from '../metadata-representation-list-element.component'; -import { Component, Inject } from '@angular/core'; -import { ITEM } from '../../../items/switcher/item-type-switcher.component'; +import { Component } from '@angular/core'; import { ItemMetadataRepresentation } from '../../../../core/shared/metadata-representation/item/item-metadata-representation.model'; @Component({ @@ -11,7 +10,5 @@ import { ItemMetadataRepresentation } from '../../../../core/shared/metadata-rep * An abstract class for displaying a single ItemMetadataRepresentation */ export class ItemMetadataRepresentationListElementComponent extends MetadataRepresentationListElementComponent { - constructor(@Inject(ITEM) public metadataRepresentation: ItemMetadataRepresentation) { - super(metadataRepresentation); - } + metadataRepresentation: ItemMetadataRepresentation; } From 575a1420224c67eb289959048782571b1be37e1c Mon Sep 17 00:00:00 2001 From: lotte Date: Thu, 7 Nov 2019 16:58:05 +0100 Subject: [PATCH 8/9] split up submission context --- .../my-dspace-page.component.html | 3 ++- .../+my-dspace-page/my-dspace-page.component.ts | 16 +++++++++++++++- .../my-dspace-results.component.ts | 2 +- src/app/core/shared/context.model.ts | 3 ++- ...h-result-list-element-submission.component.ts | 3 ++- 5 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/app/+my-dspace-page/my-dspace-page.component.html b/src/app/+my-dspace-page/my-dspace-page.component.html index 4c691028fc..e6d1a5c80d 100644 --- a/src/app/+my-dspace-page/my-dspace-page.component.html +++ b/src/app/+my-dspace-page/my-dspace-page.component.html @@ -39,7 +39,8 @@
+ [searchConfig]="searchOptions$ | async" + [context]="context$ | async"> diff --git a/src/app/+my-dspace-page/my-dspace-page.component.ts b/src/app/+my-dspace-page/my-dspace-page.component.ts index 1bad29f0d5..c8217f9ba8 100644 --- a/src/app/+my-dspace-page/my-dspace-page.component.ts +++ b/src/app/+my-dspace-page/my-dspace-page.component.ts @@ -8,7 +8,7 @@ import { } from '@angular/core'; import { BehaviorSubject, Observable, Subscription } from 'rxjs'; -import { switchMap, tap, } from 'rxjs/operators'; +import { map, switchMap, tap, } from 'rxjs/operators'; import { PaginatedList } from '../core/data/paginated-list'; import { RemoteData } from '../core/data/remote-data'; @@ -28,6 +28,7 @@ import { MyDSpaceConfigurationService } from './my-dspace-configuration.service' import { ViewMode } from '../core/shared/view-mode.model'; import { MyDSpaceRequest } from '../core/data/request.models'; import { SearchResult } from '../+search-page/search-result.model'; +import { Context } from '../core/shared/context.model'; export const MYDSPACE_ROUTE = '/mydspace'; export const SEARCH_CONFIG_SERVICE: InjectionToken = new InjectionToken('searchConfigurationService'); @@ -95,6 +96,8 @@ export class MyDSpacePageComponent implements OnInit { */ viewModeList = [ViewMode.ListElement, ViewMode.DetailedListElement]; + context$: Observable; + constructor(private service: SearchService, private sidebarService: SearchSidebarService, private windowService: HostWindowService, @@ -126,6 +129,17 @@ export class MyDSpacePageComponent implements OnInit { switchMap((scopeId) => this.service.getScopes(scopeId)) ); + this.context$ = this.searchConfigService.getCurrentConfiguration('workspace') + .pipe( + map((configuration: string) => { + if (configuration === 'workspace') { + return Context.Workspace + } else { + return Context.Workflow + } + }) + ); + } /** diff --git a/src/app/+my-dspace-page/my-dspace-results/my-dspace-results.component.ts b/src/app/+my-dspace-page/my-dspace-results/my-dspace-results.component.ts index 61669277cf..96f11e7dba 100644 --- a/src/app/+my-dspace-page/my-dspace-results/my-dspace-results.component.ts +++ b/src/app/+my-dspace-page/my-dspace-results/my-dspace-results.component.ts @@ -37,7 +37,7 @@ export class MyDSpaceResultsComponent { */ @Input() viewMode: ViewMode; - context = Context.Submission; + @Input() context: Context; /** * A boolean representing if search results entry are separated by a line */ diff --git a/src/app/core/shared/context.model.ts b/src/app/core/shared/context.model.ts index a0e7f6a967..7bfd613b65 100644 --- a/src/app/core/shared/context.model.ts +++ b/src/app/core/shared/context.model.ts @@ -6,7 +6,8 @@ export enum Context { Undefined = 'undefined', ItemPage = 'itemPage', Search = 'search', - Submission = 'submission', + Workflow = 'workflow', + Workspace = 'workspace', AdminMenu = 'adminMenu', SubmissionModal = 'submissionModal', } diff --git a/src/app/shared/object-list/my-dspace-result-list-element/item-search-result/item-search-result-list-element-submission.component.ts b/src/app/shared/object-list/my-dspace-result-list-element/item-search-result/item-search-result-list-element-submission.component.ts index 6a3cc3befb..3ef45d1c47 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/item-search-result/item-search-result-list-element-submission.component.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/item-search-result/item-search-result-list-element-submission.component.ts @@ -17,7 +17,8 @@ import { SearchResultListElementComponent } from '../../search-result-list-eleme templateUrl: './item-search-result-list-element-submission.component.html' }) -@listableObjectComponent(ItemSearchResult, ViewMode.ListElement, Context.Submission) +@listableObjectComponent(ItemSearchResult, ViewMode.ListElement, Context.Workspace) +@listableObjectComponent(ItemSearchResult, ViewMode.ListElement, Context.Workflow) export class ItemSearchResultListElementSubmissionComponent extends SearchResultListElementComponent implements OnInit { /** * Represent item's status From 1e94a02da0adf106e43c680e3d1b8092024b6bb0 Mon Sep 17 00:00:00 2001 From: lotte Date: Fri, 8 Nov 2019 07:44:10 +0100 Subject: [PATCH 9/9] added missing typedoc --- src/app/+my-dspace-page/my-dspace-page.component.ts | 6 ++++++ .../my-dspace-results/my-dspace-results.component.ts | 3 +++ 2 files changed, 9 insertions(+) diff --git a/src/app/+my-dspace-page/my-dspace-page.component.ts b/src/app/+my-dspace-page/my-dspace-page.component.ts index c8217f9ba8..3600a10d22 100644 --- a/src/app/+my-dspace-page/my-dspace-page.component.ts +++ b/src/app/+my-dspace-page/my-dspace-page.component.ts @@ -96,6 +96,9 @@ export class MyDSpacePageComponent implements OnInit { */ viewModeList = [ViewMode.ListElement, ViewMode.DetailedListElement]; + /** + * The current context of this page: workspace or workflow + */ context$: Observable; constructor(private service: SearchService, @@ -114,6 +117,9 @@ export class MyDSpacePageComponent implements OnInit { * * Listen to changes in the scope * If something changes, update the list of scopes for the dropdown + * + * Listen to changes in the configuration + * If something changes, update the current context */ ngOnInit(): void { this.configurationList$ = this.searchConfigService.getAvailableConfigurationOptions(); diff --git a/src/app/+my-dspace-page/my-dspace-results/my-dspace-results.component.ts b/src/app/+my-dspace-page/my-dspace-results/my-dspace-results.component.ts index 96f11e7dba..91c206fc79 100644 --- a/src/app/+my-dspace-page/my-dspace-results/my-dspace-results.component.ts +++ b/src/app/+my-dspace-page/my-dspace-results/my-dspace-results.component.ts @@ -37,6 +37,9 @@ export class MyDSpaceResultsComponent { */ @Input() viewMode: ViewMode; + /** + * The current context for the search results + */ @Input() context: Context; /** * A boolean representing if search results entry are separated by a line