-
-
-
+
+
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);
}
}