diff --git a/src/app/shared/object-list/my-dspace-result-list-element/claimed-search-result/claimed-search-result-list-element.component.html b/src/app/shared/object-list/my-dspace-result-list-element/claimed-search-result/claimed-search-result-list-element.component.html index 747fb9bc36..2cee94ce20 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/claimed-search-result/claimed-search-result-list-element.component.html +++ b/src/app/shared/object-list/my-dspace-result-list-element/claimed-search-result/claimed-search-result-list-element.component.html @@ -1,9 +1,18 @@ - - - - + + +
+
+ +
+
+ + + + diff --git a/src/app/shared/object-list/my-dspace-result-list-element/claimed-search-result/claimed-search-result-list-element.component.spec.ts b/src/app/shared/object-list/my-dspace-result-list-element/claimed-search-result/claimed-search-result-list-element.component.spec.ts index 3e9f64e718..c5383a2e31 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/claimed-search-result/claimed-search-result-list-element.component.spec.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/claimed-search-result/claimed-search-result-list-element.component.spec.ts @@ -1,5 +1,5 @@ import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; -import { ComponentFixture, fakeAsync, TestBed, tick, waitForAsync } from '@angular/core/testing'; +import { ComponentFixture, fakeAsync, flush, TestBed, tick, waitForAsync } from '@angular/core/testing'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { of as observableOf } from 'rxjs'; @@ -7,7 +7,9 @@ import { of as observableOf } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; import { ClaimedSearchResultListElementComponent } from './claimed-search-result-list-element.component'; import { ClaimedTask } from '../../../../core/tasks/models/claimed-task-object.model'; -import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; +import { + MyDspaceItemStatusType +} from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; import { WorkflowItem } from '../../../../core/submission/models/workflowitem.model'; import { createSuccessfulRemoteDataObject } from '../../../remote-data.utils'; import { ClaimedTaskSearchResult } from '../../../object-collection/shared/claimed-task-search-result.model'; @@ -94,17 +96,15 @@ describe('ClaimedSearchResultListElementComponent', () => { fixture.detectChanges(); }); - it('should init workflowitem properly', (done) => { - component.workflowitemRD$.subscribe((workflowitemRD) => { - expect(linkService.resolveLinks).toHaveBeenCalledWith( - component.dso, - jasmine.objectContaining({ name: 'workflowitem' }), - jasmine.objectContaining({ name: 'action' }) - ); - expect(workflowitemRD.payload).toEqual(workflowitem); - done(); - }); - }); + it('should init workflowitem properly', fakeAsync(() => { + flush(); + expect(linkService.resolveLinks).toHaveBeenCalledWith( + component.dso, + jasmine.objectContaining({ name: 'workflowitem' }), + jasmine.objectContaining({ name: 'action' }) + ); + expect(component.workflowitem$.value).toEqual(workflowitem); + })); it('should have properly status', () => { expect(component.status).toEqual(MyDspaceItemStatusType.VALIDATION); diff --git a/src/app/shared/object-list/my-dspace-result-list-element/claimed-search-result/claimed-search-result-list-element.component.ts b/src/app/shared/object-list/my-dspace-result-list-element/claimed-search-result/claimed-search-result-list-element.component.ts index 2d02687a43..c1458043a7 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/claimed-search-result/claimed-search-result-list-element.component.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/claimed-search-result/claimed-search-result-list-element.component.ts @@ -5,16 +5,21 @@ import { listableObjectComponent } from '../../../object-collection/shared/lista import { ClaimedTaskSearchResult } from '../../../object-collection/shared/claimed-task-search-result.model'; import { LinkService } from '../../../../core/cache/builders/link.service'; import { TruncatableService } from '../../../truncatable/truncatable.service'; -import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; -import { Observable } from 'rxjs'; +import { + MyDspaceItemStatusType +} from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; +import { BehaviorSubject, Observable } from 'rxjs'; import { RemoteData } from '../../../../core/data/remote-data'; import { WorkflowItem } from '../../../../core/submission/models/workflowitem.model'; import { followLink } from '../../../utils/follow-link-config.model'; -import { SearchResultListElementComponent } from '../../search-result-list-element/search-result-list-element.component'; +import { + SearchResultListElementComponent +} from '../../search-result-list-element/search-result-list-element.component'; import { ClaimedTask } from '../../../../core/tasks/models/claimed-task-object.model'; import { DSONameService } from '../../../../core/breadcrumbs/dso-name.service'; import { APP_CONFIG, AppConfig } from '../../../../../config/app-config.interface'; import { ObjectCacheService } from '../../../../core/cache/object-cache.service'; +import { getFirstCompletedRemoteData } from '../../../../core/shared/operators'; @Component({ selector: 'ds-claimed-search-result-list-element', @@ -37,7 +42,12 @@ export class ClaimedSearchResultListElementComponent extends SearchResultListEle /** * The workflowitem object that belonging to the result object */ - public workflowitemRD$: Observable>; + public workflowitem$: BehaviorSubject = new BehaviorSubject(null); + + /** + * Display thumbnails if required by configuration + */ + showThumbnails: boolean; public constructor( protected linkService: LinkService, @@ -57,7 +67,14 @@ export class ClaimedSearchResultListElementComponent extends SearchResultListEle this.linkService.resolveLinks(this.dso, followLink('workflowitem', {}, followLink('item'), followLink('submitter') ), followLink('action')); - this.workflowitemRD$ = this.dso.workflowitem as Observable>; + (this.dso.workflowitem as Observable>).pipe( + getFirstCompletedRemoteData() + ).subscribe((wfiRD: RemoteData) => { + if (wfiRD.hasSucceeded) { + this.workflowitem$.next(wfiRD.payload); + } + }); + this.showThumbnails = this.appConfig.browseBy.showThumbnails; } ngOnDestroy() { diff --git a/src/app/shared/object-list/my-dspace-result-list-element/pool-search-result/pool-search-result-list-element.component.html b/src/app/shared/object-list/my-dspace-result-list-element/pool-search-result/pool-search-result-list-element.component.html index 0fd27eb073..6a6e729dea 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/pool-search-result/pool-search-result-list-element.component.html +++ b/src/app/shared/object-list/my-dspace-result-list-element/pool-search-result/pool-search-result-list-element.component.html @@ -1,13 +1,12 @@ - - -
-
- -
+ +
+
+
- +
diff --git a/src/app/shared/object-list/my-dspace-result-list-element/pool-search-result/pool-search-result-list-element.component.spec.ts b/src/app/shared/object-list/my-dspace-result-list-element/pool-search-result/pool-search-result-list-element.component.spec.ts index 9f40ebb1f4..ab5652138e 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/pool-search-result/pool-search-result-list-element.component.spec.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/pool-search-result/pool-search-result-list-element.component.spec.ts @@ -1,5 +1,5 @@ import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; -import { waitForAsync, ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing'; +import { ComponentFixture, fakeAsync, flush, TestBed, tick, waitForAsync } from '@angular/core/testing'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { of as observableOf } from 'rxjs'; @@ -7,7 +7,9 @@ import { of as observableOf } from 'rxjs'; import { Item } from '../../../../core/shared/item.model'; import { PoolSearchResultListElementComponent } from './pool-search-result-list-element.component'; import { PoolTask } from '../../../../core/tasks/models/pool-task-object.model'; -import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; +import { + MyDspaceItemStatusType +} from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; import { WorkflowItem } from '../../../../core/submission/models/workflowitem.model'; import { createSuccessfulRemoteDataObject } from '../../../remote-data.utils'; import { PoolTaskSearchResult } from '../../../object-collection/shared/pool-task-search-result.model'; @@ -72,7 +74,6 @@ const objectCacheServiceMock = jasmine.createSpyObj('ObjectCacheService', { remove: jasmine.createSpy('remove') }); - describe('PoolSearchResultListElementComponent', () => { beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ @@ -101,17 +102,15 @@ describe('PoolSearchResultListElementComponent', () => { fixture.detectChanges(); }); - it('should init workflowitem properly', (done) => { - component.workflowitemRD$.subscribe((workflowitemRD) => { - expect(linkService.resolveLinks).toHaveBeenCalledWith( - component.dso, - jasmine.objectContaining({ name: 'workflowitem' }), - jasmine.objectContaining({ name: 'action' }) - ); - expect(workflowitemRD.payload).toEqual(workflowitem); - done(); - }); - }); + it('should init workflowitem properly', fakeAsync(() => { + flush(); + expect(linkService.resolveLinks).toHaveBeenCalledWith( + component.dso, + jasmine.objectContaining({ name: 'workflowitem' }), + jasmine.objectContaining({ name: 'action' }) + ); + expect(component.workflowitem$.value).toEqual(workflowitem); + })); it('should have properly status', () => { expect(component.status).toEqual(MyDspaceItemStatusType.WAITING_CONTROLLER); diff --git a/src/app/shared/object-list/my-dspace-result-list-element/pool-search-result/pool-search-result-list-element.component.ts b/src/app/shared/object-list/my-dspace-result-list-element/pool-search-result/pool-search-result-list-element.component.ts index 60ba846347..a42b3d04d6 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/pool-search-result/pool-search-result-list-element.component.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/pool-search-result/pool-search-result-list-element.component.ts @@ -1,21 +1,26 @@ import { Component, Inject, OnDestroy, OnInit } from '@angular/core'; -import { Observable } from 'rxjs'; +import { BehaviorSubject, Observable } from 'rxjs'; import { ViewMode } from '../../../../core/shared/view-mode.model'; import { RemoteData } from '../../../../core/data/remote-data'; import { WorkflowItem } from '../../../../core/submission/models/workflowitem.model'; import { PoolTask } from '../../../../core/tasks/models/pool-task-object.model'; -import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; +import { + MyDspaceItemStatusType +} from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type'; import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator'; import { PoolTaskSearchResult } from '../../../object-collection/shared/pool-task-search-result.model'; -import { SearchResultListElementComponent } from '../../search-result-list-element/search-result-list-element.component'; +import { + SearchResultListElementComponent +} from '../../search-result-list-element/search-result-list-element.component'; import { TruncatableService } from '../../../truncatable/truncatable.service'; import { followLink } from '../../../utils/follow-link-config.model'; import { LinkService } from '../../../../core/cache/builders/link.service'; import { DSONameService } from '../../../../core/breadcrumbs/dso-name.service'; import { APP_CONFIG, AppConfig } from '../../../../../config/app-config.interface'; import { ObjectCacheService } from '../../../../core/cache/object-cache.service'; +import { getFirstCompletedRemoteData } from '../../../../core/shared/operators'; /** * This component renders pool task object for the search result in the list view. @@ -42,7 +47,7 @@ export class PoolSearchResultListElementComponent extends SearchResultListElemen /** * The workflowitem object that belonging to the result object */ - public workflowitemRD$: Observable>; + public workflowitem$: BehaviorSubject = new BehaviorSubject(null); /** * The index of this list element @@ -72,12 +77,19 @@ export class PoolSearchResultListElementComponent extends SearchResultListElemen this.linkService.resolveLinks(this.dso, followLink('workflowitem', {}, followLink('item'), followLink('submitter') ), followLink('action')); - this.workflowitemRD$ = this.dso.workflowitem as Observable>; + (this.dso.workflowitem as Observable>).pipe( + getFirstCompletedRemoteData() + ).subscribe((wfiRD: RemoteData) => { + if (wfiRD.hasSucceeded) { + this.workflowitem$.next(wfiRD.payload); + } + }); this.showThumbnails = this.appConfig.browseBy.showThumbnails; } ngOnDestroy() { // This ensures the object is removed from cache, when action is performed on task + // this.wfiService.invalidateByHref(this.dso._links.workflowitem.href); this.objectCache.remove(this.dso._links.workflowitem.href); } }