-
+
@@ -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")}}
-
-
-
-
-
-
+
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')}}
- ,
-
-
-
-
-
-
-
-
-
-
-
-
-
+
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')}}
+ ,
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ 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 @@
-
-
-
-
- (, )
- 0"
- class="item-list-authors">
-
-
- ;
-
-
-
-
-
-
-
-
-
+
\ 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 @@
+
+
+
+
+
+ (, )
+ 0"
+ class="item-list-authors">
+
+
+ ;
+
+
+
+
+
+
+
+
+
+
\ 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) => {