diff --git a/src/app/+item-page/edit-item-page/item-metadata/item-metadata.component.spec.ts b/src/app/+item-page/edit-item-page/item-metadata/item-metadata.component.spec.ts index 0c164b7bc2..b9a793eddd 100644 --- a/src/app/+item-page/edit-item-page/item-metadata/item-metadata.component.spec.ts +++ b/src/app/+item-page/edit-item-page/item-metadata/item-metadata.component.spec.ts @@ -216,9 +216,9 @@ describe('ItemMetadataComponent', () => { }); it('it should call reinstateFieldUpdates on the objectUpdatesService with the correct url and metadata', () => { - expect(objectUpdatesService.getUpdatedFields).toHaveBeenCalledWith(url, comp.item.metadataAsList); - expect(itemService.update).toHaveBeenCalledWith(Object.assign(comp.item, { metadata: Metadata.toMetadataMap(comp.item.metadataAsList) })); - expect(objectUpdatesService.getFieldUpdates).toHaveBeenCalledWith(url, comp.item.metadataAsList); + expect(objectUpdatesService.getUpdatedFields).toHaveBeenCalledWith(url, comp.object.metadataAsList); + expect(itemService.update).toHaveBeenCalledWith(Object.assign(comp.object, { metadata: Metadata.toMetadataMap(comp.object.metadataAsList) })); + expect(objectUpdatesService.getFieldUpdates).toHaveBeenCalledWith(url, comp.object.metadataAsList); }); }); diff --git a/src/app/+item-page/edit-item-page/item-relationships/edit-relationship-list/edit-relationship-list.component.spec.ts b/src/app/+item-page/edit-item-page/item-relationships/edit-relationship-list/edit-relationship-list.component.spec.ts index 3748ebca9d..c8e4c35b8b 100644 --- a/src/app/+item-page/edit-item-page/item-relationships/edit-relationship-list/edit-relationship-list.component.spec.ts +++ b/src/app/+item-page/edit-item-page/item-relationships/edit-relationship-list/edit-relationship-list.component.spec.ts @@ -117,7 +117,7 @@ describe('EditRelationshipListComponent', () => { fixture = TestBed.createComponent(EditRelationshipListComponent); comp = fixture.componentInstance; de = fixture.debugElement; - comp.item = item; + comp.object = item; comp.url = url; comp.relationshipLabel = relationshipType.leftLabel; fixture.detectChanges(); diff --git a/src/app/+item-page/edit-item-page/item-relationships/edit-relationship/edit-relationship.component.spec.ts b/src/app/+item-page/edit-item-page/item-relationships/edit-relationship/edit-relationship.component.spec.ts index 3306d8eb01..55f97000e7 100644 --- a/src/app/+item-page/edit-item-page/item-relationships/edit-relationship/edit-relationship.component.spec.ts +++ b/src/app/+item-page/edit-item-page/item-relationships/edit-relationship/edit-relationship.component.spec.ts @@ -113,7 +113,7 @@ describe('EditRelationshipComponent', () => { comp.url = url; comp.fieldUpdate = fieldUpdate1; - comp.item = item; + comp.object = item; fixture.detectChanges(); }); diff --git a/src/app/+item-page/edit-item-page/modify-item-overview/modify-item-overview.component.spec.ts b/src/app/+item-page/edit-item-page/modify-item-overview/modify-item-overview.component.spec.ts index 07ad9a347c..d0c875d2d3 100644 --- a/src/app/+item-page/edit-item-page/modify-item-overview/modify-item-overview.component.spec.ts +++ b/src/app/+item-page/edit-item-page/modify-item-overview/modify-item-overview.component.spec.ts @@ -32,7 +32,7 @@ describe('ModifyItemOverviewComponent', () => { beforeEach(() => { fixture = TestBed.createComponent(ModifyItemOverviewComponent); comp = fixture.componentInstance; - comp.item = mockItem; + comp.object = mockItem; fixture.detectChanges(); }); diff --git a/src/app/+item-page/simple/field-components/specific-field/abstract/item-page-abstract-field.component.spec.ts b/src/app/+item-page/simple/field-components/specific-field/abstract/item-page-abstract-field.component.spec.ts index 9461ee0950..219da338eb 100644 --- a/src/app/+item-page/simple/field-components/specific-field/abstract/item-page-abstract-field.component.spec.ts +++ b/src/app/+item-page/simple/field-components/specific-field/abstract/item-page-abstract-field.component.spec.ts @@ -31,7 +31,7 @@ describe('ItemPageAbstractFieldComponent', () => { beforeEach(async(() => { fixture = TestBed.createComponent(ItemPageAbstractFieldComponent); comp = fixture.componentInstance; - comp.item = mockItemWithMetadataFieldAndValue(mockField, mockValue); + comp.object = mockItemWithMetadataFieldAndValue(mockField, mockValue); fixture.detectChanges(); })); diff --git a/src/app/+item-page/simple/field-components/specific-field/author/item-page-author-field.component.spec.ts b/src/app/+item-page/simple/field-components/specific-field/author/item-page-author-field.component.spec.ts index d865caff8a..5647c7cc11 100644 --- a/src/app/+item-page/simple/field-components/specific-field/author/item-page-author-field.component.spec.ts +++ b/src/app/+item-page/simple/field-components/specific-field/author/item-page-author-field.component.spec.ts @@ -32,7 +32,7 @@ describe('ItemPageAuthorFieldComponent', () => { beforeEach(async(() => { fixture = TestBed.createComponent(ItemPageAuthorFieldComponent); comp = fixture.componentInstance; - comp.item = mockItemWithMetadataFieldAndValue(field, mockValue); + comp.object = mockItemWithMetadataFieldAndValue(field, mockValue); fixture.detectChanges(); })); diff --git a/src/app/+item-page/simple/field-components/specific-field/date/item-page-date-field.component.spec.ts b/src/app/+item-page/simple/field-components/specific-field/date/item-page-date-field.component.spec.ts index 2adada582b..760398e1f5 100644 --- a/src/app/+item-page/simple/field-components/specific-field/date/item-page-date-field.component.spec.ts +++ b/src/app/+item-page/simple/field-components/specific-field/date/item-page-date-field.component.spec.ts @@ -31,7 +31,7 @@ describe('ItemPageDateFieldComponent', () => { beforeEach(async(() => { fixture = TestBed.createComponent(ItemPageDateFieldComponent); comp = fixture.componentInstance; - comp.item = mockItemWithMetadataFieldAndValue(mockField, mockValue); + comp.object = mockItemWithMetadataFieldAndValue(mockField, mockValue); fixture.detectChanges(); })); diff --git a/src/app/+item-page/simple/field-components/specific-field/generic/generic-item-page-field.component.spec.ts b/src/app/+item-page/simple/field-components/specific-field/generic/generic-item-page-field.component.spec.ts index d8abd39cf3..2bfff14dd6 100644 --- a/src/app/+item-page/simple/field-components/specific-field/generic/generic-item-page-field.component.spec.ts +++ b/src/app/+item-page/simple/field-components/specific-field/generic/generic-item-page-field.component.spec.ts @@ -33,7 +33,7 @@ describe('GenericItemPageFieldComponent', () => { beforeEach(async(() => { fixture = TestBed.createComponent(GenericItemPageFieldComponent); comp = fixture.componentInstance; - comp.item = mockItemWithMetadataFieldAndValue(mockField, mockValue); + comp.object = mockItemWithMetadataFieldAndValue(mockField, mockValue); comp.fields = mockFields; comp.label = mockLabel; fixture.detectChanges(); diff --git a/src/app/+item-page/simple/field-components/specific-field/item-page-field.component.spec.ts b/src/app/+item-page/simple/field-components/specific-field/item-page-field.component.spec.ts index 1b7acb2e3b..4db4e06ce6 100644 --- a/src/app/+item-page/simple/field-components/specific-field/item-page-field.component.spec.ts +++ b/src/app/+item-page/simple/field-components/specific-field/item-page-field.component.spec.ts @@ -40,7 +40,7 @@ describe('ItemPageFieldComponent', () => { beforeEach(async(() => { fixture = TestBed.createComponent(ItemPageFieldComponent); comp = fixture.componentInstance; - comp.item = mockItemWithMetadataFieldAndValue(mockField, mockValue); + comp.object = mockItemWithMetadataFieldAndValue(mockField, mockValue); comp.fields = mockFields; comp.label = mockLabel; fixture.detectChanges(); diff --git a/src/app/+item-page/simple/field-components/specific-field/title/item-page-title-field.component.spec.ts b/src/app/+item-page/simple/field-components/specific-field/title/item-page-title-field.component.spec.ts index cb1ba6a4bc..17ce39dd18 100644 --- a/src/app/+item-page/simple/field-components/specific-field/title/item-page-title-field.component.spec.ts +++ b/src/app/+item-page/simple/field-components/specific-field/title/item-page-title-field.component.spec.ts @@ -31,7 +31,7 @@ describe('ItemPageTitleFieldComponent', () => { beforeEach(async(() => { fixture = TestBed.createComponent(ItemPageTitleFieldComponent); comp = fixture.componentInstance; - comp.item = mockItemWithMetadataFieldAndValue(mockField, mockValue); + comp.object = mockItemWithMetadataFieldAndValue(mockField, mockValue); fixture.detectChanges(); })); diff --git a/src/app/+item-page/simple/field-components/specific-field/uri/item-page-uri-field.component.spec.ts b/src/app/+item-page/simple/field-components/specific-field/uri/item-page-uri-field.component.spec.ts index 4511f16aae..60d2f5c97c 100644 --- a/src/app/+item-page/simple/field-components/specific-field/uri/item-page-uri-field.component.spec.ts +++ b/src/app/+item-page/simple/field-components/specific-field/uri/item-page-uri-field.component.spec.ts @@ -31,7 +31,7 @@ describe('ItemPageUriFieldComponent', () => { beforeEach(async(() => { fixture = TestBed.createComponent(ItemPageUriFieldComponent); comp = fixture.componentInstance; - comp.item = mockItemWithMetadataFieldAndValue(mockField, mockValue); + comp.object = mockItemWithMetadataFieldAndValue(mockField, mockValue); fixture.detectChanges(); })); 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..09952354a5 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 @@ -1,27 +1,27 @@

- {{'publication.page.titleprefix' | translate}} + {{'publication.page.titleprefix' | translate}}

- + - - - - + + + - - - @@ -43,25 +43,25 @@ [items]="journalIssues$ | async" [label]="'relationships.isJournalIssueOf' | translate"> - - + - - - - + +
- + {{"item.page.link.full" | 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 09319a4fa6..8f0bdc141d 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 @@ -44,15 +44,15 @@ export class PublicationComponent extends ItemComponent implements OnInit { this.authors$ = this.buildRepresentations('Person', 'dc.contributor.author'); this.projects$ = this.resolvedRelsAndTypes$.pipe( - getRelatedItemsByTypeLabel(this.item.id, 'isProjectOfPublication') + getRelatedItemsByTypeLabel(this.object.id, 'isProjectOfPublication') ); this.orgUnits$ = this.resolvedRelsAndTypes$.pipe( - getRelatedItemsByTypeLabel(this.item.id, 'isOrgUnitOfPublication') + getRelatedItemsByTypeLabel(this.object.id, 'isOrgUnitOfPublication') ); this.journalIssues$ = this.resolvedRelsAndTypes$.pipe( - getRelatedItemsByTypeLabel(this.item.id, 'isJournalIssueOfPublication') + getRelatedItemsByTypeLabel(this.object.id, 'isJournalIssueOfPublication') ); } 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 6ad84ffae2..398228856b 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,14 +1,12 @@ -import { Component, Inject, OnInit } from '@angular/core'; +import { Component, Inject, Input, 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'; import { Relationship } from '../../../../core/shared/item-relationships/relationship.model'; import { Item } from '../../../../core/shared/item.model'; import { getRemoteDataPayload, getSucceededRemoteData } from '../../../../core/shared/operators'; -import { ITEM } from '../../../../shared/items/switcher/listable-object-component-loader.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'; @@ -66,13 +64,13 @@ export class ItemComponent implements OnInit { * Resolved relationships and types together in one observable */ resolvedRelsAndTypes$: Observable<[Relationship[], RelationshipType[]]>; + @Input() object: Item; constructor( - @Inject(ITEM) public item: Item ) {} ngOnInit(): void { - const relationships$ = this.item.relationships; + const relationships$ = this.object.relationships; if (relationships$) { const relsCurrentPage$ = relationships$.pipe( filter((rd: RemoteData>) => rd.hasSucceeded), @@ -104,8 +102,8 @@ export class ItemComponent implements OnInit { * @param metadataField The metadata field that resembles the item type. */ buildRepresentations(itemType: string, metadataField: string): Observable { - const metadata = this.item.findMetadataSortedByPlace(metadataField); - const relsCurrentPage$ = this.item.relationships.pipe( + const metadata = this.object.findMetadataSortedByPlace(metadataField); + const relsCurrentPage$ = this.object.relationships.pipe( getSucceededRemoteData(), getRemoteDataPayload(), map((pl: PaginatedList) => pl.page), @@ -113,7 +111,7 @@ export class ItemComponent implements OnInit { ); return relsCurrentPage$.pipe( - relationsToRepresentations(this.item.id, itemType, metadata) + relationsToRepresentations(this.object.id, itemType, metadata) ); } diff --git a/src/app/+item-page/simple/related-entities/related-entities-search/related-entities-search.component.spec.ts b/src/app/+item-page/simple/related-entities/related-entities-search/related-entities-search.component.spec.ts index 711e1b9d3d..bc2571f6f9 100644 --- a/src/app/+item-page/simple/related-entities/related-entities-search/related-entities-search.component.spec.ts +++ b/src/app/+item-page/simple/related-entities/related-entities-search/related-entities-search.component.spec.ts @@ -38,7 +38,7 @@ describe('RelatedEntitiesSearchComponent', () => { comp = fixture.componentInstance; fixedFilterService = (comp as any).fixedFilterService; comp.relationType = mockRelationType; - comp.item = mockItem; + comp.object = mockItem; comp.relationEntityType = mockRelationEntityType; fixture.detectChanges(); }); diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/journal-issue/journal-issue-grid-element.component.html b/src/app/entity-groups/journal-entities/item-grid-elements/journal-issue/journal-issue-grid-element.component.html index 3aa79fc70a..fab0cf5c07 100644 --- a/src/app/entity-groups/journal-entities/item-grid-elements/journal-issue/journal-issue-grid-element.component.html +++ b/src/app/entity-groups/journal-entities/item-grid-elements/journal-issue/journal-issue-grid-element.component.html @@ -1,30 +1 @@ - -
- -
- - -
-
-
- - -

-
-

- - - -

-

- - - -

-
- View -
-
-
-
+ \ No newline at end of file diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/journal-issue/journal-issue-grid-element.component.ts b/src/app/entity-groups/journal-entities/item-grid-elements/journal-issue/journal-issue-grid-element.component.ts index 75e23de21d..3e57731613 100644 --- a/src/app/entity-groups/journal-entities/item-grid-elements/journal-issue/journal-issue-grid-element.component.ts +++ b/src/app/entity-groups/journal-entities/item-grid-elements/journal-issue/journal-issue-grid-element.component.ts @@ -1,18 +1,17 @@ import { Component } from '@angular/core'; -import { focusShadow } from '../../../../shared/animations/focus'; -import { TypedItemSearchResultGridElementComponent } from '../../../../shared/object-grid/item-grid-element/item-types/typed-item-search-result-grid-element.component'; import { ViewMode } from '../../../../core/shared/view-mode.model'; import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +import { AbstractListableElementComponent } from '../../../../shared/object-collection/shared/object-collection-element/abstract-listable-element.component'; +import { Item } from '../../../../core/shared/item.model'; @listableObjectComponent('JournalIssue', ViewMode.GridElement) @Component({ selector: 'ds-journal-issue-grid-element', styleUrls: ['./journal-issue-grid-element.component.scss'], templateUrl: './journal-issue-grid-element.component.html', - animations: [focusShadow] }) /** * The component for displaying a grid element for an item of the type Journal Issue */ -export class JournalIssueGridElementComponent extends TypedItemSearchResultGridElementComponent { +export class JournalIssueGridElementComponent extends AbstractListableElementComponent { } diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/journal-volume/journal-volume-grid-element.component.html b/src/app/entity-groups/journal-entities/item-grid-elements/journal-volume/journal-volume-grid-element.component.html index b2b251f550..06bcb10c4d 100644 --- a/src/app/entity-groups/journal-entities/item-grid-elements/journal-volume/journal-volume-grid-element.component.html +++ b/src/app/entity-groups/journal-entities/item-grid-elements/journal-volume/journal-volume-grid-element.component.html @@ -1,30 +1 @@ - -
- -
- - -
-
-
- - -

-
-

- - - -

-

- - - -

-
- View -
-
-
-
+ \ No newline at end of file diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/journal-volume/journal-volume-grid-element.component.ts b/src/app/entity-groups/journal-entities/item-grid-elements/journal-volume/journal-volume-grid-element.component.ts index 35f1a6161d..eb88c25a12 100644 --- a/src/app/entity-groups/journal-entities/item-grid-elements/journal-volume/journal-volume-grid-element.component.ts +++ b/src/app/entity-groups/journal-entities/item-grid-elements/journal-volume/journal-volume-grid-element.component.ts @@ -1,18 +1,17 @@ import { Component } from '@angular/core'; -import { focusShadow } from '../../../../shared/animations/focus'; -import { TypedItemSearchResultGridElementComponent } from '../../../../shared/object-grid/item-grid-element/item-types/typed-item-search-result-grid-element.component'; import { ViewMode } from '../../../../core/shared/view-mode.model'; import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +import { AbstractListableElementComponent } from '../../../../shared/object-collection/shared/object-collection-element/abstract-listable-element.component'; +import { Item } from '../../../../core/shared/item.model'; @listableObjectComponent('JournalVolume', ViewMode.GridElement) @Component({ selector: 'ds-journal-volume-grid-element', styleUrls: ['./journal-volume-grid-element.component.scss'], templateUrl: './journal-volume-grid-element.component.html', - animations: [focusShadow] }) /** * The component for displaying a grid element for an item of the type Journal Volume */ -export class JournalVolumeGridElementComponent extends TypedItemSearchResultGridElementComponent { +export class JournalVolumeGridElementComponent extends AbstractListableElementComponent { } diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/journal/journal-grid-element.component.html b/src/app/entity-groups/journal-entities/item-grid-elements/journal/journal-grid-element.component.html index af0739004c..1a7a6f5da8 100644 --- a/src/app/entity-groups/journal-entities/item-grid-elements/journal/journal-grid-element.component.html +++ b/src/app/entity-groups/journal-entities/item-grid-elements/journal/journal-grid-element.component.html @@ -1,35 +1 @@ - -
- -
- - -
-
-
- - -

-
-

- - {{dso.firstMetadataValue('creativework.editor')}} - - , - {{dso.firstMetadataValue('creativework.publisher')}} - - -

-

- - - -

-
- View -
-
-
-
+ \ No newline at end of file diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/journal/journal-grid-element.component.ts b/src/app/entity-groups/journal-entities/item-grid-elements/journal/journal-grid-element.component.ts index 4596549e3a..c86529317b 100644 --- a/src/app/entity-groups/journal-entities/item-grid-elements/journal/journal-grid-element.component.ts +++ b/src/app/entity-groups/journal-entities/item-grid-elements/journal/journal-grid-element.component.ts @@ -1,18 +1,18 @@ import { Component } from '@angular/core'; import { focusShadow } from '../../../../shared/animations/focus'; -import { TypedItemSearchResultGridElementComponent } from '../../../../shared/object-grid/item-grid-element/item-types/typed-item-search-result-grid-element.component'; import { ViewMode } from '../../../../core/shared/view-mode.model'; import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +import { AbstractListableElementComponent } from '../../../../shared/object-collection/shared/object-collection-element/abstract-listable-element.component'; +import { Item } from '../../../../core/shared/item.model'; @listableObjectComponent('Journal', ViewMode.GridElement) @Component({ selector: 'ds-journal-grid-element', styleUrls: ['./journal-grid-element.component.scss'], templateUrl: './journal-grid-element.component.html', - animations: [focusShadow] }) /** * The component for displaying a grid element for an item of the type Journal */ -export class JournalGridElementComponent extends TypedItemSearchResultGridElementComponent { +export class JournalGridElementComponent extends AbstractListableElementComponent { } diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.html b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.html new file mode 100644 index 0000000000..69ea378269 --- /dev/null +++ b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.html @@ -0,0 +1,32 @@ + + +
+ +
+ + +
+
+
+ + +

+
+

+ + + +

+

+ + + +

+
+ View +
+
+
+
+
\ No newline at end of file diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.scss b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.scss new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.spec.ts b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.spec.ts new file mode 100644 index 0000000000..db13b3592c --- /dev/null +++ b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.spec.ts @@ -0,0 +1,50 @@ +import { ItemSearchResult } from '../../../../shared/object-collection/shared/item-search-result.model'; +import { Item } from '../../../../core/shared/item.model'; +import { of as observableOf } from 'rxjs/internal/observable/of'; +import { getEntityGridElementTestComponent } from '../../../../shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.spec'; +import { JournalIssueSearchResultGridElementComponent } from './journal-issue-grid-element.component'; +import { createSuccessfulRemoteDataObject$ } from '../../../../shared/testing/utils'; +import { PaginatedList } from '../../../../core/data/paginated-list'; +import { PageInfo } from '../../../../core/shared/page-info.model'; + +const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult(); +mockItemWithMetadata.hitHighlights = {}; +mockItemWithMetadata.indexableObject = Object.assign(new Item(), { + bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ], + 'creativework.datePublished': [ + { + language: null, + value: '2015-06-26' + } + ], + 'journal.title': [ + { + language: 'en_US', + value: 'The journal title' + } + ] + } +}); + +const mockItemWithoutMetadata: ItemSearchResult = new ItemSearchResult(); +mockItemWithoutMetadata.hitHighlights = {}; +mockItemWithoutMetadata.indexableObject = Object.assign(new Item(), { + bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ] + } +}); + +describe('JournalIssueGridElementComponent', getEntityGridElementTestComponent(JournalIssueSearchResultGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['date', 'journal-title'])); diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.ts b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.ts new file mode 100644 index 0000000000..ceda357559 --- /dev/null +++ b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.ts @@ -0,0 +1,20 @@ +import { Component } from '@angular/core'; +import { ViewMode } from '../../../../../core/shared/view-mode.model'; +import { listableObjectComponent } from '../../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +import { focusShadow } from '../../../../../shared/animations/focus'; +import { SearchResultGridElementComponent } from '../../../../../shared/object-grid/search-result-grid-element/search-result-grid-element.component'; +import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model'; +import { Item } from '../../../../../core/shared/item.model'; + +@listableObjectComponent('JournalIssueSearchResult', ViewMode.GridElement) +@Component({ + selector: 'ds-journal-issue-search-result-grid-element', + styleUrls: ['./journal-issue-search-result-grid-element.component.scss'], + templateUrl: './journal-issue-search-result-grid-element.component.html', + animations: [focusShadow] +}) +/** + * The component for displaying a grid element for an item of the type Journal Issue + */ +export class JournalIssueSearchResultGridElementComponent extends SearchResultGridElementComponent { +} diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.html b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.html new file mode 100644 index 0000000000..93559d21bf --- /dev/null +++ b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.html @@ -0,0 +1,32 @@ + + +
+ +
+ + +
+
+
+ + +

+
+

+ + + +

+

+ + + +

+
+ View +
+
+
+
+
\ No newline at end of file diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.scss b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.scss new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.spec.ts b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.spec.ts new file mode 100644 index 0000000000..07ffc7bdc0 --- /dev/null +++ b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.spec.ts @@ -0,0 +1,50 @@ +import { ItemSearchResult } from '../../../../shared/object-collection/shared/item-search-result.model'; +import { Item } from '../../../../core/shared/item.model'; +import { of as observableOf } from 'rxjs/internal/observable/of'; +import { getEntityGridElementTestComponent } from '../../../../shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.spec'; +import { JournalVolumeSearchResultGridElementComponent } from './journal-volume-grid-element.component'; +import { createSuccessfulRemoteDataObject$ } from '../../../../shared/testing/utils'; +import { PaginatedList } from '../../../../core/data/paginated-list'; +import { PageInfo } from '../../../../core/shared/page-info.model'; + +const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult(); +mockItemWithMetadata.hitHighlights = {}; +mockItemWithMetadata.indexableObject = Object.assign(new Item(), { + bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ], + 'creativework.datePublished': [ + { + language: null, + value: '2015-06-26' + } + ], + 'dc.description': [ + { + language: 'en_US', + value: 'A description for the journal volume' + } + ] + } +}); + +const mockItemWithoutMetadata: ItemSearchResult = new ItemSearchResult(); +mockItemWithoutMetadata.hitHighlights = {}; +mockItemWithoutMetadata.indexableObject = Object.assign(new Item(), { + bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ] + } +}); + +describe('JournalVolumeGridElementComponent', getEntityGridElementTestComponent(JournalVolumeSearchResultGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['date', 'description'])); diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.ts b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.ts new file mode 100644 index 0000000000..9ce106f962 --- /dev/null +++ b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.ts @@ -0,0 +1,20 @@ +import { Component } from '@angular/core'; +import { SearchResultGridElementComponent } from '../../../../../shared/object-grid/search-result-grid-element/search-result-grid-element.component'; +import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model'; +import { Item } from '../../../../../core/shared/item.model'; +import { ViewMode } from '../../../../../core/shared/view-mode.model'; +import { listableObjectComponent } from '../../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +import { focusShadow } from '../../../../../shared/animations/focus'; + +@listableObjectComponent('JournalVolumeSearchResult', ViewMode.GridElement) +@Component({ + selector: 'ds-journal-volume-search-result-grid-element', + styleUrls: ['./journal-volume-search-result-grid-element.component.scss'], + templateUrl: './journal-volume-search-result-grid-element.component.html', + animations: [focusShadow] +}) +/** + * The component for displaying a grid element for an item of the type Journal Volume + */ +export class JournalVolumeSearchResultGridElementComponent extends SearchResultGridElementComponent { +} diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.html b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.html new file mode 100644 index 0000000000..ad37333b90 --- /dev/null +++ b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.html @@ -0,0 +1,37 @@ + + +
+ +
+ + +
+
+
+ + +

+
+

+ + {{item.firstMetadataValue('creativework.editor')}} + + , + {{item.firstMetadataValue('creativework.publisher')}} + + +

+

+ + + +

+
+ View +
+
+
+
+
\ No newline at end of file diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.scss b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.scss new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.spec.ts b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.spec.ts new file mode 100644 index 0000000000..94e2e7fd68 --- /dev/null +++ b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.spec.ts @@ -0,0 +1,56 @@ +import { ItemSearchResult } from '../../../../shared/object-collection/shared/item-search-result.model'; +import { Item } from '../../../../core/shared/item.model'; +import { of as observableOf } from 'rxjs/internal/observable/of'; +import { getEntityGridElementTestComponent } from '../../../../shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.spec'; +import { JournalSearchResultGridElementComponent } from './journal-grid-element.component'; +import { createSuccessfulRemoteDataObject$ } from '../../../../shared/testing/utils'; +import { PaginatedList } from '../../../../core/data/paginated-list'; +import { PageInfo } from '../../../../core/shared/page-info.model'; + +const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult(); +mockItemWithMetadata.hitHighlights = {}; +mockItemWithMetadata.indexableObject = Object.assign(new Item(), { + bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ], + 'creativework.editor': [ + { + language: 'en_US', + value: 'Smith, Donald' + } + ], + 'creativework.publisher': [ + { + language: 'en_US', + value: 'A company' + } + ], + 'dc.description': [ + { + language: 'en_US', + value: 'This is the description' + } + ] + } +}); + +const mockItemWithoutMetadata: ItemSearchResult = new ItemSearchResult(); +mockItemWithoutMetadata.hitHighlights = {}; +mockItemWithoutMetadata.indexableObject = Object.assign(new Item(), { + bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ] + } +}); + +describe('JournalGridElementComponent', getEntityGridElementTestComponent(JournalSearchResultGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['editor', 'publisher', 'description'])); diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.ts b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.ts new file mode 100644 index 0000000000..5f24601223 --- /dev/null +++ b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.ts @@ -0,0 +1,20 @@ +import { Component } from '@angular/core'; +import { focusShadow } from '../../../../../shared/animations/focus'; +import { listableObjectComponent } from '../../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +import { ViewMode } from '../../../../../core/shared/view-mode.model'; +import { SearchResultGridElementComponent } from '../../../../../shared/object-grid/search-result-grid-element/search-result-grid-element.component'; +import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model'; +import { Item } from '../../../../../core/shared/item.model'; + +@listableObjectComponent('JournalSearchResult', ViewMode.GridElement) +@Component({ + selector: 'ds-journal-search-result-grid-element', + styleUrls: ['./journal-search-result-grid-element.component.scss'], + templateUrl: './journal-search-result-grid-element.component.html', + animations: [focusShadow] +}) +/** + * The component for displaying a grid element for an item of the type Journal + */ +export class JournalSearchResultGridElementComponent extends SearchResultGridElementComponent { +} diff --git a/src/app/entity-groups/journal-entities/item-list-elements/journal-issue/journal-issue-list-element.component.html b/src/app/entity-groups/journal-entities/item-list-elements/journal-issue/journal-issue-list-element.component.html index 030a26df39..1e418ba7c2 100644 --- a/src/app/entity-groups/journal-entities/item-list-elements/journal-issue/journal-issue-list-element.component.html +++ b/src/app/entity-groups/journal-entities/item-list-elements/journal-issue/journal-issue-list-element.component.html @@ -1,21 +1 @@ - - - - - - - - - - - - - - - - - - + \ No newline at end of file diff --git a/src/app/entity-groups/journal-entities/item-list-elements/journal-issue/journal-issue-list-element.component.spec.ts b/src/app/entity-groups/journal-entities/item-list-elements/journal-issue/journal-issue-list-element.component.spec.ts index 37234f8140..ec61615c9a 100644 --- a/src/app/entity-groups/journal-entities/item-list-elements/journal-issue/journal-issue-list-element.component.spec.ts +++ b/src/app/entity-groups/journal-entities/item-list-elements/journal-issue/journal-issue-list-element.component.spec.ts @@ -69,7 +69,7 @@ describe('JournalIssueListElementComponent', () => { describe('When the item has a journal identifier', () => { beforeEach(() => { - journalIssueListElementComponent.item = mockItemWithMetadata; + journalIssueListElementComponent.object = mockItemWithMetadata; fixture.detectChanges(); }); @@ -81,7 +81,7 @@ describe('JournalIssueListElementComponent', () => { describe('When the item has no journal identifier', () => { beforeEach(() => { - journalIssueListElementComponent.item = mockItemWithoutMetadata; + journalIssueListElementComponent.object = mockItemWithoutMetadata; fixture.detectChanges(); }); @@ -93,7 +93,7 @@ describe('JournalIssueListElementComponent', () => { describe('When the item has a journal number', () => { beforeEach(() => { - journalIssueListElementComponent.item = mockItemWithMetadata; + journalIssueListElementComponent.object = mockItemWithMetadata; fixture.detectChanges(); }); @@ -105,7 +105,7 @@ describe('JournalIssueListElementComponent', () => { describe('When the item has no journal number', () => { beforeEach(() => { - journalIssueListElementComponent.item = mockItemWithoutMetadata; + journalIssueListElementComponent.object = mockItemWithoutMetadata; fixture.detectChanges(); }); diff --git a/src/app/entity-groups/journal-entities/item-list-elements/journal-issue/journal-issue-list-element.component.ts b/src/app/entity-groups/journal-entities/item-list-elements/journal-issue/journal-issue-list-element.component.ts index 847b8a6978..454c140050 100644 --- a/src/app/entity-groups/journal-entities/item-list-elements/journal-issue/journal-issue-list-element.component.ts +++ b/src/app/entity-groups/journal-entities/item-list-elements/journal-issue/journal-issue-list-element.component.ts @@ -1,7 +1,8 @@ import { Component } from '@angular/core'; -import { TypedItemSearchResultListElementComponent } from '../../../../shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component'; import { ViewMode } from '../../../../core/shared/view-mode.model'; import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +import { AbstractListableElementComponent } from '../../../../shared/object-collection/shared/object-collection-element/abstract-listable-element.component'; +import { Item } from '../../../../core/shared/item.model'; @listableObjectComponent('JournalIssue', ViewMode.ListElement) @Component({ @@ -12,5 +13,5 @@ import { listableObjectComponent } from '../../../../shared/object-collection/sh /** * The component for displaying a list element for an item of the type Journal Issue */ -export class JournalIssueListElementComponent extends TypedItemSearchResultListElementComponent { +export class JournalIssueListElementComponent extends AbstractListableElementComponent { } diff --git a/src/app/entity-groups/journal-entities/item-list-elements/journal-volume/journal-volume-list-element.component.html b/src/app/entity-groups/journal-entities/item-list-elements/journal-volume/journal-volume-list-element.component.html index 4e6e34d3d6..c00de1c33d 100644 --- a/src/app/entity-groups/journal-entities/item-list-elements/journal-volume/journal-volume-list-element.component.html +++ b/src/app/entity-groups/journal-entities/item-list-elements/journal-volume/journal-volume-list-element.component.html @@ -1,21 +1 @@ - - - - - - - - - - - - () - - - - - + \ No newline at end of file diff --git a/src/app/entity-groups/journal-entities/item-list-elements/journal-volume/journal-volume-list-element.component.spec.ts b/src/app/entity-groups/journal-entities/item-list-elements/journal-volume/journal-volume-list-element.component.spec.ts index 4872d47c31..21d28c7fe8 100644 --- a/src/app/entity-groups/journal-entities/item-list-elements/journal-volume/journal-volume-list-element.component.spec.ts +++ b/src/app/entity-groups/journal-entities/item-list-elements/journal-volume/journal-volume-list-element.component.spec.ts @@ -69,7 +69,7 @@ describe('JournalVolumeListElementComponent', () => { describe('When the item has a journal title', () => { beforeEach(() => { - journalVolumeListElementComponent.item = mockItemWithMetadata; + journalVolumeListElementComponent.object = mockItemWithMetadata; fixture.detectChanges(); }); @@ -81,7 +81,7 @@ describe('JournalVolumeListElementComponent', () => { describe('When the item has no journal title', () => { beforeEach(() => { - journalVolumeListElementComponent.item = mockItemWithoutMetadata; + journalVolumeListElementComponent.object = mockItemWithoutMetadata; fixture.detectChanges(); }); @@ -93,7 +93,7 @@ describe('JournalVolumeListElementComponent', () => { describe('When the item has a journal identifier', () => { beforeEach(() => { - journalVolumeListElementComponent.item = mockItemWithMetadata; + journalVolumeListElementComponent.object = mockItemWithMetadata; fixture.detectChanges(); }); @@ -105,7 +105,7 @@ describe('JournalVolumeListElementComponent', () => { describe('When the item has no journal identifier', () => { beforeEach(() => { - journalVolumeListElementComponent.item = mockItemWithoutMetadata; + journalVolumeListElementComponent.object = mockItemWithoutMetadata; fixture.detectChanges(); }); diff --git a/src/app/entity-groups/journal-entities/item-list-elements/journal-volume/journal-volume-list-element.component.ts b/src/app/entity-groups/journal-entities/item-list-elements/journal-volume/journal-volume-list-element.component.ts index e1bc178b5e..641a0d2238 100644 --- a/src/app/entity-groups/journal-entities/item-list-elements/journal-volume/journal-volume-list-element.component.ts +++ b/src/app/entity-groups/journal-entities/item-list-elements/journal-volume/journal-volume-list-element.component.ts @@ -1,7 +1,8 @@ import { Component } from '@angular/core'; -import { TypedItemSearchResultListElementComponent } from '../../../../shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component'; import { ViewMode } from '../../../../core/shared/view-mode.model'; import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +import { AbstractListableElementComponent } from '../../../../shared/object-collection/shared/object-collection-element/abstract-listable-element.component'; +import { Item } from '../../../../core/shared/item.model'; @listableObjectComponent('JournalVolume', ViewMode.ListElement) @Component({ @@ -12,5 +13,5 @@ import { listableObjectComponent } from '../../../../shared/object-collection/sh /** * The component for displaying a list element for an item of the type Journal Volume */ -export class JournalVolumeListElementComponent extends TypedItemSearchResultListElementComponent { +export class JournalVolumeListElementComponent extends AbstractListableElementComponent { } diff --git a/src/app/entity-groups/journal-entities/item-list-elements/journal/journal-list-element.component.html b/src/app/entity-groups/journal-entities/item-list-elements/journal/journal-list-element.component.html index 0e46e921bb..3df361e7f9 100644 --- a/src/app/entity-groups/journal-entities/item-list-elements/journal/journal-list-element.component.html +++ b/src/app/entity-groups/journal-entities/item-list-elements/journal/journal-list-element.component.html @@ -1,15 +1 @@ - - - - - - - - - - - - + \ No newline at end of file diff --git a/src/app/entity-groups/journal-entities/item-list-elements/journal/journal-list-element.component.spec.ts b/src/app/entity-groups/journal-entities/item-list-elements/journal/journal-list-element.component.spec.ts index 469549821e..c9567fc731 100644 --- a/src/app/entity-groups/journal-entities/item-list-elements/journal/journal-list-element.component.spec.ts +++ b/src/app/entity-groups/journal-entities/item-list-elements/journal/journal-list-element.component.spec.ts @@ -63,7 +63,7 @@ describe('JournalListElementComponent', () => { describe('When the item has an issn', () => { beforeEach(() => { - journalListElementComponent.item = mockItemWithMetadata; + journalListElementComponent.object = mockItemWithMetadata; fixture.detectChanges(); }); @@ -75,7 +75,7 @@ describe('JournalListElementComponent', () => { describe('When the item has no issn', () => { beforeEach(() => { - journalListElementComponent.item = mockItemWithoutMetadata; + journalListElementComponent.object = mockItemWithoutMetadata; fixture.detectChanges(); }); diff --git a/src/app/entity-groups/journal-entities/item-list-elements/journal/journal-list-element.component.ts b/src/app/entity-groups/journal-entities/item-list-elements/journal/journal-list-element.component.ts index 05e1576219..fa83c3cff4 100644 --- a/src/app/entity-groups/journal-entities/item-list-elements/journal/journal-list-element.component.ts +++ b/src/app/entity-groups/journal-entities/item-list-elements/journal/journal-list-element.component.ts @@ -1,7 +1,8 @@ import { Component } from '@angular/core'; -import { TypedItemSearchResultListElementComponent } from '../../../../shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component'; import { ViewMode } from '../../../../core/shared/view-mode.model'; import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +import { AbstractListableElementComponent } from '../../../../shared/object-collection/shared/object-collection-element/abstract-listable-element.component'; +import { Item } from '../../../../core/shared/item.model'; @listableObjectComponent('Journal', ViewMode.ListElement) @Component({ @@ -12,5 +13,5 @@ import { listableObjectComponent } from '../../../../shared/object-collection/sh /** * The component for displaying a list element for an item of the type Journal */ -export class JournalListElementComponent extends TypedItemSearchResultListElementComponent { +export class JournalListElementComponent extends AbstractListableElementComponent { } diff --git a/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-issue/journal-issue-search-result-list-element.component.html b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-issue/journal-issue-search-result-list-element.component.html new file mode 100644 index 0000000000..2d9faadcdc --- /dev/null +++ b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-issue/journal-issue-search-result-list-element.component.html @@ -0,0 +1,23 @@ + + + + + + + + + + + + - + + + + + + + \ No newline at end of file diff --git a/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-issue/journal-issue-search-result-list-element.component.scss b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-issue/journal-issue-search-result-list-element.component.scss new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-issue/journal-issue-search-result-list-element.component.spec.ts b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-issue/journal-issue-search-result-list-element.component.spec.ts new file mode 100644 index 0000000000..4d49346e83 --- /dev/null +++ b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-issue/journal-issue-search-result-list-element.component.spec.ts @@ -0,0 +1,117 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; +import { By } from '@angular/platform-browser'; +import { JournalIssueSearchResultListElementComponent } from './journal-issue-list-element.component'; +import { of as observableOf } from 'rxjs'; +import { Item } from '../../../../core/shared/item.model'; +import { TruncatePipe } from '../../../../shared/utils/truncate.pipe'; +import { ITEM } from '../../../../shared/items/switcher/listable-object-component-loader.component'; +import { TruncatableService } from '../../../../shared/truncatable/truncatable.service'; + +let journalIssueListElementComponent: JournalIssueSearchResultListElementComponent; +let fixture: ComponentFixture; + +const mockItemWithMetadata: Item = Object.assign(new Item(), { + bitstreams: observableOf({}), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ], + 'publicationvolume.volumeNumber': [ + { + language: 'en_US', + value: '1234' + } + ], + 'publicationissue.issueNumber': [ + { + language: 'en_US', + value: '5678' + } + ] + } +}); +const mockItemWithoutMetadata: Item = Object.assign(new Item(), { + bitstreams: observableOf({}), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ] + } +}); + +describe('JournalIssueListElementComponent', () => { + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ JournalIssueSearchResultListElementComponent , TruncatePipe], + providers: [ + { provide: ITEM, useValue: mockItemWithMetadata}, + { provide: TruncatableService, useValue: {} } + ], + + schemas: [ NO_ERRORS_SCHEMA ] + }).overrideComponent(JournalIssueSearchResultListElementComponent, { + set: { changeDetection: ChangeDetectionStrategy.Default } + }).compileComponents(); + })); + + beforeEach(async(() => { + fixture = TestBed.createComponent(JournalIssueSearchResultListElementComponent); + journalIssueListElementComponent = fixture.componentInstance; + + })); + + describe('When the item has a journal identifier', () => { + beforeEach(() => { + journalIssueListElementComponent.object = mockItemWithMetadata; + fixture.detectChanges(); + }); + + it('should show the journal issues span', () => { + const journalIdentifierField = fixture.debugElement.query(By.css('span.item-list-journal-issues')); + expect(journalIdentifierField).not.toBeNull(); + }); + }); + + describe('When the item has no journal identifier', () => { + beforeEach(() => { + journalIssueListElementComponent.object = mockItemWithoutMetadata; + fixture.detectChanges(); + }); + + it('should not show the journal issues span', () => { + const journalIdentifierField = fixture.debugElement.query(By.css('span.item-list-journal-issues')); + expect(journalIdentifierField).toBeNull(); + }); + }); + + describe('When the item has a journal number', () => { + beforeEach(() => { + journalIssueListElementComponent.object = mockItemWithMetadata; + fixture.detectChanges(); + }); + + it('should show the journal issue numbers span', () => { + const journalNumberField = fixture.debugElement.query(By.css('span.item-list-journal-issue-numbers')); + expect(journalNumberField).not.toBeNull(); + }); + }); + + describe('When the item has no journal number', () => { + beforeEach(() => { + journalIssueListElementComponent.object = mockItemWithoutMetadata; + fixture.detectChanges(); + }); + + it('should not show the journal issue numbers span', () => { + const journalNumberField = fixture.debugElement.query(By.css('span.item-list-journal-issue-numbers')); + expect(journalNumberField).toBeNull(); + }); + }); +}); diff --git a/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-issue/journal-issue-search-result-list-element.component.ts b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-issue/journal-issue-search-result-list-element.component.ts new file mode 100644 index 0000000000..65969752ea --- /dev/null +++ b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-issue/journal-issue-search-result-list-element.component.ts @@ -0,0 +1,18 @@ +import { Component } from '@angular/core'; +import { listableObjectComponent } from '../../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +import { ViewMode } from '../../../../../core/shared/view-mode.model'; +import { SearchResultListElementComponent } from '../../../../../shared/object-list/search-result-list-element/search-result-list-element.component'; +import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model'; +import { Item } from '../../../../../core/shared/item.model'; + +@listableObjectComponent('JournalIssueSearchResult', ViewMode.ListElement) +@Component({ + selector: 'ds-journal-issue-search-result-list-element', + styleUrls: ['./journal-issue-search-result-list-element.component.scss'], + templateUrl: './journal-issue-search-result-list-element.component.html' +}) +/** + * The component for displaying a list element for an item of the type Journal Issue + */ +export class JournalIssueSearchResultListElementComponent extends SearchResultListElementComponent { +} diff --git a/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-volume/journal-volume-search-result-list-element.component.html b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-volume/journal-volume-search-result-list-element.component.html new file mode 100644 index 0000000000..8a1ae65a22 --- /dev/null +++ b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-volume/journal-volume-search-result-list-element.component.html @@ -0,0 +1,23 @@ + + + + + + + + + + + + + () + + + + + + \ No newline at end of file diff --git a/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-volume/journal-volume-search-result-list-element.component.scss b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-volume/journal-volume-search-result-list-element.component.scss new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-volume/journal-volume-search-result-list-element.component.spec.ts b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-volume/journal-volume-search-result-list-element.component.spec.ts new file mode 100644 index 0000000000..c452ad7be2 --- /dev/null +++ b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-volume/journal-volume-search-result-list-element.component.spec.ts @@ -0,0 +1,117 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; +import { By } from '@angular/platform-browser'; +import { JournalVolumeSearchResultListElementComponent } from './journal-volume-list-element.component'; +import { of as observableOf } from 'rxjs'; +import { Item } from '../../../../core/shared/item.model'; +import { TruncatePipe } from '../../../../shared/utils/truncate.pipe'; +import { ITEM } from '../../../../shared/items/switcher/listable-object-component-loader.component'; +import { TruncatableService } from '../../../../shared/truncatable/truncatable.service'; + +let journalVolumeListElementComponent: JournalVolumeSearchResultListElementComponent; +let fixture: ComponentFixture; + +const mockItemWithMetadata: Item = Object.assign(new Item(), { + bitstreams: observableOf({}), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ], + 'journal.title': [ + { + language: 'en_US', + value: 'This is just another journal title' + } + ], + 'publicationvolume.volumeNumber': [ + { + language: 'en_US', + value: '1234' + } + ] + } +}); +const mockItemWithoutMetadata: Item = Object.assign(new Item(), { + bitstreams: observableOf({}), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ] + } +}); + +describe('JournalVolumeListElementComponent', () => { + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ JournalVolumeSearchResultListElementComponent , TruncatePipe], + providers: [ + { provide: ITEM, useValue: mockItemWithMetadata}, + { provide: TruncatableService, useValue: {} } + ], + + schemas: [ NO_ERRORS_SCHEMA ] + }).overrideComponent(JournalVolumeSearchResultListElementComponent, { + set: { changeDetection: ChangeDetectionStrategy.Default } + }).compileComponents(); + })); + + beforeEach(async(() => { + fixture = TestBed.createComponent(JournalVolumeSearchResultListElementComponent); + journalVolumeListElementComponent = fixture.componentInstance; + + })); + + describe('When the item has a journal title', () => { + beforeEach(() => { + journalVolumeListElementComponent.object = mockItemWithMetadata; + fixture.detectChanges(); + }); + + it('should show the journal title span', () => { + const journalTitleField = fixture.debugElement.query(By.css('span.item-list-journal-volumes')); + expect(journalTitleField).not.toBeNull(); + }); + }); + + describe('When the item has no journal title', () => { + beforeEach(() => { + journalVolumeListElementComponent.object = mockItemWithoutMetadata; + fixture.detectChanges(); + }); + + it('should not show the journal title span', () => { + const journalTitleField = fixture.debugElement.query(By.css('span.item-list-journal-volumes')); + expect(journalTitleField).toBeNull(); + }); + }); + + describe('When the item has a journal identifier', () => { + beforeEach(() => { + journalVolumeListElementComponent.object = mockItemWithMetadata; + fixture.detectChanges(); + }); + + it('should show the journal identifiers span', () => { + const journalIdentifierField = fixture.debugElement.query(By.css('span.item-list-journal-volume-identifiers')); + expect(journalIdentifierField).not.toBeNull(); + }); + }); + + describe('When the item has no journal identifier', () => { + beforeEach(() => { + journalVolumeListElementComponent.object = mockItemWithoutMetadata; + fixture.detectChanges(); + }); + + it('should not show the journal identifiers span', () => { + const journalIdentifierField = fixture.debugElement.query(By.css('span.item-list-journal-volume-identifiers')); + expect(journalIdentifierField).toBeNull(); + }); + }); +}); diff --git a/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-volume/journal-volume-search-result-list-element.component.ts b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-volume/journal-volume-search-result-list-element.component.ts new file mode 100644 index 0000000000..05ffe5ea57 --- /dev/null +++ b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-volume/journal-volume-search-result-list-element.component.ts @@ -0,0 +1,18 @@ +import { Component } from '@angular/core'; +import { SearchResultListElementComponent } from '../../../../../shared/object-list/search-result-list-element/search-result-list-element.component'; +import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model'; +import { Item } from '../../../../../core/shared/item.model'; +import { listableObjectComponent } from '../../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +import { ViewMode } from '../../../../../core/shared/view-mode.model'; + +@listableObjectComponent('JournalVolumeSearchResult', ViewMode.ListElement) +@Component({ + selector: 'ds-journal-volume-search-result-list-element', + styleUrls: ['./journal-volume-search-result-list-element.component.scss'], + templateUrl: './journal-volume-search-result-list-element.component.html' +}) +/** + * The component for displaying a list element for an item of the type Journal Volume + */ +export class JournalVolumeSearchResultListElementComponent extends SearchResultListElementComponent { +} diff --git a/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal/journal-search-result-list-element.component.html b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal/journal-search-result-list-element.component.html new file mode 100644 index 0000000000..d1dfff123a --- /dev/null +++ b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal/journal-search-result-list-element.component.html @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal/journal-search-result-list-element.component.scss b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal/journal-search-result-list-element.component.scss new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal/journal-search-result-list-element.component.spec.ts b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal/journal-search-result-list-element.component.spec.ts new file mode 100644 index 0000000000..3603b9e689 --- /dev/null +++ b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal/journal-search-result-list-element.component.spec.ts @@ -0,0 +1,87 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; +import { By } from '@angular/platform-browser'; +import { JournalSearchResultListElementComponent } from './journal-list-element.component'; +import { of as observableOf } from 'rxjs'; +import { Item } from '../../../../core/shared/item.model'; +import { TruncatePipe } from '../../../../shared/utils/truncate.pipe'; +import { ITEM } from '../../../../shared/items/switcher/listable-object-component-loader.component'; +import { TruncatableService } from '../../../../shared/truncatable/truncatable.service'; + +let journalListElementComponent: JournalSearchResultListElementComponent; +let fixture: ComponentFixture; + +const mockItemWithMetadata: Item = Object.assign(new Item(), { + bitstreams: observableOf({}), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ], + 'creativeworkseries.issn': [ + { + language: 'en_US', + value: '1234' + } + ] + } +}); +const mockItemWithoutMetadata: Item = Object.assign(new Item(), { + bitstreams: observableOf({}), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ] + } +}); + +describe('JournalListElementComponent', () => { + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ JournalSearchResultListElementComponent , TruncatePipe], + providers: [ + { provide: ITEM, useValue: mockItemWithMetadata}, + { provide: TruncatableService, useValue: {} } + ], + + schemas: [ NO_ERRORS_SCHEMA ] + }).overrideComponent(JournalSearchResultListElementComponent, { + set: { changeDetection: ChangeDetectionStrategy.Default } + }).compileComponents(); + })); + + beforeEach(async(() => { + fixture = TestBed.createComponent(JournalSearchResultListElementComponent); + journalListElementComponent = fixture.componentInstance; + + })); + + describe('When the item has an issn', () => { + beforeEach(() => { + journalListElementComponent.object = mockItemWithMetadata; + fixture.detectChanges(); + }); + + it('should show the journals span', () => { + const issnField = fixture.debugElement.query(By.css('span.item-list-journals')); + expect(issnField).not.toBeNull(); + }); + }); + + describe('When the item has no issn', () => { + beforeEach(() => { + journalListElementComponent.object = mockItemWithoutMetadata; + fixture.detectChanges(); + }); + + it('should not show the journals span', () => { + const issnField = fixture.debugElement.query(By.css('span.item-list-journals')); + expect(issnField).toBeNull(); + }); + }); +}); diff --git a/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal/journal-search-result-list-element.component.ts b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal/journal-search-result-list-element.component.ts new file mode 100644 index 0000000000..3e389dcc83 --- /dev/null +++ b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal/journal-search-result-list-element.component.ts @@ -0,0 +1,18 @@ +import { Component } from '@angular/core'; +import { SearchResultListElementComponent } from '../../../../../shared/object-list/search-result-list-element/search-result-list-element.component'; +import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model'; +import { Item } from '../../../../../core/shared/item.model'; +import { listableObjectComponent } from '../../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +import { ViewMode } from '../../../../../core/shared/view-mode.model'; + +@listableObjectComponent('JournalSearchResult', ViewMode.ListElement) +@Component({ + selector: 'ds-journal-search-result-list-element', + styleUrls: ['./journal-search-result-list-element.component.scss'], + templateUrl: './journal-search-result-list-element.component.html' +}) +/** + * The component for displaying a list element for an item of the type Journal + */ +export class JournalSearchResultListElementComponent extends SearchResultListElementComponent { +} diff --git a/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.html b/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.html index eebd3e03c8..d49d80b15e 100644 --- a/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.html +++ b/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.html @@ -1,28 +1,28 @@

- {{'journalissue.page.titleprefix' | translate}} + {{'journalissue.page.titleprefix' | translate}}

- + - - - - - @@ -37,16 +37,16 @@ [items]="publications$ | async" [label]="'relationships.isPublicationOfJournalIssue' | translate"> - - diff --git a/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.ts b/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.ts index 631ec64490..151a60a198 100644 --- a/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.ts +++ b/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.ts @@ -32,10 +32,10 @@ export class JournalIssueComponent extends ItemComponent { if (isNotEmpty(this.resolvedRelsAndTypes$)) { this.volumes$ = this.resolvedRelsAndTypes$.pipe( - getRelatedItemsByTypeLabel(this.item.id, 'isJournalVolumeOfIssue') + getRelatedItemsByTypeLabel(this.object.id, 'isJournalVolumeOfIssue') ); this.publications$ = this.resolvedRelsAndTypes$.pipe( - getRelatedItemsByTypeLabel(this.item.id, 'isPublicationOfJournalIssue') + getRelatedItemsByTypeLabel(this.object.id, 'isPublicationOfJournalIssue') ); } } diff --git a/src/app/entity-groups/journal-entities/item-pages/journal-volume/journal-volume.component.html b/src/app/entity-groups/journal-entities/item-pages/journal-volume/journal-volume.component.html index 83626c7ae7..d96bff9570 100644 --- a/src/app/entity-groups/journal-entities/item-pages/journal-volume/journal-volume.component.html +++ b/src/app/entity-groups/journal-entities/item-pages/journal-volume/journal-volume.component.html @@ -1,16 +1,16 @@

- {{'journalvolume.page.titleprefix' | translate}} + {{'journalvolume.page.titleprefix' | translate}}

- + - - @@ -24,12 +24,12 @@ [items]="issues$ | async" [label]="'relationships.isIssueOf' | translate"> - diff --git a/src/app/entity-groups/journal-entities/item-pages/journal-volume/journal-volume.component.ts b/src/app/entity-groups/journal-entities/item-pages/journal-volume/journal-volume.component.ts index 72cfc103fa..b1d83c25f2 100644 --- a/src/app/entity-groups/journal-entities/item-pages/journal-volume/journal-volume.component.ts +++ b/src/app/entity-groups/journal-entities/item-pages/journal-volume/journal-volume.component.ts @@ -32,10 +32,10 @@ export class JournalVolumeComponent extends ItemComponent { if (isNotEmpty(this.resolvedRelsAndTypes$)) { this.journals$ = this.resolvedRelsAndTypes$.pipe( - getRelatedItemsByTypeLabel(this.item.id, 'isJournalOfVolume') + getRelatedItemsByTypeLabel(this.object.id, 'isJournalOfVolume') ); this.issues$ = this.resolvedRelsAndTypes$.pipe( - getRelatedItemsByTypeLabel(this.item.id, 'isIssueOfJournalVolume') + getRelatedItemsByTypeLabel(this.object.id, 'isIssueOfJournalVolume') ); } } diff --git a/src/app/entity-groups/journal-entities/item-pages/journal/journal.component.html b/src/app/entity-groups/journal-entities/item-pages/journal/journal.component.html index a82d3c5df6..05d7ffc802 100644 --- a/src/app/entity-groups/journal-entities/item-pages/journal/journal.component.html +++ b/src/app/entity-groups/journal-entities/item-pages/journal/journal.component.html @@ -1,20 +1,20 @@

- {{'journal.page.titleprefix' | translate}} + {{'journal.page.titleprefix' | translate}}

- + - - - @@ -24,18 +24,18 @@ [items]="volumes$ | async" [label]="'relationships.isVolumeOf' | translate"> -
-
diff --git a/src/app/entity-groups/journal-entities/item-pages/journal/journal.component.ts b/src/app/entity-groups/journal-entities/item-pages/journal/journal.component.ts index 32b2648477..1282144a2f 100644 --- a/src/app/entity-groups/journal-entities/item-pages/journal/journal.component.ts +++ b/src/app/entity-groups/journal-entities/item-pages/journal/journal.component.ts @@ -27,7 +27,7 @@ export class JournalComponent extends ItemComponent { if (isNotEmpty(this.resolvedRelsAndTypes$)) { this.volumes$ = this.resolvedRelsAndTypes$.pipe( - getRelatedItemsByTypeLabel(this.item.id, 'isVolumeOfJournal') + getRelatedItemsByTypeLabel(this.object.id, 'isVolumeOfJournal') ); } } diff --git a/src/app/entity-groups/journal-entities/journal-entities.module.ts b/src/app/entity-groups/journal-entities/journal-entities.module.ts index 4033645e1b..d00eae1e54 100644 --- a/src/app/entity-groups/journal-entities/journal-entities.module.ts +++ b/src/app/entity-groups/journal-entities/journal-entities.module.ts @@ -12,6 +12,12 @@ import { TooltipModule } from 'ngx-bootstrap'; import { JournalIssueGridElementComponent } from './item-grid-elements/journal-issue/journal-issue-grid-element.component'; import { JournalVolumeGridElementComponent } from './item-grid-elements/journal-volume/journal-volume-grid-element.component'; import { JournalGridElementComponent } from './item-grid-elements/journal/journal-grid-element.component'; +import { JournalSearchResultListElementComponent } from './item-list-elements/search-result-list-elements/journal/journal-search-result-list-element.component'; +import { JournalSearchResultGridElementComponent } from './item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component'; +import { JournalIssueSearchResultListElementComponent } from './item-list-elements/search-result-list-elements/journal-issue/journal-issue-search-result-list-element.component'; +import { JournalVolumeSearchResultListElementComponent } from './item-list-elements/search-result-list-elements/journal-volume/journal-volume-search-result-list-element.component'; +import { JournalIssueSearchResultGridElementComponent } from './item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component'; +import { JournalVolumeSearchResultGridElementComponent } from './item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component'; const ENTRY_COMPONENTS = [ JournalComponent, @@ -22,7 +28,13 @@ const ENTRY_COMPONENTS = [ JournalVolumeListElementComponent, JournalIssueGridElementComponent, JournalVolumeGridElementComponent, - JournalGridElementComponent + JournalGridElementComponent, + JournalSearchResultListElementComponent, + JournalIssueSearchResultListElementComponent, + JournalVolumeSearchResultListElementComponent, + JournalIssueSearchResultGridElementComponent, + JournalVolumeSearchResultGridElementComponent, + JournalSearchResultGridElementComponent ]; @NgModule({ diff --git a/src/app/entity-groups/research-entities/item-grid-elements/orgunit/orgunit-grid-element.component.html b/src/app/entity-groups/research-entities/item-grid-elements/orgunit/orgunit-grid-element.component.html index a4765c4e8f..8ad7ce3590 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/orgunit/orgunit-grid-element.component.html +++ b/src/app/entity-groups/research-entities/item-grid-elements/orgunit/orgunit-grid-element.component.html @@ -1,35 +1 @@ - -
- -
- - -
-
-
- - -

-
-

- - - -

-

- - {{dso.firstMetadataValue('organization.address.addressCountry')}} - - , - {{dso.firstMetadataValue('organization.address.addressLocality')}} - - -

-
- View -
-
-
-
+ \ No newline at end of file diff --git a/src/app/entity-groups/research-entities/item-grid-elements/orgunit/orgunit-grid-element.component.ts b/src/app/entity-groups/research-entities/item-grid-elements/orgunit/orgunit-grid-element.component.ts index f7a13f1033..1bdcbdc370 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/orgunit/orgunit-grid-element.component.ts +++ b/src/app/entity-groups/research-entities/item-grid-elements/orgunit/orgunit-grid-element.component.ts @@ -1,18 +1,17 @@ import { Component } from '@angular/core'; -import { focusShadow } from '../../../../shared/animations/focus'; -import { TypedItemSearchResultGridElementComponent } from '../../../../shared/object-grid/item-grid-element/item-types/typed-item-search-result-grid-element.component'; import { ViewMode } from '../../../../core/shared/view-mode.model'; import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +import { AbstractListableElementComponent } from '../../../../shared/object-collection/shared/object-collection-element/abstract-listable-element.component'; +import { Item } from '../../../../core/shared/item.model'; @listableObjectComponent('OrgUnit', ViewMode.GridElement) @Component({ selector: 'ds-orgunit-grid-element', styleUrls: ['./orgunit-grid-element.component.scss'], templateUrl: './orgunit-grid-element.component.html', - animations: [focusShadow] }) /** * The component for displaying a grid element for an item of the type Organisation Unit */ -export class OrgunitGridElementComponent extends TypedItemSearchResultGridElementComponent { +export class OrgunitGridElementComponent extends AbstractListableElementComponent { } diff --git a/src/app/entity-groups/research-entities/item-grid-elements/person/person-grid-element.component.html b/src/app/entity-groups/research-entities/item-grid-elements/person/person-grid-element.component.html index 331c2bd520..b837422121 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/person/person-grid-element.component.html +++ b/src/app/entity-groups/research-entities/item-grid-elements/person/person-grid-element.component.html @@ -1,30 +1 @@ - -
- -
- - -
-
-
- - -

-
- -

- - - -

-
- View -
-
-
-
+ \ No newline at end of file diff --git a/src/app/entity-groups/research-entities/item-grid-elements/person/person-grid-element.component.ts b/src/app/entity-groups/research-entities/item-grid-elements/person/person-grid-element.component.ts index 2458d0b99d..2e3ce5804e 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/person/person-grid-element.component.ts +++ b/src/app/entity-groups/research-entities/item-grid-elements/person/person-grid-element.component.ts @@ -1,18 +1,17 @@ import { Component } from '@angular/core'; -import { TypedItemSearchResultGridElementComponent } from '../../../../shared/object-grid/item-grid-element/item-types/typed-item-search-result-grid-element.component'; -import { focusShadow } from '../../../../shared/animations/focus'; import { ViewMode } from '../../../../core/shared/view-mode.model'; import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +import { AbstractListableElementComponent } from '../../../../shared/object-collection/shared/object-collection-element/abstract-listable-element.component'; +import { Item } from '../../../../core/shared/item.model'; @listableObjectComponent('Person', ViewMode.GridElement) @Component({ selector: 'ds-person-grid-element', styleUrls: ['./person-grid-element.component.scss'], templateUrl: './person-grid-element.component.html', - animations: [focusShadow] }) /** * The component for displaying a grid element for an item of the type Person */ -export class PersonGridElementComponent extends TypedItemSearchResultGridElementComponent { +export class PersonGridElementComponent extends AbstractListableElementComponent { } diff --git a/src/app/entity-groups/research-entities/item-grid-elements/project/project-grid-element.component.html b/src/app/entity-groups/research-entities/item-grid-elements/project/project-grid-element.component.html index 889276b29b..094d109dde 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/project/project-grid-element.component.html +++ b/src/app/entity-groups/research-entities/item-grid-elements/project/project-grid-element.component.html @@ -1,25 +1 @@ - -
- -
- - -
-
-
- - -

-
-

- - - -

-
- View -
-
-
-
+ \ No newline at end of file diff --git a/src/app/entity-groups/research-entities/item-grid-elements/project/project-grid-element.component.ts b/src/app/entity-groups/research-entities/item-grid-elements/project/project-grid-element.component.ts index 067e14bae3..58547960cf 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/project/project-grid-element.component.ts +++ b/src/app/entity-groups/research-entities/item-grid-elements/project/project-grid-element.component.ts @@ -1,18 +1,17 @@ import { Component } from '@angular/core'; -import { focusShadow } from '../../../../shared/animations/focus'; -import { TypedItemSearchResultGridElementComponent } from '../../../../shared/object-grid/item-grid-element/item-types/typed-item-search-result-grid-element.component'; import { ViewMode } from '../../../../core/shared/view-mode.model'; import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +import { AbstractListableElementComponent } from '../../../../shared/object-collection/shared/object-collection-element/abstract-listable-element.component'; +import { Item } from '../../../../core/shared/item.model'; @listableObjectComponent('Project', ViewMode.GridElement) @Component({ selector: 'ds-project-grid-element', styleUrls: ['./project-grid-element.component.scss'], templateUrl: './project-grid-element.component.html', - animations: [focusShadow] }) /** * The component for displaying a grid element for an item of the type Project */ -export class ProjectGridElementComponent extends TypedItemSearchResultGridElementComponent { +export class ProjectGridElementComponent extends AbstractListableElementComponent { } diff --git a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.html b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.html new file mode 100644 index 0000000000..799f5bd43c --- /dev/null +++ b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.html @@ -0,0 +1,37 @@ + + +
+ +
+ + +
+
+
+ + +

+
+

+ + + +

+

+ + {{item.firstMetadataValue('organization.address.addressCountry')}} + + , + {{item.firstMetadataValue('organization.address.addressLocality')}} + + +

+
+ View +
+
+
+
+
\ No newline at end of file diff --git a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.scss b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.scss new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.spec.ts b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.spec.ts new file mode 100644 index 0000000000..f854eaa273 --- /dev/null +++ b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.spec.ts @@ -0,0 +1,56 @@ +import { ItemSearchResult } from '../../../../shared/object-collection/shared/item-search-result.model'; +import { Item } from '../../../../core/shared/item.model'; +import { of as observableOf } from 'rxjs/internal/observable/of'; +import { getEntityGridElementTestComponent } from '../../../../shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.spec'; +import { OrgunitSearchResultGridElementComponent } from './orgunit-grid-element.component'; +import { createSuccessfulRemoteDataObject$ } from '../../../../shared/testing/utils'; +import { PaginatedList } from '../../../../core/data/paginated-list'; +import { PageInfo } from '../../../../core/shared/page-info.model'; + +const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult(); +mockItemWithMetadata.hitHighlights = {}; +mockItemWithMetadata.indexableObject = Object.assign(new Item(), { + bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ], + 'organization.foundingDate': [ + { + language: null, + value: '2015-06-26' + } + ], + 'organization.address.addressCountry': [ + { + language: 'en_US', + value: 'Belgium' + } + ], + 'organization.address.addressLocality': [ + { + language: 'en_US', + value: 'Brussels' + } + ] + } +}); + +const mockItemWithoutMetadata: ItemSearchResult = new ItemSearchResult(); +mockItemWithoutMetadata.hitHighlights = {}; +mockItemWithoutMetadata.indexableObject = Object.assign(new Item(), { + bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ] + } +}); + +describe('OrgunitGridElementComponent', getEntityGridElementTestComponent(OrgunitSearchResultGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['date', 'country', 'city'])); diff --git a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.ts b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.ts new file mode 100644 index 0000000000..535fb0cdbc --- /dev/null +++ b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component.ts @@ -0,0 +1,20 @@ +import { Component } from '@angular/core'; +import { listableObjectComponent } from '../../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +import { ViewMode } from '../../../../../core/shared/view-mode.model'; +import { focusShadow } from '../../../../../shared/animations/focus'; +import { SearchResultGridElementComponent } from '../../../../../shared/object-grid/search-result-grid-element/search-result-grid-element.component'; +import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model'; +import { Item } from '../../../../../core/shared/item.model'; + +@listableObjectComponent('OrgUnitSearchResult', ViewMode.GridElement) +@Component({ + selector: 'ds-orgunit-search-result-grid-element', + styleUrls: ['./orgunit-search-result-grid-element.component.scss'], + templateUrl: './orgunit-search-result-grid-element.component.html', + animations: [focusShadow] +}) +/** + * The component for displaying a grid element for an item of the type Organisation Unit + */ +export class OrgunitSearchResultGridElementComponent extends SearchResultGridElementComponent { +} diff --git a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.html b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.html new file mode 100644 index 0000000000..1f66fa0d4e --- /dev/null +++ b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.html @@ -0,0 +1,32 @@ + + +
+ +
+ + +
+
+
+ + +

+
+ +

+ + + +

+
+ View +
+
+
+
+
\ No newline at end of file diff --git a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.scss b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.scss new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.spec.ts b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.spec.ts new file mode 100644 index 0000000000..752630c7b9 --- /dev/null +++ b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.spec.ts @@ -0,0 +1,50 @@ +import { ItemSearchResult } from '../../../../shared/object-collection/shared/item-search-result.model'; +import { Item } from '../../../../core/shared/item.model'; +import { of as observableOf } from 'rxjs/internal/observable/of'; +import { getEntityGridElementTestComponent } from '../../../../shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.spec'; +import { PersonSearchResultGridElementComponent } from './person-grid-element.component'; +import { createSuccessfulRemoteDataObject$ } from '../../../../shared/testing/utils'; +import { PaginatedList } from '../../../../core/data/paginated-list'; +import { PageInfo } from '../../../../core/shared/page-info.model'; + +const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult(); +mockItemWithMetadata.hitHighlights = {}; +mockItemWithMetadata.indexableObject = Object.assign(new Item(), { + bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ], + 'person.email': [ + { + language: 'en_US', + value: 'Smith-Donald@gmail.com' + } + ], + 'person.jobTitle': [ + { + language: 'en_US', + value: 'Web Developer' + } + ] + } +}); + +const mockItemWithoutMetadata: ItemSearchResult = new ItemSearchResult(); +mockItemWithoutMetadata.hitHighlights = {}; +mockItemWithoutMetadata.indexableObject = Object.assign(new Item(), { + bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ] + } +}); + +describe('PersonGridElementComponent', getEntityGridElementTestComponent(PersonSearchResultGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['email', 'jobtitle'])); diff --git a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.ts b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.ts new file mode 100644 index 0000000000..19293c9ed4 --- /dev/null +++ b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.ts @@ -0,0 +1,20 @@ +import { Component } from '@angular/core'; +import { listableObjectComponent } from '../../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +import { ViewMode } from '../../../../../core/shared/view-mode.model'; +import { focusShadow } from '../../../../../shared/animations/focus'; +import { SearchResultGridElementComponent } from '../../../../../shared/object-grid/search-result-grid-element/search-result-grid-element.component'; +import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model'; +import { Item } from '../../../../../core/shared/item.model'; + +@listableObjectComponent('PersonSearchResult', ViewMode.GridElement) +@Component({ + selector: 'ds-person-search-result-grid-element', + styleUrls: ['./person-search-result-grid-element.component.scss'], + templateUrl: './person-search-result-grid-element.component.html', + animations: [focusShadow] +}) +/** + * The component for displaying a grid element for an item of the type Person + */ +export class PersonSearchResultGridElementComponent extends SearchResultGridElementComponent { +} diff --git a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.html b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.html new file mode 100644 index 0000000000..3465388ee0 --- /dev/null +++ b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.html @@ -0,0 +1,27 @@ + + +
+ +
+ + +
+
+
+ + +

+
+

+ + + +

+
+ View +
+
+
+
+
\ No newline at end of file diff --git a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.scss b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.scss new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.spec.ts b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.spec.ts new file mode 100644 index 0000000000..acf52224be --- /dev/null +++ b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.spec.ts @@ -0,0 +1,44 @@ +import { ItemSearchResult } from '../../../../shared/object-collection/shared/item-search-result.model'; +import { Item } from '../../../../core/shared/item.model'; +import { of as observableOf } from 'rxjs/internal/observable/of'; +import { getEntityGridElementTestComponent } from '../../../../shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.spec'; +import { ProjectSearchResultGridElementComponent } from './project-grid-element.component'; +import { createSuccessfulRemoteDataObject$ } from '../../../../shared/testing/utils'; +import { PaginatedList } from '../../../../core/data/paginated-list'; +import { PageInfo } from '../../../../core/shared/page-info.model'; + +const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult(); +mockItemWithMetadata.hitHighlights = {}; +mockItemWithMetadata.indexableObject = Object.assign(new Item(), { + bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ], + 'dc.description': [ + { + language: 'en_US', + value: 'The project description' + } + ] + } +}); + +const mockItemWithoutMetadata: ItemSearchResult = new ItemSearchResult(); +mockItemWithoutMetadata.hitHighlights = {}; +mockItemWithoutMetadata.indexableObject = Object.assign(new Item(), { + bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ] + } +}); + +describe('ProjectGridElementComponent', getEntityGridElementTestComponent(ProjectSearchResultGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['description'])); diff --git a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.ts b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.ts new file mode 100644 index 0000000000..57c57c6cb1 --- /dev/null +++ b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.ts @@ -0,0 +1,20 @@ +import { Component } from '@angular/core'; +import { SearchResultGridElementComponent } from '../../../../../shared/object-grid/search-result-grid-element/search-result-grid-element.component'; +import { Item } from '../../../../../core/shared/item.model'; +import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model'; +import { listableObjectComponent } from '../../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +import { ViewMode } from '../../../../../core/shared/view-mode.model'; +import { focusShadow } from '../../../../../shared/animations/focus'; + +@listableObjectComponent('ProjectSearchResult', ViewMode.GridElement) +@Component({ + selector: 'ds-project-search-result-grid-element', + styleUrls: ['./project-search-result-grid-element.component.scss'], + templateUrl: './project-search-result-grid-element.component.html', + animations: [focusShadow] +}) +/** + * The component for displaying a grid element for an item of the type Project + */ +export class ProjectSearchResultGridElementComponent extends SearchResultGridElementComponent { +} diff --git a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-item-page-list-element.component.html b/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-item-page-list-element.component.html index ea429e87c6..bacec900c0 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-item-page-list-element.component.html +++ b/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-item-page-list-element.component.html @@ -1,13 +1,13 @@ - - - + diff --git a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-item-page-list-element.component.ts b/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-item-page-list-element.component.ts index 350ddf7ece..84ae543f95 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-item-page-list-element.component.ts +++ b/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-item-page-list-element.component.ts @@ -1,8 +1,9 @@ import { Component } from '@angular/core'; -import { TypedItemSearchResultListElementComponent } from '../../../../shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component'; import { ViewMode } from '../../../../core/shared/view-mode.model'; import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; import { Context } from '../../../../core/shared/context.model'; +import { AbstractListableElementComponent } from '../../../../shared/object-collection/shared/object-collection-element/abstract-listable-element.component'; +import { Item } from '../../../../core/shared/item.model'; @listableObjectComponent('OrgUnit', ViewMode.ListElement, Context.ItemPage) @Component({ @@ -12,5 +13,5 @@ import { Context } from '../../../../core/shared/context.model'; /** * The component for displaying a list element for an item of the type OrgUnit */ -export class OrgunitItemPageListElementComponent extends TypedItemSearchResultListElementComponent { +export class OrgunitItemPageListElementComponent extends AbstractListableElementComponent { } diff --git a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.html b/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.html index 8d312fb7c0..246bac000c 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.html +++ b/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.html @@ -1,16 +1 @@ - - - - - - - - - - - - + \ No newline at end of file diff --git a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.spec.ts b/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.spec.ts index a06ed5ac72..f1ff6b1dce 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.spec.ts +++ b/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.spec.ts @@ -63,7 +63,7 @@ describe('OrgUnitListElementComponent', () => { describe('When the item has an orgunit description', () => { beforeEach(() => { - orgUnitListElementComponent.item = mockItemWithMetadata; + orgUnitListElementComponent.object = mockItemWithMetadata; fixture.detectChanges(); }); @@ -75,7 +75,7 @@ describe('OrgUnitListElementComponent', () => { describe('When the item has no orgunit description', () => { beforeEach(() => { - orgUnitListElementComponent.item = mockItemWithoutMetadata; + orgUnitListElementComponent.object = mockItemWithoutMetadata; fixture.detectChanges(); }); diff --git a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.ts b/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.ts index 8348a3fe35..7e25cf614d 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.ts +++ b/src/app/entity-groups/research-entities/item-list-elements/orgunit/orgunit-list-element.component.ts @@ -1,7 +1,8 @@ import { Component } from '@angular/core'; -import { TypedItemSearchResultListElementComponent } from '../../../../shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component'; import { ViewMode } from '../../../../core/shared/view-mode.model'; import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +import { AbstractListableElementComponent } from '../../../../shared/object-collection/shared/object-collection-element/abstract-listable-element.component'; +import { Item } from '../../../../core/shared/item.model'; @listableObjectComponent('OrgUnit', ViewMode.ListElement) @Component({ @@ -12,5 +13,5 @@ import { listableObjectComponent } from '../../../../shared/object-collection/sh /** * The component for displaying a list element for an item of the type Organisation Unit */ -export class OrgUnitListElementComponent extends TypedItemSearchResultListElementComponent { +export class OrgUnitListElementComponent extends AbstractListableElementComponent { } diff --git a/src/app/entity-groups/research-entities/item-list-elements/person/person-item-page-list-element.component.html b/src/app/entity-groups/research-entities/item-list-elements/person/person-item-page-list-element.component.html index 1125c2fb9b..e9627b504e 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/person/person-item-page-list-element.component.html +++ b/src/app/entity-groups/research-entities/item-list-elements/person/person-item-page-list-element.component.html @@ -1,6 +1,6 @@ - @@ -8,8 +8,8 @@ - - + diff --git a/src/app/entity-groups/research-entities/item-list-elements/person/person-item-page-list-element.component.ts b/src/app/entity-groups/research-entities/item-list-elements/person/person-item-page-list-element.component.ts index 2569a9cb4e..d90b90262c 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/person/person-item-page-list-element.component.ts +++ b/src/app/entity-groups/research-entities/item-list-elements/person/person-item-page-list-element.component.ts @@ -1,8 +1,9 @@ import { Component } from '@angular/core'; -import { TypedItemSearchResultListElementComponent } from '../../../../shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component'; import { ViewMode } from '../../../../core/shared/view-mode.model'; import { Context } from '../../../../core/shared/context.model'; import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +import { AbstractListableElementComponent } from '../../../../shared/object-collection/shared/object-collection-element/abstract-listable-element.component'; +import { Item } from '../../../../core/shared/item.model'; @listableObjectComponent('OrgUnit', ViewMode.ListElement, Context.ItemPage) @Component({ @@ -12,5 +13,5 @@ import { listableObjectComponent } from '../../../../shared/object-collection/sh /** * The component for displaying a list element for an item of the type Person */ -export class PersonItemPageListElementComponent extends TypedItemSearchResultListElementComponent { +export class PersonItemPageListElementComponent extends AbstractListableElementComponent { } diff --git a/src/app/entity-groups/research-entities/item-list-elements/person/person-list-element.component.html b/src/app/entity-groups/research-entities/item-list-elements/person/person-list-element.component.html index c88b77083d..9df315824a 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/person/person-list-element.component.html +++ b/src/app/entity-groups/research-entities/item-list-elements/person/person-list-element.component.html @@ -1,15 +1 @@ - - - - - - - - - - - - + \ No newline at end of file diff --git a/src/app/entity-groups/research-entities/item-list-elements/person/person-list-element.component.spec.ts b/src/app/entity-groups/research-entities/item-list-elements/person/person-list-element.component.spec.ts index 9553f8ea2c..7d9eaf0d16 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/person/person-list-element.component.spec.ts +++ b/src/app/entity-groups/research-entities/item-list-elements/person/person-list-element.component.spec.ts @@ -5,7 +5,6 @@ import { PersonListElementComponent } from './person-list-element.component'; import { of as observableOf } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; import { TruncatePipe } from '../../../../shared/utils/truncate.pipe'; -import { ITEM } from '../../../../shared/items/switcher/listable-object-component-loader.component'; import { TruncatableService } from '../../../../shared/truncatable/truncatable.service'; let personListElementComponent: PersonListElementComponent; @@ -45,7 +44,6 @@ describe('PersonListElementComponent', () => { TestBed.configureTestingModule({ declarations: [ PersonListElementComponent , TruncatePipe], providers: [ - { provide: ITEM, useValue: mockItemWithMetadata}, { provide: TruncatableService, useValue: {} } ], @@ -63,7 +61,7 @@ describe('PersonListElementComponent', () => { describe('When the item has a job title', () => { beforeEach(() => { - personListElementComponent.item = mockItemWithMetadata; + personListElementComponent.object = mockItemWithMetadata; fixture.detectChanges(); }); @@ -75,7 +73,7 @@ describe('PersonListElementComponent', () => { describe('When the item has no job title', () => { beforeEach(() => { - personListElementComponent.item = mockItemWithoutMetadata; + personListElementComponent.object = mockItemWithoutMetadata; fixture.detectChanges(); }); diff --git a/src/app/entity-groups/research-entities/item-list-elements/person/person-list-element.component.ts b/src/app/entity-groups/research-entities/item-list-elements/person/person-list-element.component.ts index bd46cb1cdd..f35ed90c58 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/person/person-list-element.component.ts +++ b/src/app/entity-groups/research-entities/item-list-elements/person/person-list-element.component.ts @@ -1,7 +1,8 @@ import { Component } from '@angular/core'; -import { TypedItemSearchResultListElementComponent } from '../../../../shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component'; import { ViewMode } from '../../../../core/shared/view-mode.model'; import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +import { AbstractListableElementComponent } from '../../../../shared/object-collection/shared/object-collection-element/abstract-listable-element.component'; +import { Item } from '../../../../core/shared/item.model'; @listableObjectComponent('Person', ViewMode.ListElement) @Component({ @@ -12,5 +13,5 @@ import { listableObjectComponent } from '../../../../shared/object-collection/sh /** * The component for displaying a list element for an item of the type Person */ -export class PersonListElementComponent extends TypedItemSearchResultListElementComponent { +export class PersonListElementComponent extends AbstractListableElementComponent { } diff --git a/src/app/entity-groups/research-entities/item-list-elements/project/project-list-element.component.html b/src/app/entity-groups/research-entities/item-list-elements/project/project-list-element.component.html index 3e979b4e4d..6d33c48fb4 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/project/project-list-element.component.html +++ b/src/app/entity-groups/research-entities/item-list-elements/project/project-list-element.component.html @@ -1,16 +1 @@ - - - - - - - - - - - - - - + \ No newline at end of file diff --git a/src/app/entity-groups/research-entities/item-list-elements/project/project-list-element.component.ts b/src/app/entity-groups/research-entities/item-list-elements/project/project-list-element.component.ts index d6b0dbfbce..04d66dcf34 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/project/project-list-element.component.ts +++ b/src/app/entity-groups/research-entities/item-list-elements/project/project-list-element.component.ts @@ -1,7 +1,8 @@ import { Component } from '@angular/core'; -import { TypedItemSearchResultListElementComponent } from '../../../../shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component'; import { metadataRepresentationComponent } from '../../../../shared/metadata-representation/metadata-representation.decorator'; import { MetadataRepresentationType } from '../../../../core/shared/metadata-representation/metadata-representation.model'; +import { AbstractListableElementComponent } from '../../../../shared/object-collection/shared/object-collection-element/abstract-listable-element.component'; +import { Item } from '../../../../core/shared/item.model'; @metadataRepresentationComponent('Project', MetadataRepresentationType.PlainText) @Component({ @@ -12,5 +13,5 @@ import { MetadataRepresentationType } from '../../../../core/shared/metadata-rep /** * The component for displaying a list element for an item of the type Project */ -export class ProjectListElementComponent extends TypedItemSearchResultListElementComponent { +export class ProjectListElementComponent extends AbstractListableElementComponent { } diff --git a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/orgunit/orgunit-search-result-list-element.component.html b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/orgunit/orgunit-search-result-list-element.component.html new file mode 100644 index 0000000000..0bb94c7d24 --- /dev/null +++ b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/orgunit/orgunit-search-result-list-element.component.html @@ -0,0 +1,17 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/orgunit/orgunit-search-result-list-element.component.scss b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/orgunit/orgunit-search-result-list-element.component.scss new file mode 100644 index 0000000000..1d0786105c --- /dev/null +++ b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/orgunit/orgunit-search-result-list-element.component.scss @@ -0,0 +1 @@ +@import '../../../../../styles/variables'; diff --git a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/orgunit/orgunit-search-result-list-element.component.spec.ts b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/orgunit/orgunit-search-result-list-element.component.spec.ts new file mode 100644 index 0000000000..18f405760f --- /dev/null +++ b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/orgunit/orgunit-search-result-list-element.component.spec.ts @@ -0,0 +1,87 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; +import { By } from '@angular/platform-browser'; +import { OrgunitSearchResultListElementComponent } from './orgunit-list-element.component'; +import { of as observableOf } from 'rxjs'; +import { Item } from '../../../../core/shared/item.model'; +import { TruncatePipe } from '../../../../shared/utils/truncate.pipe'; +import { ITEM } from '../../../../shared/items/switcher/listable-object-component-loader.component'; +import { TruncatableService } from '../../../../shared/truncatable/truncatable.service'; + +let orgUnitListElementComponent: OrgunitSearchResultListElementComponent; +let fixture: ComponentFixture; + +const mockItemWithMetadata: Item = Object.assign(new Item(), { + bitstreams: observableOf({}), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ], + 'dc.description': [ + { + language: 'en_US', + value: 'A description about the OrgUnit' + } + ] + } +}); +const mockItemWithoutMetadata: Item = Object.assign(new Item(), { + bitstreams: observableOf({}), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ] + } +}); + +describe('OrgUnitListElementComponent', () => { + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ OrgunitSearchResultListElementComponent , TruncatePipe], + providers: [ + { provide: ITEM, useValue: mockItemWithMetadata}, + { provide: TruncatableService, useValue: {} } + ], + + schemas: [ NO_ERRORS_SCHEMA ] + }).overrideComponent(OrgunitSearchResultListElementComponent, { + set: { changeDetection: ChangeDetectionStrategy.Default } + }).compileComponents(); + })); + + beforeEach(async(() => { + fixture = TestBed.createComponent(OrgunitSearchResultListElementComponent); + orgUnitListElementComponent = fixture.componentInstance; + + })); + + describe('When the item has an orgunit description', () => { + beforeEach(() => { + orgUnitListElementComponent.object = mockItemWithMetadata; + fixture.detectChanges(); + }); + + it('should show the description span', () => { + const orgunitDescriptionField = fixture.debugElement.query(By.css('span.item-list-orgunit-description')); + expect(orgunitDescriptionField).not.toBeNull(); + }); + }); + + describe('When the item has no orgunit description', () => { + beforeEach(() => { + orgUnitListElementComponent.object = mockItemWithoutMetadata; + fixture.detectChanges(); + }); + + it('should not show the description span', () => { + const orgunitDescriptionField = fixture.debugElement.query(By.css('span.item-list-orgunit-description')); + expect(orgunitDescriptionField).toBeNull(); + }); + }); +}); diff --git a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/orgunit/orgunit-search-result-list-element.component.ts b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/orgunit/orgunit-search-result-list-element.component.ts new file mode 100644 index 0000000000..860e1154ef --- /dev/null +++ b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/orgunit/orgunit-search-result-list-element.component.ts @@ -0,0 +1,18 @@ +import { Component } from '@angular/core'; +import { ViewMode } from '../../../../../core/shared/view-mode.model'; +import { listableObjectComponent } from '../../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +import { SearchResultListElementComponent } from '../../../../../shared/object-list/search-result-list-element/search-result-list-element.component'; +import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model'; +import { Item } from '../../../../../core/shared/item.model'; + +@listableObjectComponent('OrgUnitSearchResult', ViewMode.ListElement) +@Component({ + selector: 'ds-orgunit-search-result-list-element', + styleUrls: ['./orgunit-search-result-list-element.component.scss'], + templateUrl: './orgunit-search-result-list-element.component.html' +}) +/** + * The component for displaying a list element for an item of the type Organisation Unit + */ +export class OrgunitSearchResultListElementComponent extends SearchResultListElementComponent { +} diff --git a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/person/person-search-result-list-element.component.html b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/person/person-search-result-list-element.component.html new file mode 100644 index 0000000000..77f29d25ff --- /dev/null +++ b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/person/person-search-result-list-element.component.html @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/person/person-search-result-list-element.component.scss b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/person/person-search-result-list-element.component.scss new file mode 100644 index 0000000000..1d0786105c --- /dev/null +++ b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/person/person-search-result-list-element.component.scss @@ -0,0 +1 @@ +@import '../../../../../styles/variables'; diff --git a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/person/person-search-result-list-element.component.spec.ts b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/person/person-search-result-list-element.component.spec.ts new file mode 100644 index 0000000000..07c53d3c16 --- /dev/null +++ b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/person/person-search-result-list-element.component.spec.ts @@ -0,0 +1,85 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; +import { By } from '@angular/platform-browser'; +import { PersonSearchResultListElementComponent } from './person-list-element.component'; +import { of as observableOf } from 'rxjs'; +import { Item } from '../../../../core/shared/item.model'; +import { TruncatePipe } from '../../../../shared/utils/truncate.pipe'; +import { TruncatableService } from '../../../../shared/truncatable/truncatable.service'; + +let personListElementComponent: PersonSearchResultListElementComponent; +let fixture: ComponentFixture; + +const mockItemWithMetadata: Item = Object.assign(new Item(), { + bitstreams: observableOf({}), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ], + 'person.jobTitle': [ + { + language: 'en_US', + value: 'Developer' + } + ] + } +}); +const mockItemWithoutMetadata: Item = Object.assign(new Item(), { + bitstreams: observableOf({}), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ] + } +}); + +describe('PersonListElementComponent', () => { + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ PersonSearchResultListElementComponent , TruncatePipe], + providers: [ + { provide: TruncatableService, useValue: {} } + ], + + schemas: [ NO_ERRORS_SCHEMA ] + }).overrideComponent(PersonSearchResultListElementComponent, { + set: { changeDetection: ChangeDetectionStrategy.Default } + }).compileComponents(); + })); + + beforeEach(async(() => { + fixture = TestBed.createComponent(PersonSearchResultListElementComponent); + personListElementComponent = fixture.componentInstance; + + })); + + describe('When the item has a job title', () => { + beforeEach(() => { + personListElementComponent.object = mockItemWithMetadata; + fixture.detectChanges(); + }); + + it('should show the job title span', () => { + const jobTitleField = fixture.debugElement.query(By.css('span.item-list-job-title')); + expect(jobTitleField).not.toBeNull(); + }); + }); + + describe('When the item has no job title', () => { + beforeEach(() => { + personListElementComponent.object = mockItemWithoutMetadata; + fixture.detectChanges(); + }); + + it('should not show the job title span', () => { + const jobTitleField = fixture.debugElement.query(By.css('span.item-list-job-title')); + expect(jobTitleField).toBeNull(); + }); + }); +}); diff --git a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/person/person-search-result-list-element.component.ts b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/person/person-search-result-list-element.component.ts new file mode 100644 index 0000000000..b53a369504 --- /dev/null +++ b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/person/person-search-result-list-element.component.ts @@ -0,0 +1,18 @@ +import { Component } from '@angular/core'; +import { SearchResultListElementComponent } from '../../../../../shared/object-list/search-result-list-element/search-result-list-element.component'; +import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model'; +import { listableObjectComponent } from '../../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +import { ViewMode } from '../../../../../core/shared/view-mode.model'; +import { Item } from '../../../../../core/shared/item.model'; + +@listableObjectComponent('PersonSearchResult', ViewMode.ListElement) +@Component({ + selector: 'ds-person-search-result-list-element', + styleUrls: ['./person-search-result-list-element.component.scss'], + templateUrl: './person-search-result-list-element.component.html' +}) +/** + * The component for displaying a list element for an item of the type Person + */ +export class PersonSearchResultListElementComponent extends SearchResultListElementComponent { +} diff --git a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.html b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.html new file mode 100644 index 0000000000..fab5971f9e --- /dev/null +++ b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.html @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + diff --git a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.scss b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.scss new file mode 100644 index 0000000000..1d0786105c --- /dev/null +++ b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.scss @@ -0,0 +1 @@ +@import '../../../../../styles/variables'; diff --git a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.spec.ts b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.spec.ts new file mode 100644 index 0000000000..816467727e --- /dev/null +++ b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.spec.ts @@ -0,0 +1,87 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; +import { By } from '@angular/platform-browser'; +import { ProjectSearchResultListElementComponent } from './project-list-element.component'; +import { of as observableOf } from 'rxjs'; +import { Item } from '../../../../core/shared/item.model'; +import { TruncatePipe } from '../../../../shared/utils/truncate.pipe'; +import { ITEM } from '../../../../shared/items/switcher/listable-object-component-loader.component'; +import { TruncatableService } from '../../../../shared/truncatable/truncatable.service'; + +let projectListElementComponent: ProjectSearchResultListElementComponent; +let fixture: ComponentFixture; + +const mockItemWithMetadata: Item = Object.assign(new Item(), { + bitstreams: observableOf({}), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ], + // 'project.identifier.status': [ + // { + // language: 'en_US', + // value: 'A status about the project' + // } + // ] + } +}); +const mockItemWithoutMetadata: Item = Object.assign(new Item(), { + bitstreams: observableOf({}), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ] + } +}); + +describe('ProjectListElementComponent', () => { + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ ProjectSearchResultListElementComponent , TruncatePipe], + providers: [ + { provide: ITEM, useValue: mockItemWithMetadata}, + { provide: TruncatableService, useValue: {} } + ], + + schemas: [ NO_ERRORS_SCHEMA ] + }).overrideComponent(ProjectSearchResultListElementComponent, { + set: { changeDetection: ChangeDetectionStrategy.Default } + }).compileComponents(); + })); + + beforeEach(async(() => { + fixture = TestBed.createComponent(ProjectSearchResultListElementComponent); + projectListElementComponent = fixture.componentInstance; + + })); + + // describe('When the item has a status', () => { + // beforeEach(() => { + // projectListElementComponent.item = mockItemWithMetadata; + // fixture.detectChanges(); + // }); + // + // it('should show the status span', () => { + // const statusField = fixture.debugElement.query(By.css('span.item-list-status')); + // expect(statusField).not.toBeNull(); + // }); + // }); + // + // describe('When the item has no status', () => { + // beforeEach(() => { + // projectListElementComponent.item = mockItemWithoutMetadata; + // fixture.detectChanges(); + // }); + // + // it('should not show the status span', () => { + // const statusField = fixture.debugElement.query(By.css('span.item-list-status')); + // expect(statusField).toBeNull(); + // }); + // }); +}); diff --git a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.ts b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.ts new file mode 100644 index 0000000000..5fd5d57d81 --- /dev/null +++ b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.ts @@ -0,0 +1,18 @@ +import { Component } from '@angular/core'; +import { SearchResultListElementComponent } from '../../../../../shared/object-list/search-result-list-element/search-result-list-element.component'; +import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model'; +import { metadataRepresentationComponent } from '../../../../../shared/metadata-representation/metadata-representation.decorator'; +import { MetadataRepresentationType } from '../../../../../core/shared/metadata-representation/metadata-representation.model'; +import { Item } from '../../../../../core/shared/item.model'; + +@metadataRepresentationComponent('ProjectSearchResult', MetadataRepresentationType.PlainText) +@Component({ + selector: 'ds-project-search-result-list-element', + styleUrls: ['./project-search-result-list-element.component.scss'], + templateUrl: './project-search-result-list-element.component.html' +}) +/** + * The component for displaying a list element for an item of the type Project + */ +export class ProjectSearchResultListElementComponent extends SearchResultListElementComponent { +} diff --git a/src/app/entity-groups/research-entities/item-pages/orgunit/orgunit.component.html b/src/app/entity-groups/research-entities/item-pages/orgunit/orgunit.component.html index 92ac3eac30..637e59b4fb 100644 --- a/src/app/entity-groups/research-entities/item-pages/orgunit/orgunit.component.html +++ b/src/app/entity-groups/research-entities/item-pages/orgunit/orgunit.component.html @@ -1,24 +1,24 @@

- {{'orgunit.page.titleprefix' | translate}} + {{'orgunit.page.titleprefix' | translate}}

- + - - - - @@ -36,12 +36,12 @@ [items]="publications$ | async" [label]="'relationships.isPublicationOf' | translate"> - diff --git a/src/app/entity-groups/research-entities/item-pages/orgunit/orgunit.component.ts b/src/app/entity-groups/research-entities/item-pages/orgunit/orgunit.component.ts index 164388547c..c63a1c8a53 100644 --- a/src/app/entity-groups/research-entities/item-pages/orgunit/orgunit.component.ts +++ b/src/app/entity-groups/research-entities/item-pages/orgunit/orgunit.component.ts @@ -37,15 +37,15 @@ export class OrgunitComponent extends ItemComponent implements OnInit { if (isNotEmpty(this.resolvedRelsAndTypes$)) { this.people$ = this.resolvedRelsAndTypes$.pipe( - getRelatedItemsByTypeLabel(this.item.id, 'isPersonOfOrgUnit') + getRelatedItemsByTypeLabel(this.object.id, 'isPersonOfOrgUnit') ); this.projects$ = this.resolvedRelsAndTypes$.pipe( - getRelatedItemsByTypeLabel(this.item.id, 'isProjectOfOrgUnit') + getRelatedItemsByTypeLabel(this.object.id, 'isProjectOfOrgUnit') ); this.publications$ = this.resolvedRelsAndTypes$.pipe( - getRelatedItemsByTypeLabel(this.item.id, 'isPublicationOfOrgUnit') + getRelatedItemsByTypeLabel(this.object.id, 'isPublicationOfOrgUnit') ); } }} diff --git a/src/app/entity-groups/research-entities/item-pages/person/person.component.ts b/src/app/entity-groups/research-entities/item-pages/person/person.component.ts index 4783a7548e..78d11ccde4 100644 --- a/src/app/entity-groups/research-entities/item-pages/person/person.component.ts +++ b/src/app/entity-groups/research-entities/item-pages/person/person.component.ts @@ -1,7 +1,6 @@ import { Component, Inject } from '@angular/core'; import { Observable , of as observableOf } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; -import { ITEM } from '../../../../shared/items/switcher/listable-object-component-loader.component'; import { SearchFixedFilterService } from '../../../../+search-page/search-filters/search-filter/search-fixed-filter.service'; import { isNotEmpty } from '../../../../shared/empty.util'; import { ItemComponent } from '../../../../+item-page/simple/item-types/shared/item.component'; @@ -45,28 +44,28 @@ export class PersonComponent extends ItemComponent { fixedFilterQuery: string; constructor( - @Inject(ITEM) public item: Item, private fixedFilterService: SearchFixedFilterService ) { - super(item); + super(); } + ngOnInit(): void { super.ngOnInit(); if (isNotEmpty(this.resolvedRelsAndTypes$)) { this.publications$ = this.resolvedRelsAndTypes$.pipe( - getRelatedItemsByTypeLabel(this.item.id, 'isPublicationOfAuthor') + getRelatedItemsByTypeLabel(this.object.id, 'isPublicationOfAuthor') ); this.projects$ = this.resolvedRelsAndTypes$.pipe( - getRelatedItemsByTypeLabel(this.item.id, 'isProjectOfPerson') + getRelatedItemsByTypeLabel(this.object.id, 'isProjectOfPerson') ); this.orgUnits$ = this.resolvedRelsAndTypes$.pipe( - getRelatedItemsByTypeLabel(this.item.id, 'isOrgUnitOfPerson') + getRelatedItemsByTypeLabel(this.object.id, 'isOrgUnitOfPerson') ); - this.fixedFilterQuery = this.fixedFilterService.getQueryByRelations('isAuthorOfPublication', this.item.id); + this.fixedFilterQuery = this.fixedFilterService.getQueryByRelations('isAuthorOfPublication', this.object.id); this.fixedFilter$ = observableOf('publication'); } } diff --git a/src/app/entity-groups/research-entities/item-pages/project/project.component.html b/src/app/entity-groups/research-entities/item-pages/project/project.component.html index 4e9a130b8c..f9596e7f0c 100644 --- a/src/app/entity-groups/research-entities/item-pages/project/project.component.html +++ b/src/app/entity-groups/research-entities/item-pages/project/project.component.html @@ -1,10 +1,10 @@

- {{'project.page.titleprefix' | translate}} + {{'project.page.titleprefix' | translate}}

- + @@ -14,11 +14,11 @@ [label]="'project.page.contributor' | translate" [representations]="contributors$ | async"> - - @@ -40,16 +40,16 @@ [items]="orgUnits$ | async" [label]="'relationships.isOrgUnitOf' | translate"> - - diff --git a/src/app/entity-groups/research-entities/item-pages/project/project.component.ts b/src/app/entity-groups/research-entities/item-pages/project/project.component.ts index 776e38e7f4..8a672c5eb4 100644 --- a/src/app/entity-groups/research-entities/item-pages/project/project.component.ts +++ b/src/app/entity-groups/research-entities/item-pages/project/project.component.ts @@ -45,15 +45,15 @@ export class ProjectComponent extends ItemComponent implements OnInit { this.contributors$ = this.buildRepresentations('OrgUnit', 'project.contributor.other'); this.people$ = this.resolvedRelsAndTypes$.pipe( - getRelatedItemsByTypeLabel(this.item.id, 'isPersonOfProject') + getRelatedItemsByTypeLabel(this.object.id, 'isPersonOfProject') ); this.publications$ = this.resolvedRelsAndTypes$.pipe( - getRelatedItemsByTypeLabel(this.item.id, 'isPublicationOfProject') + getRelatedItemsByTypeLabel(this.object.id, 'isPublicationOfProject') ); this.orgUnits$ = this.resolvedRelsAndTypes$.pipe( - getRelatedItemsByTypeLabel(this.item.id, 'isOrgUnitOfProject') + getRelatedItemsByTypeLabel(this.object.id, 'isOrgUnitOfProject') ); } } diff --git a/src/app/entity-groups/research-entities/research-entities.module.ts b/src/app/entity-groups/research-entities/research-entities.module.ts index 1f6e477097..2d4d95dfbf 100644 --- a/src/app/entity-groups/research-entities/research-entities.module.ts +++ b/src/app/entity-groups/research-entities/research-entities.module.ts @@ -14,6 +14,12 @@ import { TooltipModule } from 'ngx-bootstrap'; import { PersonGridElementComponent } from './item-grid-elements/person/person-grid-element.component'; import { OrgunitGridElementComponent } from './item-grid-elements/orgunit/orgunit-grid-element.component'; import { ProjectGridElementComponent } from './item-grid-elements/project/project-grid-element.component'; +import { OrgunitSearchResultListElementComponent } from './item-list-elements/search-result-list-elements/orgunit/orgunit-search-result-list-element.component'; +import { PersonSearchResultListElementComponent } from './item-list-elements/search-result-list-elements/person/person-search-result-list-element.component'; +import { ProjectSearchResultListElementComponent } from './item-list-elements/search-result-list-elements/project/project-search-result-list-element.component'; +import { PersonSearchResultGridElementComponent } from './item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component'; +import { OrgunitSearchResultGridElementComponent } from './item-grid-elements/search-result-grid-elements/orgunit/orgunit-search-result-grid-element.component'; +import { ProjectSearchResultGridElementComponent } from './item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component'; const ENTRY_COMPONENTS = [ OrgunitComponent, @@ -26,7 +32,13 @@ const ENTRY_COMPONENTS = [ ProjectListElementComponent, PersonGridElementComponent, OrgunitGridElementComponent, - ProjectGridElementComponent + ProjectGridElementComponent, + OrgunitSearchResultListElementComponent, + PersonSearchResultListElementComponent, + ProjectSearchResultListElementComponent, + PersonSearchResultGridElementComponent, + OrgunitSearchResultGridElementComponent, + ProjectSearchResultGridElementComponent ]; @NgModule({ diff --git a/src/app/shared/object-collection/object-collection.component.ts b/src/app/shared/object-collection/object-collection.component.ts index f90842d58a..2b25915f1e 100644 --- a/src/app/shared/object-collection/object-collection.component.ts +++ b/src/app/shared/object-collection/object-collection.component.ts @@ -1,13 +1,4 @@ -import { - ChangeDetectorRef, - Component, - EventEmitter, - Input, - OnChanges, - OnInit, - Output, - SimpleChanges -} from '@angular/core'; +import { ChangeDetectorRef, Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; import { Observable } from 'rxjs'; @@ -18,7 +9,7 @@ import { PageInfo } from '../../core/shared/page-info.model'; import { PaginationComponentOptions } from '../pagination/pagination-component-options.model'; import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model'; import { ListableObject } from './shared/listable-object.model'; -import { hasValue, isEmpty, isNotEmpty } from '../empty.util'; +import { isNotEmpty } from '../empty.util'; import { ViewMode } from '../../core/shared/view-mode.model'; @Component({ diff --git a/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.ts b/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.ts index 17c860e04b..149425c157 100644 --- a/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.ts +++ b/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.ts @@ -1,9 +1,11 @@ -import { Component, InjectionToken, Injector, Input, OnInit } from '@angular/core'; +import { Component, ComponentFactoryResolver, Input, OnInit, ViewChild } from '@angular/core'; import { ListableObject } from '../listable-object.model'; import { ViewMode } from '../../../../core/shared/view-mode.model'; import { Context } from '../../../../core/shared/context.model'; -import { hasValue } from '../../../empty.util'; import { getListableObjectComponent } from './listable-object.decorator'; +import { GenericConstructor } from '../../../../core/shared/generic-constructor'; +import { ListableObjectDirective } from './listable-object.directive'; +import { hasValue, isNotEmpty } from '../../../empty.util'; @Component({ selector: 'ds-listable-object-component-loader', @@ -14,6 +16,8 @@ import { getListableObjectComponent } from './listable-object.decorator'; * Component for determining what component to use depending on the item's relationship type (relationship.type) */ export class ListableObjectComponentLoaderComponent implements OnInit { + + @Input() type?: string; /** * The item or metadata to determine the component for */ @@ -25,19 +29,29 @@ export class ListableObjectComponentLoaderComponent implements OnInit { @Input() viewMode: ViewMode; @Input() context: Context; + @ViewChild(ListableObjectDirective) listableObjectDirective: ListableObjectDirective; - constructor(private injector: Injector) { + constructor(private componentFactoryResolver: ComponentFactoryResolver) { } ngOnInit(): void { + const componentFactory = this.componentFactoryResolver.resolveComponentFactory(this.getComponent()); + const viewContainerRef = this.listableObjectDirective.viewContainerRef; + viewContainerRef.clear(); + + const componentRef = viewContainerRef.createComponent(componentFactory); + (componentRef.instance as any).object = this.object; } /** * Fetch the component depending on the item's relationship type * @returns {string} */ - private getComponent(): string { - return getListableObjectComponent(this.object, this.viewMode); + private getComponent(): GenericConstructor { + if (isNotEmpty(this.type)) { + return getListableObjectComponent(this.type, this.viewMode) + } + return getListableObjectComponent(this.object.constructor as GenericConstructor, this.viewMode); } } diff --git a/src/app/shared/object-collection/shared/object-collection-element/abstract-listable-element.component.ts b/src/app/shared/object-collection/shared/object-collection-element/abstract-listable-element.component.ts index d52036b5dc..f72d1c9e51 100644 --- a/src/app/shared/object-collection/shared/object-collection-element/abstract-listable-element.component.ts +++ b/src/app/shared/object-collection/shared/object-collection-element/abstract-listable-element.component.ts @@ -1,4 +1,4 @@ -import { Component, Inject } from '@angular/core'; +import { Component, Inject, Input } from '@angular/core'; import { ListableObject } from '../listable-object.model'; @Component({ @@ -6,8 +6,5 @@ import { ListableObject } from '../listable-object.model'; template: ``, }) export class AbstractListableElementComponent { - object: T; - public constructor(@Inject('objectElementProvider') public listableObject: ListableObject) { - this.object = listableObject as T; - } + @Input() object: T; } diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/claimed-my-dspace-result/claimed-my-dspace-result-detail-element.component.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/claimed-my-dspace-result/claimed-my-dspace-result-detail-element.component.ts index 4e947a496f..0c47a239cc 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/claimed-my-dspace-result/claimed-my-dspace-result-detail-element.component.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/claimed-my-dspace-result/claimed-my-dspace-result-detail-element.component.ts @@ -42,10 +42,6 @@ export class ClaimedMyDSpaceResultDetailElementComponent extends MyDSpaceResultD */ public workflowitem: WorkflowItem; - constructor(@Inject('objectElementProvider') public listable: ListableObject) { - super(listable); - } - /** * Initialize all instance variables */ diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/item-detail-preview/item-detail-preview.component.spec.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/item-detail-preview/item-detail-preview.component.spec.ts index 7920e54b00..c5970d751f 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/item-detail-preview/item-detail-preview.component.spec.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/item-detail-preview/item-detail-preview.component.spec.ts @@ -72,7 +72,7 @@ describe('ItemDetailPreviewComponent', () => { fixture = TestBed.createComponent(ItemDetailPreviewComponent); component = fixture.componentInstance; component.object = { hitHighlights: {} } as any; - component.item = mockItem; + component.object = mockItem; component.separator = ', '; spyOn(component.item, 'getFiles').and.returnValue(mockItem.bitstreams); fixture.detectChanges(); diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/my-dspace-result-detail-element.component.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/my-dspace-result-detail-element.component.ts index 47a44d3132..1b83468c68 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/my-dspace-result-detail-element.component.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/my-dspace-result-detail-element.component.ts @@ -22,8 +22,8 @@ export class MyDSpaceResultDetailElementComponent, K * * @param {ListableObject} detailable */ - public constructor(@Inject('objectElementProvider') public detailable: ListableObject) { - super(detailable); + public constructor() { + super(); this.dso = this.object.indexableObject; } diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/pool-my-dspace-result/pool-my-dspace-result-detail-element.component.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/pool-my-dspace-result/pool-my-dspace-result-detail-element.component.ts index 16e96cf412..20fe3dcb2c 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/pool-my-dspace-result/pool-my-dspace-result-detail-element.component.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/pool-my-dspace-result/pool-my-dspace-result-detail-element.component.ts @@ -41,8 +41,8 @@ export class PoolMyDSpaceResultDetailElementComponent extends MyDSpaceResultDeta */ public workflowitem: WorkflowItem; - constructor(@Inject('objectElementProvider') public listable: ListableObject) { - super(listable); + constructor() { + super(); } /** diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/workflowitem-my-dspace-result/workflowitem-my-dspace-result-detail-element.component.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/workflowitem-my-dspace-result/workflowitem-my-dspace-result-detail-element.component.ts index a8c2e5555f..ec83c7f6d0 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/workflowitem-my-dspace-result/workflowitem-my-dspace-result-detail-element.component.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/workflowitem-my-dspace-result/workflowitem-my-dspace-result-detail-element.component.ts @@ -36,10 +36,6 @@ export class WorkflowitemMyDSpaceResultDetailElementComponent extends MyDSpaceRe */ public status = MyDspaceItemStatusType.WORKFLOW; - constructor(@Inject('objectElementProvider') public listable: ListableObject) { - super(listable); - } - /** * Initialize all instance variables */ diff --git a/src/app/shared/object-detail/my-dspace-result-detail-element/workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-detail-element.component.ts b/src/app/shared/object-detail/my-dspace-result-detail-element/workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-detail-element.component.ts index 0415715c44..afb3107fa4 100644 --- a/src/app/shared/object-detail/my-dspace-result-detail-element/workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-detail-element.component.ts +++ b/src/app/shared/object-detail/my-dspace-result-detail-element/workspaceitem-my-dspace-result/workspaceitem-my-dspace-result-detail-element.component.ts @@ -39,10 +39,6 @@ export class WorkspaceitemMyDSpaceResultDetailElementComponent extends MyDSpaceR */ status = MyDspaceItemStatusType.WORKSPACE; - constructor(@Inject('objectElementProvider') public listable: ListableObject) { - super(listable); - } - /** * Initialize all instance variables */ diff --git a/src/app/shared/object-grid/item-grid-element/item-grid-element.component.html b/src/app/shared/object-grid/item-grid-element/item-grid-element.component.html index 6bb2cfa99d..21ee7968ca 100644 --- a/src/app/shared/object-grid/item-grid-element/item-grid-element.component.html +++ b/src/app/shared/object-grid/item-grid-element/item-grid-element.component.html @@ -1,28 +1 @@ - -
- - - - -
-

{{object.firstMetadataValue('dc.title')}}

- - -

- {{author}} - ; - - {{object.firstMetadataValue("dc.date.issued")}} -

-
- - -

{{object.firstMetadataValue("dc.description.abstract")}}

-
- -
- View -
-
-
-
+ diff --git a/src/app/shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.html b/src/app/shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.html index e735dbf107..df413ebead 100644 --- a/src/app/shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.html +++ b/src/app/shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.html @@ -1,34 +1 @@ - -
- -
- - -
-
-
- - -

-
-

- - {{dso.firstMetadataValue('dc.date.issued')}} - , - - - -

-

- - - -

-
- View -
-
-
-
+ diff --git a/src/app/shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.ts b/src/app/shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.ts index f99810ea69..0893d6b121 100644 --- a/src/app/shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.ts +++ b/src/app/shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.ts @@ -1,8 +1,9 @@ -import { TypedItemSearchResultGridElementComponent } from '../typed-item-search-result-grid-element.component'; import { Component } from '@angular/core'; import { focusShadow } from '../../../../animations/focus'; import { ViewMode } from '../../../../../core/shared/view-mode.model'; import { DEFAULT_ITEM_TYPE, listableObjectComponent } from '../../../../object-collection/shared/listable-object/listable-object.decorator'; +import { AbstractListableElementComponent } from '../../../../object-collection/shared/object-collection-element/abstract-listable-element.component'; +import { Item } from '../../../../../core/shared/item.model'; @listableObjectComponent('Publication', ViewMode.GridElement) @listableObjectComponent(DEFAULT_ITEM_TYPE, ViewMode.GridElement) @@ -15,5 +16,5 @@ import { DEFAULT_ITEM_TYPE, listableObjectComponent } from '../../../../object-c /** * The component for displaying a grid element for an item of the type Publication */ -export class PublicationGridElementComponent extends TypedItemSearchResultGridElementComponent { +export class PublicationGridElementComponent extends AbstractListableElementComponent { } diff --git a/src/app/shared/object-grid/item-grid-element/item-types/typed-item-search-result-grid-element.component.spec.ts b/src/app/shared/object-grid/item-grid-element/item-types/typed-item-search-result-grid-element.component.spec.ts deleted file mode 100644 index 8035ec623f..0000000000 --- a/src/app/shared/object-grid/item-grid-element/item-types/typed-item-search-result-grid-element.component.spec.ts +++ /dev/null @@ -1,83 +0,0 @@ -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 { 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 { ITEM } from '../../../items/switcher/listable-object-component-loader.component'; -import { ItemSearchResult } from '../../../object-collection/shared/item-search-result.model'; -import { createRelationshipsObservable } from '../../../../+item-page/simple/item-types/shared/item.component.spec'; -import { of as observableOf } from 'rxjs'; -import { MetadataMap } from '../../../../core/shared/metadata.models'; -import { TypedItemSearchResultGridElementComponent } from './typed-item-search-result-grid-element.component'; - -const mockItem: Item = Object.assign(new Item(), { - bitstreams: observableOf(new RemoteData(false, false, true, null, new PaginatedList(new PageInfo(), []))), - metadata: [], - relationships: createRelationshipsObservable() -}); -const mockSearchResult = { - indexableObject: mockItem as Item, - hitHighlights: new MetadataMap() -} as ItemSearchResult; - -describe('TypedItemSearchResultGridElementComponent', () => { - let comp: TypedItemSearchResultGridElementComponent; - let fixture: ComponentFixture; - - describe('when injecting an Item', () => { - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [TypedItemSearchResultGridElementComponent, TruncatePipe], - providers: [ - {provide: TruncatableService, useValue: {}}, - {provide: ITEM, useValue: mockItem} - ], - - schemas: [NO_ERRORS_SCHEMA] - }).overrideComponent(TypedItemSearchResultGridElementComponent, { - set: {changeDetection: ChangeDetectionStrategy.Default} - }).compileComponents(); - })); - - beforeEach(async(() => { - fixture = TestBed.createComponent(TypedItemSearchResultGridElementComponent); - comp = fixture.componentInstance; - })); - - it('should initiate item, object and dso correctly', () => { - expect(comp.item).toBe(mockItem); - expect(comp.dso).toBe(mockItem); - expect(comp.object.indexableObject).toBe(mockItem); - }) - }); - - describe('when injecting an ItemSearchResult', () => { - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [TypedItemSearchResultGridElementComponent, TruncatePipe], - providers: [ - {provide: TruncatableService, useValue: {}}, - {provide: ITEM, useValue: mockSearchResult} - ], - - schemas: [NO_ERRORS_SCHEMA] - }).overrideComponent(TypedItemSearchResultGridElementComponent, { - set: {changeDetection: ChangeDetectionStrategy.Default} - }).compileComponents(); - })); - - beforeEach(async(() => { - fixture = TestBed.createComponent(TypedItemSearchResultGridElementComponent); - comp = fixture.componentInstance; - })); - - it('should initiate item, object and dso correctly', () => { - expect(comp.item).toBe(mockItem); - expect(comp.dso).toBe(mockItem); - expect(comp.object.indexableObject).toBe(mockItem); - }) - }); -}); diff --git a/src/app/shared/object-grid/item-grid-element/item-types/typed-item-search-result-grid-element.component.ts b/src/app/shared/object-grid/item-grid-element/item-types/typed-item-search-result-grid-element.component.ts deleted file mode 100644 index 3e19b34c04..0000000000 --- a/src/app/shared/object-grid/item-grid-element/item-types/typed-item-search-result-grid-element.component.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { ItemSearchResult } from '../../../object-collection/shared/item-search-result.model'; -import { Item } from '../../../../core/shared/item.model'; -import { SearchResultGridElementComponent } from '../../search-result-grid-element/search-result-grid-element.component'; -import { TruncatableService } from '../../../truncatable/truncatable.service'; -import { Component, Inject } from '@angular/core'; -import { ITEM } from '../../../items/switcher/listable-object-component-loader.component'; -import { hasValue } from '../../../empty.util'; -import { MetadataMap } from '../../../../core/shared/metadata.models'; - -/** - * A generic component for displaying item grid elements - */ -@Component({ - selector: 'ds-item-search-result-grid-element', - template: '' -}) -export class TypedItemSearchResultGridElementComponent extends SearchResultGridElementComponent { - item: Item; - - constructor( - protected truncatableService: TruncatableService, - @Inject(ITEM) public obj: Item | ItemSearchResult, - ) { - super(undefined, truncatableService); - if (hasValue((obj as any).indexableObject)) { - this.object = obj as ItemSearchResult; - this.dso = this.object.indexableObject; - } else { - this.object = { - indexableObject: obj as Item, - hitHighlights: new MetadataMap() - }; - this.dso = obj as Item; - } - this.item = this.dso; - } -} diff --git a/src/app/shared/object-grid/search-result-grid-element/item-search-result/item-search-result-grid-element.component.html b/src/app/shared/object-grid/search-result-grid-element/item-search-result/item-search-result-grid-element.component.html index d433c7acf2..36740cf48f 100644 --- a/src/app/shared/object-grid/search-result-grid-element/item-search-result/item-search-result-grid-element.component.html +++ b/src/app/shared/object-grid/search-result-grid-element/item-search-result/item-search-result-grid-element.component.html @@ -1 +1 @@ - + diff --git a/src/app/shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.html b/src/app/shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.html new file mode 100644 index 0000000000..273be96ca5 --- /dev/null +++ b/src/app/shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.html @@ -0,0 +1,36 @@ + + +
+ +
+ + +
+
+
+ + +

+
+

+ + {{item.firstMetadataValue('dc.date.issued')}} + , + + + +

+

+ + + +

+
+ View +
+
+
+
+
\ No newline at end of file diff --git a/src/app/shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.scss b/src/app/shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.scss new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/app/shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.spec.ts b/src/app/shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.spec.ts new file mode 100644 index 0000000000..0245e0699e --- /dev/null +++ b/src/app/shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.spec.ts @@ -0,0 +1,127 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { NoopAnimationsModule } from '@angular/platform-browser/animations'; +import { TruncatePipe } from '../../../../utils/truncate.pipe'; +import { TruncatableService } from '../../../../truncatable/truncatable.service'; +import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; +import { By } from '@angular/platform-browser'; +import { PublicationSearchResultGridElementComponent } from './publication-grid-element.component'; +import { of as observableOf } from 'rxjs/internal/observable/of'; +import { ItemSearchResult } from '../../../../object-collection/shared/item-search-result.model'; +import { Item } from '../../../../../core/shared/item.model'; +import { ITEM } from '../../../../items/switcher/listable-object-component-loader.component'; +import { createSuccessfulRemoteDataObject$ } from '../../../../testing/utils'; +import { PaginatedList } from '../../../../../core/data/paginated-list'; +import { PageInfo } from '../../../../../core/shared/page-info.model'; + +const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult(); +mockItemWithMetadata.hitHighlights = {}; +mockItemWithMetadata.indexableObject = Object.assign(new Item(), { + bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ], + 'dc.contributor.author': [ + { + language: 'en_US', + value: 'Smith, Donald' + } + ], + 'dc.date.issued': [ + { + language: null, + value: '2015-06-26' + } + ], + 'dc.description.abstract': [ + { + language: 'en_US', + value: 'This is an abstract' + } + ] + } +}); + +const mockItemWithoutMetadata: ItemSearchResult = new ItemSearchResult(); +mockItemWithoutMetadata.hitHighlights = {}; +mockItemWithoutMetadata.indexableObject = Object.assign(new Item(), { + bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ] + } +}); + +describe('PublicationGridElementComponent', getEntityGridElementTestComponent(PublicationSearchResultGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['authors', 'date', 'abstract'])); + +/** + * Create test cases for a grid component of an entity. + * @param component The component's class + * @param searchResultWithMetadata An ItemSearchResult containing an item with metadata that should be displayed in the grid element + * @param searchResultWithoutMetadata An ItemSearchResult containing an item that's missing the metadata that should be displayed in the grid element + * @param fieldsToCheck A list of fields to check. The tests expect to find html elements with class ".item-${field}", so make sure they exist in the html template of the grid element. + * For example: If one of the fields to check is labeled "authors", the html template should contain at least one element with class ".item-authors" that's + * present when the author metadata is available. + */ +export function getEntityGridElementTestComponent(component, searchResultWithMetadata: ItemSearchResult, searchResultWithoutMetadata: ItemSearchResult, fieldsToCheck: string[]) { + return () => { + let comp; + let fixture; + + const truncatableServiceStub: any = { + isCollapsed: (id: number) => observableOf(true), + }; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [NoopAnimationsModule], + declarations: [component, TruncatePipe], + providers: [ + { provide: TruncatableService, useValue: truncatableServiceStub }, + {provide: ITEM, useValue: searchResultWithoutMetadata} + ], + schemas: [NO_ERRORS_SCHEMA] + }).overrideComponent(component, { + set: { changeDetection: ChangeDetectionStrategy.Default } + }).compileComponents(); + })); + + beforeEach(async(() => { + fixture = TestBed.createComponent(component); + comp = fixture.componentInstance; + })); + + fieldsToCheck.forEach((field) => { + describe(`when the item has "${field}" metadata`, () => { + beforeEach(() => { + comp.dso = searchResultWithMetadata.indexableObject; + fixture.detectChanges(); + }); + + it(`should show the "${field}" field`, () => { + const itemAuthorField = fixture.debugElement.query(By.css(`.item-${field}`)); + expect(itemAuthorField).not.toBeNull(); + }); + }); + + describe(`when the item has no "${field}" metadata`, () => { + beforeEach(() => { + comp.dso = searchResultWithoutMetadata.indexableObject; + fixture.detectChanges(); + }); + + it(`should not show the "${field}" field`, () => { + const itemAuthorField = fixture.debugElement.query(By.css(`.item-${field}`)); + expect(itemAuthorField).toBeNull(); + }); + }); + }); + } +} diff --git a/src/app/shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.ts b/src/app/shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.ts new file mode 100644 index 0000000000..bda211532a --- /dev/null +++ b/src/app/shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.ts @@ -0,0 +1,20 @@ +import { Component } from '@angular/core'; +import { focusShadow } from '../../../../animations/focus'; +import { ViewMode } from '../../../../../core/shared/view-mode.model'; +import { listableObjectComponent } from '../../../../object-collection/shared/listable-object/listable-object.decorator'; +import { SearchResultGridElementComponent } from '../../search-result-grid-element.component'; +import { Item } from '../../../../../core/shared/item.model'; +import { ItemSearchResult } from '../../../../object-collection/shared/item-search-result.model'; + +@listableObjectComponent('PublicationSearchResult', ViewMode.GridElement) +@Component({ + selector: 'ds-publication-search-result-grid-element', + styleUrls: ['./publication-search-result-grid-element.component.scss'], + templateUrl: './publication-search-result-grid-element.component.html', + animations: [focusShadow] +}) +/** + * The component for displaying a grid element for an item of the type Publication + */ +export class PublicationSearchResultGridElementComponent extends SearchResultGridElementComponent { +} diff --git a/src/app/shared/object-grid/search-result-grid-element/search-result-grid-element.component.ts b/src/app/shared/object-grid/search-result-grid-element/search-result-grid-element.component.ts index 63b2536043..2213941864 100644 --- a/src/app/shared/object-grid/search-result-grid-element/search-result-grid-element.component.ts +++ b/src/app/shared/object-grid/search-result-grid-element/search-result-grid-element.component.ts @@ -18,8 +18,8 @@ export class SearchResultGridElementComponent, K exten dso: K; isCollapsed$: Observable; - public constructor(@Inject('objectElementProvider') public listableObject: ListableObject, protected truncatableService: TruncatableService) { - super(listableObject); + public constructor(protected truncatableService: TruncatableService) { + super(); if (hasValue(this.object)) { this.dso = this.object.indexableObject; this.isCollapsed$ = this.isCollapsed(); 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 d433c7acf2..21ee7968ca 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-types/publication/publication-list-element.component.html b/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.html index d467edfb21..f4269d357d 100644 --- a/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.html +++ b/src/app/shared/object-list/item-list-element/item-types/publication/publication-list-element.component.html @@ -1,25 +1 @@ - - - - - (, ) - - - - ; - - - - -
- - -
-
+ \ No newline at end of file diff --git a/src/app/shared/object-list/item-list-element/item-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 index fe46669cfe..5761a591dd 100644 --- a/src/app/shared/object-list/item-list-element/item-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 @@ -5,7 +5,6 @@ import { PublicationListElementComponent } from './publication-list-element.comp import { Item } from '../../../../../core/shared/item.model'; import { TruncatePipe } from '../../../../utils/truncate.pipe'; import { TruncatableService } from '../../../../truncatable/truncatable.service'; -import { ITEM } from '../../../../items/switcher/listable-object-component-loader.component'; import { of as observableOf } from 'rxjs'; let publicationListElementComponent: PublicationListElementComponent; @@ -63,7 +62,6 @@ describe('PublicationListElementComponent', () => { TestBed.configureTestingModule({ declarations: [ PublicationListElementComponent , TruncatePipe], providers: [ - { provide: ITEM, useValue: mockItemWithMetadata}, { provide: TruncatableService, useValue: {} } ], @@ -81,7 +79,7 @@ describe('PublicationListElementComponent', () => { describe('When the item has an author', () => { beforeEach(() => { - publicationListElementComponent.item = mockItemWithMetadata; + publicationListElementComponent.object = mockItemWithMetadata; fixture.detectChanges(); }); @@ -93,7 +91,7 @@ describe('PublicationListElementComponent', () => { describe('When the item has no author', () => { beforeEach(() => { - publicationListElementComponent.item = mockItemWithoutMetadata; + publicationListElementComponent.object = mockItemWithoutMetadata; fixture.detectChanges(); }); @@ -105,7 +103,7 @@ describe('PublicationListElementComponent', () => { describe('When the item has a publisher', () => { beforeEach(() => { - publicationListElementComponent.item = mockItemWithMetadata; + publicationListElementComponent.object = mockItemWithMetadata; fixture.detectChanges(); }); @@ -117,7 +115,7 @@ describe('PublicationListElementComponent', () => { describe('When the item has no publisher', () => { beforeEach(() => { - publicationListElementComponent.item = mockItemWithoutMetadata; + publicationListElementComponent.object = mockItemWithoutMetadata; fixture.detectChanges(); }); @@ -129,7 +127,7 @@ describe('PublicationListElementComponent', () => { describe('When the item has an issuedate', () => { beforeEach(() => { - publicationListElementComponent.item = mockItemWithMetadata; + publicationListElementComponent.object = mockItemWithMetadata; fixture.detectChanges(); }); @@ -141,7 +139,7 @@ describe('PublicationListElementComponent', () => { describe('When the item has no issuedate', () => { beforeEach(() => { - publicationListElementComponent.item = mockItemWithoutMetadata; + publicationListElementComponent.object = mockItemWithoutMetadata; fixture.detectChanges(); }); @@ -153,7 +151,7 @@ describe('PublicationListElementComponent', () => { describe('When the item has an abstract', () => { beforeEach(() => { - publicationListElementComponent.item = mockItemWithMetadata; + publicationListElementComponent.object = mockItemWithMetadata; fixture.detectChanges(); }); @@ -165,7 +163,7 @@ describe('PublicationListElementComponent', () => { describe('When the item has no abstract', () => { beforeEach(() => { - publicationListElementComponent.item = mockItemWithoutMetadata; + publicationListElementComponent.object = mockItemWithoutMetadata; fixture.detectChanges(); }); 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 52d2f569b3..9c1b27e785 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,8 @@ import { Component } from '@angular/core'; -import { TypedItemSearchResultListElementComponent } from '../typed-item-search-result-list-element.component'; import { ViewMode } from '../../../../../core/shared/view-mode.model'; import { DEFAULT_ITEM_TYPE, listableObjectComponent } from '../../../../object-collection/shared/listable-object/listable-object.decorator'; +import { AbstractListableElementComponent } from '../../../../object-collection/shared/object-collection-element/abstract-listable-element.component'; +import { Item } from '../../../../../core/shared/item.model'; @listableObjectComponent('Publication', ViewMode.ListElement) @listableObjectComponent(DEFAULT_ITEM_TYPE, ViewMode.ListElement) @@ -13,5 +14,5 @@ import { DEFAULT_ITEM_TYPE, listableObjectComponent } from '../../../../object-c /** * The component for displaying a list element for an item of the type Publication */ -export class PublicationListElementComponent extends TypedItemSearchResultListElementComponent { +export class PublicationListElementComponent extends AbstractListableElementComponent { } diff --git a/src/app/shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component.spec.ts b/src/app/shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component.spec.ts deleted file mode 100644 index c114a941cf..0000000000 --- a/src/app/shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component.spec.ts +++ /dev/null @@ -1,84 +0,0 @@ -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 { 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'; -import { PageInfo } from '../../../../core/shared/page-info.model'; -import { ITEM } from '../../../items/switcher/listable-object-component-loader.component'; -import { ItemSearchResult } from '../../../object-collection/shared/item-search-result.model'; -import { createRelationshipsObservable } from '../../../../+item-page/simple/item-types/shared/item.component.spec'; -import { of as observableOf } from 'rxjs'; -import { MetadataMap } from '../../../../core/shared/metadata.models'; -import { createSuccessfulRemoteDataObject$ } from '../../../testing/utils'; - -const mockItem: Item = Object.assign(new Item(), { - bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), - metadata: [], - relationships: createRelationshipsObservable() -}); -const mockSearchResult = { - indexableObject: mockItem as Item, - hitHighlights: new MetadataMap() -} as ItemSearchResult; - -describe('TypedItemSearchResultListElementComponent', () => { - let comp: TypedItemSearchResultListElementComponent; - let fixture: ComponentFixture; - - describe('when injecting an Item', () => { - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [TypedItemSearchResultListElementComponent, TruncatePipe], - providers: [ - {provide: TruncatableService, useValue: {}}, - {provide: ITEM, useValue: mockItem} - ], - - schemas: [NO_ERRORS_SCHEMA] - }).overrideComponent(TypedItemSearchResultListElementComponent, { - set: {changeDetection: ChangeDetectionStrategy.Default} - }).compileComponents(); - })); - - beforeEach(async(() => { - fixture = TestBed.createComponent(TypedItemSearchResultListElementComponent); - comp = fixture.componentInstance; - })); - - it('should initiate item, object and dso correctly', () => { - expect(comp.item).toBe(mockItem); - expect(comp.dso).toBe(mockItem); - expect(comp.object.indexableObject).toBe(mockItem); - }) - }); - - describe('when injecting an ItemSearchResult', () => { - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [TypedItemSearchResultListElementComponent, TruncatePipe], - providers: [ - {provide: TruncatableService, useValue: {}}, - {provide: ITEM, useValue: mockSearchResult} - ], - - schemas: [NO_ERRORS_SCHEMA] - }).overrideComponent(TypedItemSearchResultListElementComponent, { - set: {changeDetection: ChangeDetectionStrategy.Default} - }).compileComponents(); - })); - - beforeEach(async(() => { - fixture = TestBed.createComponent(TypedItemSearchResultListElementComponent); - comp = fixture.componentInstance; - })); - - it('should initiate item, object and dso correctly', () => { - expect(comp.item).toBe(mockItem); - expect(comp.dso).toBe(mockItem); - expect(comp.object.indexableObject).toBe(mockItem); - }) - }); -}); diff --git a/src/app/shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component.ts b/src/app/shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component.ts deleted file mode 100644 index cf7dc0b330..0000000000 --- a/src/app/shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { Component, Inject } from '@angular/core'; -import { Item } from '../../../../core/shared/item.model'; -import { hasValue } from '../../../empty.util'; -import { ITEM } from '../../../items/switcher/listable-object-component-loader.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'; -import { MetadataMap } from '../../../../core/shared/metadata.models'; - -/** - * A generic component for displaying item list elements - */ -@Component({ - selector: 'ds-item-search-result-list-element', - template: '' -}) -export class TypedItemSearchResultListElementComponent extends SearchResultListElementComponent { - item: Item; - - constructor( - protected truncatableService: TruncatableService, - @Inject(ITEM) public obj: Item | ItemSearchResult, - ) { - super(undefined, truncatableService); - if (hasValue((obj as any).indexableObject)) { - this.object = obj as ItemSearchResult; - this.dso = this.object.indexableObject; - } else { - this.object = { - indexableObject: obj as Item, - hitHighlights: new MetadataMap() - }; - this.dso = obj as Item; - } - this.item = this.dso; - } -} 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 index 427726149f..b7f4a381e2 100644 --- 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 @@ -1,6 +1,5 @@ -import { Component, Inject } from '@angular/core'; +import { Component } from '@angular/core'; import { MetadataRepresentation } from '../../../core/shared/metadata-representation/metadata-representation.model'; -import { ITEM } from '../../items/switcher/listable-object-component-loader.component'; @Component({ selector: 'ds-metadata-representation-list-element', diff --git a/src/app/shared/object-list/my-dspace-result-list-element/my-dspace-result-list-element.component.ts b/src/app/shared/object-list/my-dspace-result-list-element/my-dspace-result-list-element.component.ts index b2a5bf14fd..0db8b73412 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/my-dspace-result-list-element.component.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/my-dspace-result-list-element.component.ts @@ -28,9 +28,8 @@ export class MyDSpaceResultListElementComponent, K e * @param {ListableObject} listable * @param {number} index */ - public constructor(@Inject('objectElementProvider') public listable: ListableObject, - @Inject('indexElementProvider') public index: number) { - super(listable); + public constructor(@Inject('indexElementProvider') public index: number) { + super(); this.dso = this.object.indexableObject; this.dsoIndex = this.index; } diff --git a/src/app/shared/object-list/my-dspace-result-list-element/pool-my-dspace-result/pool-my-dspace-result-list-element.component.ts b/src/app/shared/object-list/my-dspace-result-list-element/pool-my-dspace-result/pool-my-dspace-result-list-element.component.ts index d3876714dc..1f9499f6aa 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/pool-my-dspace-result/pool-my-dspace-result-list-element.component.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/pool-my-dspace-result/pool-my-dspace-result-list-element.component.ts @@ -42,9 +42,8 @@ export class PoolMyDSpaceResultListElementComponent extends MyDSpaceResultListEl */ public workflowitem: WorkflowItem; - constructor(@Inject('objectElementProvider') public listable: ListableObject, - @Inject('indexElementProvider') public index: number) { - super(listable, index); + constructor(@Inject('indexElementProvider') public index: number) { + super(index); } /** 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 051a27bde7..901ce441bf 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,2 +1,2 @@ - + diff --git a/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component.html b/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component.html new file mode 100644 index 0000000000..2d42fb611d --- /dev/null +++ b/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component.html @@ -0,0 +1,27 @@ + + + + + + (, ) + + + + ; + + + + +
+ + +
+
+
\ No newline at end of file diff --git a/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component.scss b/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component.scss new file mode 100644 index 0000000000..5e4536cf95 --- /dev/null +++ b/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component.scss @@ -0,0 +1 @@ +@import '../../../../../../../styles/variables'; diff --git a/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component.spec.ts b/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component.spec.ts new file mode 100644 index 0000000000..1b77c5bd85 --- /dev/null +++ b/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component.spec.ts @@ -0,0 +1,177 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; +import { By } from '@angular/platform-browser'; +import { PublicationSearchResultListElementComponent } 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 '../../../../items/switcher/listable-object-component-loader.component'; +import { of as observableOf } from 'rxjs'; + +let publicationListElementComponent: PublicationSearchResultListElementComponent; +let fixture: ComponentFixture; + +const mockItemWithMetadata: Item = Object.assign(new Item(), { + bitstreams: observableOf({}), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ], + 'dc.contributor.author': [ + { + language: 'en_US', + value: 'Smith, Donald' + } + ], + 'dc.publisher': [ + { + language: 'en_US', + value: 'a publisher' + } + ], + 'dc.date.issued': [ + { + language: 'en_US', + value: '2015-06-26' + } + ], + 'dc.description.abstract': [ + { + language: 'en_US', + value: 'This is the abstract' + } + ] + } +}); +const mockItemWithoutMetadata: Item = Object.assign(new Item(), { + bitstreams: observableOf({}), + metadata: { + 'dc.title': [ + { + language: 'en_US', + value: 'This is just another title' + } + ] + } +}); + +describe('PublicationListElementComponent', () => { + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ PublicationSearchResultListElementComponent , TruncatePipe], + providers: [ + { provide: ITEM, useValue: mockItemWithMetadata}, + { provide: TruncatableService, useValue: {} } + ], + + schemas: [ NO_ERRORS_SCHEMA ] + }).overrideComponent(PublicationSearchResultListElementComponent, { + set: { changeDetection: ChangeDetectionStrategy.Default } + }).compileComponents(); + })); + + beforeEach(async(() => { + fixture = TestBed.createComponent(PublicationSearchResultListElementComponent); + publicationListElementComponent = fixture.componentInstance; + + })); + + describe('When the item has an author', () => { + beforeEach(() => { + publicationListElementComponent.object = mockItemWithMetadata; + fixture.detectChanges(); + }); + + it('should show the author paragraph', () => { + const itemAuthorField = fixture.debugElement.query(By.css('span.item-list-authors')); + expect(itemAuthorField).not.toBeNull(); + }); + }); + + describe('When the item has no author', () => { + beforeEach(() => { + publicationListElementComponent.object = mockItemWithoutMetadata; + fixture.detectChanges(); + }); + + it('should not show the author paragraph', () => { + const itemAuthorField = fixture.debugElement.query(By.css('span.item-list-authors')); + expect(itemAuthorField).toBeNull(); + }); + }); + + describe('When the item has a publisher', () => { + beforeEach(() => { + publicationListElementComponent.object = mockItemWithMetadata; + fixture.detectChanges(); + }); + + it('should show the publisher span', () => { + const publisherField = fixture.debugElement.query(By.css('span.item-list-publisher')); + expect(publisherField).not.toBeNull(); + }); + }); + + describe('When the item has no publisher', () => { + beforeEach(() => { + publicationListElementComponent.object = mockItemWithoutMetadata; + fixture.detectChanges(); + }); + + it('should not show the publisher span', () => { + const publisherField = fixture.debugElement.query(By.css('span.item-list-publisher')); + expect(publisherField).toBeNull(); + }); + }); + + describe('When the item has an issuedate', () => { + beforeEach(() => { + publicationListElementComponent.object = mockItemWithMetadata; + fixture.detectChanges(); + }); + + it('should show the issuedate span', () => { + const dateField = fixture.debugElement.query(By.css('span.item-list-date')); + expect(dateField).not.toBeNull(); + }); + }); + + describe('When the item has no issuedate', () => { + beforeEach(() => { + publicationListElementComponent.object = mockItemWithoutMetadata; + fixture.detectChanges(); + }); + + it('should not show the issuedate span', () => { + const dateField = fixture.debugElement.query(By.css('span.item-list-date')); + expect(dateField).toBeNull(); + }); + }); + + describe('When the item has an abstract', () => { + beforeEach(() => { + publicationListElementComponent.object = mockItemWithMetadata; + fixture.detectChanges(); + }); + + it('should show the abstract span', () => { + const abstractField = fixture.debugElement.query(By.css('div.item-list-abstract')); + expect(abstractField).not.toBeNull(); + }); + }); + + describe('When the item has no abstract', () => { + beforeEach(() => { + publicationListElementComponent.object = mockItemWithoutMetadata; + fixture.detectChanges(); + }); + + it('should not show the abstract span', () => { + const abstractField = fixture.debugElement.query(By.css('div.item-list-abstract')); + expect(abstractField).toBeNull(); + }); + }); +}); diff --git a/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component.ts b/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component.ts new file mode 100644 index 0000000000..74d0d30f8d --- /dev/null +++ b/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component.ts @@ -0,0 +1,18 @@ +import { Component } from '@angular/core'; +import { listableObjectComponent } from '../../../../../object-collection/shared/listable-object/listable-object.decorator'; +import { ViewMode } from '../../../../../../core/shared/view-mode.model'; +import { ItemSearchResult } from '../../../../../object-collection/shared/item-search-result.model'; +import { SearchResultListElementComponent } from '../../../search-result-list-element.component'; +import { Item } from '../../../../../../core/shared/item.model'; + +@listableObjectComponent('PublicationSearchResult', ViewMode.ListElement) +@Component({ + selector: 'ds-publication-search-result-list-element', + styleUrls: ['./publication-search-result-list-element.component.scss'], + templateUrl: './publication-search-result-list-element.component.html' +}) +/** + * The component for displaying a list element for an item of the type Publication + */ +export class PublicationSearchResultListElementComponent extends SearchResultListElementComponent { +} diff --git a/src/app/shared/object-list/search-result-list-element/search-result-list-element.component.ts b/src/app/shared/object-list/search-result-list-element/search-result-list-element.component.ts index 7017f3f48b..f9110c0cb4 100644 --- a/src/app/shared/object-list/search-result-list-element/search-result-list-element.component.ts +++ b/src/app/shared/object-list/search-result-list-element/search-result-list-element.component.ts @@ -19,8 +19,8 @@ export class SearchResultListElementComponent, K exten dso: K; metadata: MetadataMap; - public constructor(@Inject('objectElementProvider') public listable: ListableObject, protected truncatableService: TruncatableService) { - super(listable); + public constructor(protected truncatableService: TruncatableService) { + super(); if (hasValue(this.object)) { this.dso = this.object.indexableObject; } diff --git a/src/app/shared/shared.module.ts b/src/app/shared/shared.module.ts index d50056d731..8aa5bf0fdd 100644 --- a/src/app/shared/shared.module.ts +++ b/src/app/shared/shared.module.ts @@ -9,8 +9,6 @@ import { NgbDatepickerModule, NgbModule, NgbTimepickerModule, NgbTypeaheadModule import { TranslateModule } from '@ngx-translate/core'; import { NgxPaginationModule } from 'ngx-pagination'; -import { ListableObjectComponentLoaderComponent } from './items/switcher/listable-object-component-loader.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 { FileUploadModule } from 'ng2-file-upload'; @@ -26,13 +24,11 @@ import { CollectionListElementComponent } from './object-list/collection-list-el import { CommunityListElementComponent } from './object-list/community-list-element/community-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'; import { CollectionGridElementComponent } from './object-grid/collection-grid-element/collection-grid-element.component'; import { CommunityGridElementComponent } from './object-grid/community-grid-element/community-grid-element.component'; import { ItemGridElementComponent } from './object-grid/item-grid-element/item-grid-element.component'; import { AbstractListableElementComponent } from './object-collection/shared/object-collection-element/abstract-listable-element.component'; -import { WrapperGridElementComponent } from './object-grid/wrapper-grid-element/wrapper-grid-element.component'; import { ObjectGridComponent } from './object-grid/object-grid.component'; import { ObjectCollectionComponent } from './object-collection/object-collection.component'; import { ComcolPageContentComponent } from './comcol-page-content/comcol-page-content.component'; @@ -85,7 +81,6 @@ import { MyDSpaceResultDetailElementComponent } from './object-detail/my-dspace- import { ClaimedTaskActionsComponent } from './mydspace-actions/claimed-task/claimed-task-actions.component'; import { PoolTaskActionsComponent } from './mydspace-actions/pool-task/pool-task-actions.component'; import { ObjectDetailComponent } from './object-detail/object-detail.component'; -import { WrapperDetailElementComponent } from './object-detail/wrapper-detail-element/wrapper-detail-element.component'; import { ItemDetailPreviewComponent } from './object-detail/my-dspace-result-detail-element/item-detail-preview/item-detail-preview.component'; import { MyDSpaceItemStatusComponent } from './object-collection/shared/mydspace-item-status/my-dspace-item-status.component'; import { WorkspaceitemActionsComponent } from './mydspace-actions/workspaceitem/workspaceitem-actions.component'; @@ -140,11 +135,13 @@ import { ClaimedTaskActionsReturnToPoolComponent } from './mydspace-actions/clai import { ItemDetailPreviewFieldComponent } from './object-detail/my-dspace-result-detail-element/item-detail-preview/item-detail-preview-field/item-detail-preview-field.component'; import { FilterInputSuggestionsComponent } from './input-suggestions/filter-suggestions/filter-input-suggestions.component'; import { DsoInputSuggestionsComponent } from './input-suggestions/dso-input-suggestions/dso-input-suggestions.component'; -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 { MetadataRepresentationLoaderComponent } from './metadata-representation/metadata-representation-loader.component'; import { MetadataRepresentationDirective } from './metadata-representation/metadata-representation.directive'; +import { ListableObjectComponentLoaderComponent } from './object-collection/shared/listable-object/listable-object-component-loader.component'; +import { PublicationSearchResultListElementComponent } from './object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component'; +import { PublicationSearchResultGridElementComponent } from './object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component'; const MODULES = [ // Do NOT include UniversalModule, HttpModule, or JsonpModule here @@ -224,16 +221,12 @@ const COMPONENTS = [ ObjectDetailComponent, ObjectGridComponent, AbstractListableElementComponent, - WrapperListElementComponent, - WrapperDetailElementComponent, - WrapperGridElementComponent, ObjectCollectionComponent, PaginationComponent, SearchFormComponent, ThumbnailComponent, GridThumbnailComponent, UploaderComponent, - WrapperListElementComponent, ItemListPreviewComponent, MyDSpaceItemStatusComponent, ItemSubmitterComponent, @@ -264,8 +257,6 @@ const COMPONENTS = [ CommunitySearchResultListElementComponent, CollectionSearchResultListElementComponent, ItemSearchResultListElementComponent, - TypedItemSearchResultListElementComponent, - TypedItemSearchResultGridElementComponent, ListableObjectComponentLoaderComponent, BrowseByComponent, ItemTypeBadgeComponent, @@ -288,6 +279,8 @@ const ENTRY_COMPONENTS = [ SearchResultGridElementComponent, PublicationListElementComponent, PublicationGridElementComponent, + PublicationSearchResultListElementComponent, + PublicationSearchResultGridElementComponent, BrowseEntryListElementComponent, MyDSpaceResultDetailElementComponent, SearchResultGridElementComponent, @@ -352,7 +345,8 @@ const DIRECTIVES = [ ...COMPONENTS, ...DIRECTIVES, ...ENTRY_COMPONENTS, - ...SHARED_ITEM_PAGE_COMPONENTS + ...SHARED_ITEM_PAGE_COMPONENTS, + PublicationSearchResultListElementComponent ], providers: [ ...PROVIDERS diff --git a/src/backend/api.ts b/src/backend/api.ts index e1943b5d30..da83b1ba12 100644 --- a/src/backend/api.ts +++ b/src/backend/api.ts @@ -117,7 +117,7 @@ export function createMockApi() { const id = req.params.item_id; try { req.item_id = id; - req.item = ITEMS.items.find((item) => { + req.object = ITEMS.items.find((item) => { return item.id === id; }); next(); @@ -127,7 +127,7 @@ export function createMockApi() { }); router.route('/items/:item_id').get((req, res) => { - res.json(toHALResponse(req, req.item)); + res.json(toHALResponse(req, req.object)); }); router.route('/bundles').get((req, res) => {