[CSTPER-3620] Workflow Actions refresh entire MyDSpace page instead of just WorkflowItem

Merge cache part 2
This commit is contained in:
Alessandro Martelli
2021-02-09 14:42:38 +01:00
parent 807d4f5fc7
commit 5f6ad03f6f
9 changed files with 41 additions and 26 deletions

View File

@@ -119,7 +119,11 @@ export class ClaimedTaskDataService extends TasksService<ClaimedTask> {
options.searchParams = [ options.searchParams = [
new RequestParam('uuid', uuid) new RequestParam('uuid', uuid)
]; ];
return this.searchTask('findByItem', options, followLink('workflowitem')) return this.searchTask('findByItem', options, followLink('workflowitem',
null,
true,
false,
true))
.pipe(getFirstSucceededRemoteData()); .pipe(getFirstSucceededRemoteData());
} }

View File

@@ -71,7 +71,11 @@ export class PoolTaskDataService extends TasksService<PoolTask> {
options.searchParams = [ options.searchParams = [
new RequestParam('uuid', uuid) new RequestParam('uuid', uuid)
]; ];
return this.searchTask('findByItem', options, followLink('workflowitem')) return this.searchTask('findByItem', options, followLink('workflowitem',
null,
true,
false,
true))
.pipe(getFirstSucceededRemoteData()); .pipe(getFirstSucceededRemoteData());
} }

View File

@@ -131,14 +131,19 @@ export abstract class TasksService<T extends CacheableObject> extends DataServic
* links to follow * links to follow
*/ */
public searchTask(searchMethod: string, options: FindListOptions = {}, ...linksToFollow: FollowLinkConfig<T>[]): Observable<RemoteData<T>> { public searchTask(searchMethod: string, options: FindListOptions = {}, ...linksToFollow: FollowLinkConfig<T>[]): Observable<RemoteData<T>> {
const correlationId = Math.floor(Math.random() * 1000);
const hrefObs = this.getSearchByHref(searchMethod, options, ...linksToFollow); const hrefObs = this.getSearchByHref(searchMethod, options, ...linksToFollow);
return hrefObs.pipe( return hrefObs.pipe(
tap(href => console.log('CorrelationId: ' + correlationId, 'SearchTaskHref', href)),
find((href: string) => hasValue(href)), find((href: string) => hasValue(href)),
switchMap((href) => this.findByHref(href).pipe( switchMap((href) => this.findByHref(href, false, true).pipe(
getFirstSucceededRemoteData(), getFirstSucceededRemoteData(),
tap(() => { tap(() => {
this.requestService.setStaleByHrefSubstring(searchMethod); this.requestService.setStaleByHrefSubstring(searchMethod);
}))), }))),
tap((response) => {
console.log('CorrelationId: ' + correlationId, 'SearchTaskResponse', response.payload);
})
); );
} }
} }

View File

