mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
[CST-6876] Fix issue with invalid request done when the claimed/pool task changed its status due to a performed action
This commit is contained in:
@@ -1,9 +1,18 @@
|
||||
<ng-container *ngVar="(workflowitemRD$ | async)?.payload as workflowitem">
|
||||
<ds-themed-item-list-preview *ngIf="workflowitem"
|
||||
[item]="(workflowitem?.item | async)?.payload"
|
||||
<ds-themed-item-list-preview *ngIf="workflowitem$.value"
|
||||
[item]="(workflowitem$.value?.item | async)?.payload"
|
||||
[object]="object"
|
||||
[showSubmitter]="showSubmitter"
|
||||
[status]="status"></ds-themed-item-list-preview>
|
||||
<ds-claimed-task-actions *ngIf="workflowitem" [object]="dso" (processCompleted)="reloadedObject.emit($event.reloadedObject)"></ds-claimed-task-actions>
|
||||
</ng-container>
|
||||
|
||||
<div class="row">
|
||||
<div [ngClass]="showThumbnails ? 'offset-3 offset-md-2 pl-3' : ''">
|
||||
<ds-claimed-task-actions *ngIf="workflowitem$.value"
|
||||
[object]="dso"
|
||||
(processCompleted)="reloadedObject.emit($event.reloadedObject)"></ds-claimed-task-actions>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -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) => {
|
||||
it('should init workflowitem properly', fakeAsync(() => {
|
||||
flush();
|
||||
expect(linkService.resolveLinks).toHaveBeenCalledWith(
|
||||
component.dso,
|
||||
jasmine.objectContaining({ name: 'workflowitem' }),
|
||||
jasmine.objectContaining({ name: 'action' })
|
||||
);
|
||||
expect(workflowitemRD.payload).toEqual(workflowitem);
|
||||
done();
|
||||
});
|
||||
});
|
||||
expect(component.workflowitem$.value).toEqual(workflowitem);
|
||||
}));
|
||||
|
||||
it('should have properly status', () => {
|
||||
expect(component.status).toEqual(MyDspaceItemStatusType.VALIDATION);
|
||||
|
@@ -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<RemoteData<WorkflowItem>>;
|
||||
public workflowitem$: BehaviorSubject<WorkflowItem> = new BehaviorSubject<WorkflowItem>(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<RemoteData<WorkflowItem>>;
|
||||
(this.dso.workflowitem as Observable<RemoteData<WorkflowItem>>).pipe(
|
||||
getFirstCompletedRemoteData()
|
||||
).subscribe((wfiRD: RemoteData<WorkflowItem>) => {
|
||||
if (wfiRD.hasSucceeded) {
|
||||
this.workflowitem$.next(wfiRD.payload);
|
||||
}
|
||||
});
|
||||
this.showThumbnails = this.appConfig.browseBy.showThumbnails;
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
|
@@ -1,13 +1,12 @@
|
||||
<ng-container *ngVar="(workflowitemRD$ | async)?.payload as workflowitem">
|
||||
<ds-themed-item-list-preview *ngIf="workflowitem"
|
||||
[item]="(workflowitem?.item | async)?.payload"
|
||||
<ds-themed-item-list-preview *ngIf="workflowitem$.value"
|
||||
[item]="(workflowitem$.value?.item | async)?.payload"
|
||||
[object]="object"
|
||||
[showSubmitter]="showSubmitter"
|
||||
[status]="status"></ds-themed-item-list-preview>
|
||||
<div class="row">
|
||||
<div class="row">
|
||||
<div [ngClass]="showThumbnails ? 'offset-3 offset-md-2 pl-3' : ''">
|
||||
<ds-pool-task-actions id="actions" *ngIf="workflowitem" [object]="dso"
|
||||
<ds-pool-task-actions id="actions" *ngIf="workflowitem$.value"
|
||||
[object]="dso"
|
||||
(processCompleted)="this.reloadedObject.emit($event.reloadedObject)"></ds-pool-task-actions>
|
||||
</div>
|
||||
</div>
|
||||
</ng-container>
|
||||
</div>
|
||||
|
@@ -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) => {
|
||||
it('should init workflowitem properly', fakeAsync(() => {
|
||||
flush();
|
||||
expect(linkService.resolveLinks).toHaveBeenCalledWith(
|
||||
component.dso,
|
||||
jasmine.objectContaining({ name: 'workflowitem' }),
|
||||
jasmine.objectContaining({ name: 'action' })
|
||||
);
|
||||
expect(workflowitemRD.payload).toEqual(workflowitem);
|
||||
done();
|
||||
});
|
||||
});
|
||||
expect(component.workflowitem$.value).toEqual(workflowitem);
|
||||
}));
|
||||
|
||||
it('should have properly status', () => {
|
||||
expect(component.status).toEqual(MyDspaceItemStatusType.WAITING_CONTROLLER);
|
||||
|
@@ -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<RemoteData<WorkflowItem>>;
|
||||
public workflowitem$: BehaviorSubject<WorkflowItem> = new BehaviorSubject<WorkflowItem>(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<RemoteData<WorkflowItem>>;
|
||||
(this.dso.workflowitem as Observable<RemoteData<WorkflowItem>>).pipe(
|
||||
getFirstCompletedRemoteData()
|
||||
).subscribe((wfiRD: RemoteData<WorkflowItem>) => {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user