@@ -1,4 +1,4 @@
import {Component, Injector, Input, OnDestroy, OnInit} from '@angular/core'; import { Component, Injector, Input, OnInit } from '@angular/core';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
@@ -26,7 +26,7 @@ import { WORKFLOW_TASK_OPTION_RETURN_TO_POOL } from './return-to-pool/claimed-ta
styleUrls: ['./claimed-task-actions.component.scss'], styleUrls: ['./claimed-task-actions.component.scss'],
templateUrl: './claimed-task-actions.component.html', templateUrl: './claimed-task-actions.component.html',
}) })
export class ClaimedTaskActionsComponent extends MyDSpaceActionsComponent<ClaimedTask, ClaimedTaskDataService> implements OnInit, OnDestroy { export class ClaimedTaskActionsComponent extends MyDSpaceActionsComponent<ClaimedTask, ClaimedTaskDataService> implements OnInit {
/** /**
* The ClaimedTask object * The ClaimedTask object
@@ -100,8 +100,4 @@ export class ClaimedTaskActionsComponent extends MyDSpaceActionsComponent<Claime
this.actionRD$ = object.action; this.actionRD$ = object.action;
} }
ngOnDestroy() {
console.log('Destroy of ClaimedTaskActionComponent', this.object);
}
} }

View File

@@ -11,7 +11,6 @@ import { RemoteData } from '../../../../core/data/remote-data';
import { DSpaceObject } from '../../../../core/shared/dspace-object.model'; import { DSpaceObject } from '../../../../core/shared/dspace-object.model';
import { PoolTaskDataService } from '../../../../core/tasks/pool-task-data.service'; import { PoolTaskDataService } from '../../../../core/tasks/pool-task-data.service';
import { take } from 'rxjs/operators'; import { take } from 'rxjs/operators';
import { tap } from 'rxjs/internal/operators/tap';
export const WORKFLOW_TASK_OPTION_RETURN_TO_POOL = 'return_to_pool'; export const WORKFLOW_TASK_OPTION_RETURN_TO_POOL = 'return_to_pool';
@@ -41,9 +40,7 @@ export class ClaimedTaskActionsReturnToPoolComponent extends ClaimedTaskActionsA
} }
reloadObjectExecution(): Observable<RemoteData<DSpaceObject> | DSpaceObject> { reloadObjectExecution(): Observable<RemoteData<DSpaceObject> | DSpaceObject> {
return this.poolTaskService.findByItem(this.itemUuid).pipe(take(1), tap((value) => { return this.poolTaskService.findByItem(this.itemUuid).pipe(take(1));
console.log('The new PoolTask (found by item) is:', value);
}));
} }
actionExecution(): Observable<any> { actionExecution(): Observable<any> {

View File

@@ -53,7 +53,6 @@ export abstract class MyDSpaceReloadableActionsComponent<T extends DSpaceObject,
ngOnInit() { ngOnInit() {
this.initReloadAnchor(); this.initReloadAnchor();
this.initObjects(this.object); this.initObjects(this.object);
console.log('OnInit ReloadableAction', this.object, this);
} }
/** /**
@@ -72,7 +71,6 @@ export abstract class MyDSpaceReloadableActionsComponent<T extends DSpaceObject,
(reloadedObject) => { (reloadedObject) => {
this.processing$.next(false); this.processing$.next(false);
this.handleReloadableActionResponse(res.hasSucceeded, reloadedObject); this.handleReloadableActionResponse(res.hasSucceeded, reloadedObject);
return reloadedObject;
}) })
); );
} else { } else {

View File

@@ -19,7 +19,6 @@ import { Item } from '../../../core/shared/item.model';
import { DSpaceObject } from '../../../core/shared/dspace-object.model'; import { DSpaceObject } from '../../../core/shared/dspace-object.model';
import { MyDSpaceReloadableActionsComponent } from '../mydspace-reloadable-actions'; import { MyDSpaceReloadableActionsComponent } from '../mydspace-reloadable-actions';
import { ProcessTaskResponse } from '../../../core/tasks/models/process-task-response'; import { ProcessTaskResponse } from '../../../core/tasks/models/process-task-response';
import { tap } from 'rxjs/internal/operators/tap';
/** /**
* This component represents mydspace actions related to PoolTask object. * This component represents mydspace actions related to PoolTask object.
@@ -96,9 +95,7 @@ export class PoolTaskActionsComponent extends MyDSpaceReloadableActionsComponent
} }
reloadObjectExecution(): Observable<RemoteData<DSpaceObject> | DSpaceObject> { reloadObjectExecution(): Observable<RemoteData<DSpaceObject> | DSpaceObject> {
return this.claimedTaskService.findByItem(this.itemUuid).pipe(take(1), tap((value) => { return this.claimedTaskService.findByItem(this.itemUuid).pipe(take(1));
console.log('The new ClaimTask (found by item) is:', value);
}));
} }
/** /**
@@ -116,7 +113,6 @@ export class PoolTaskActionsComponent extends MyDSpaceReloadableActionsComponent
ngOnDestroy() { ngOnDestroy() {
this.subs.forEach((sub) => sub.unsubscribe()); this.subs.forEach((sub) => sub.unsubscribe());
console.log('Destroy of PoolTaskActionsComponent', this.object);
} }
} }

View File

@@ -51,9 +51,17 @@ export class ClaimedApprovedSearchResultListElementComponent extends SearchResul
*/ */
ngOnInit() { ngOnInit() {
super.ngOnInit(); super.ngOnInit();
this.linkService.resolveLinks(this.dso, followLink('workflowitem', null, true, this.linkService.resolveLinks(this.dso,
followLink('item'), followLink('submitter') followLink('workflowitem',
), followLink('action')); null,
true,
false,
true,
followLink('item'),
followLink('submitter')
),
followLink('action')
);
this.workflowitemRD$ = this.dso.workflowitem as Observable<RemoteData<WorkflowItem>>; this.workflowitemRD$ = this.dso.workflowitem as Observable<RemoteData<WorkflowItem>>;
} }

View File

@@ -52,9 +52,16 @@ export class ClaimedDeclinedSearchResultListElementComponent extends SearchResul
*/ */
ngOnInit() { ngOnInit() {
super.ngOnInit(); super.ngOnInit();
this.linkService.resolveLinks(this.dso, followLink('workflowitem', null, true, this.linkService.resolveLinks(this.dso,
followLink('item'), followLink('submitter') followLink('workflowitem',
), followLink('action')); null,
true,
false,
true,
followLink('item'),
followLink('submitter')
),
followLink('action'));
this.workflowitemRD$ = this.dso.workflowitem as Observable<RemoteData<WorkflowItem>>; this.workflowitemRD$ = this.dso.workflowitem as Observable<RemoteData<WorkflowItem>>;
} }