mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
[CST-6876] Refactoring workflow actions components in order to pass item and workflowitem objects down from paren search element component to children
This commit is contained in:
@@ -10,11 +10,11 @@ import { RequestService } from '../../../../core/data/request.service';
|
||||
import { Observable } from 'rxjs';
|
||||
import { RemoteData } from '../../../../core/data/remote-data';
|
||||
import { WorkflowItem } from '../../../../core/submission/models/workflowitem.model';
|
||||
import { switchMap, take } from 'rxjs/operators';
|
||||
import { take } from 'rxjs/operators';
|
||||
import { CLAIMED_TASK } from '../../../../core/tasks/models/claimed-task-object.resource-type';
|
||||
import { getFirstSucceededRemoteDataPayload } from '../../../../core/shared/operators';
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { MyDSpaceReloadableActionsComponent } from '../../mydspace-reloadable-actions';
|
||||
import { isEmpty } from '../../../empty.util';
|
||||
|
||||
/**
|
||||
* Abstract component for rendering a claimed task's action
|
||||
@@ -36,6 +36,11 @@ export abstract class ClaimedTaskActionsAbstractComponent extends MyDSpaceReload
|
||||
|
||||
object: ClaimedTask;
|
||||
|
||||
/**
|
||||
* The item object that belonging to the ClaimedTask object
|
||||
*/
|
||||
item: Item;
|
||||
|
||||
/**
|
||||
* Anchor used to reload the pool task.
|
||||
*/
|
||||
@@ -43,6 +48,11 @@ export abstract class ClaimedTaskActionsAbstractComponent extends MyDSpaceReload
|
||||
|
||||
subs = [];
|
||||
|
||||
/**
|
||||
* The workflowitem object that belonging to the ClaimedTask object
|
||||
*/
|
||||
workflowitem: WorkflowItem;
|
||||
|
||||
protected constructor(protected injector: Injector,
|
||||
protected router: Router,
|
||||
protected notificationsService: NotificationsService,
|
||||
@@ -85,16 +95,10 @@ export abstract class ClaimedTaskActionsAbstractComponent extends MyDSpaceReload
|
||||
* Retrieve the itemUuid.
|
||||
*/
|
||||
initReloadAnchor() {
|
||||
if (!(this.object as any).workflowitem) {
|
||||
if (isEmpty(this.item)) {
|
||||
return;
|
||||
}
|
||||
this.subs.push(this.object.workflowitem.pipe(
|
||||
getFirstSucceededRemoteDataPayload(),
|
||||
switchMap((workflowItem: WorkflowItem) => workflowItem.item.pipe(getFirstSucceededRemoteDataPayload())
|
||||
))
|
||||
.subscribe((item: Item) => {
|
||||
this.itemUuid = item.uuid;
|
||||
}));
|
||||
this.itemUuid = this.item.uuid;
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
|
@@ -1,16 +1,23 @@
|
||||
<ng-container *ngVar="(actionRD$ | async)?.payload as workflowAction">
|
||||
<div class="mt-1 mb-3 space-children-mr">
|
||||
<ds-claimed-task-actions-loader *ngFor="let option of workflowAction?.options" [option]="option" [object]="object"
|
||||
(processCompleted)="this.processCompleted.emit($event)">
|
||||
<ds-claimed-task-actions-loader *ngFor="let option of workflowAction?.options"
|
||||
[item]="item"
|
||||
[option]="option"
|
||||
[object]="object"
|
||||
[workflowitem]="workflowitem"
|
||||
(processCompleted)="this.processCompleted.emit($event)">
|
||||
</ds-claimed-task-actions-loader>
|
||||
|
||||
<button class="btn btn-primary workflow-view" ngbTooltip="{{'submission.workflow.generic.view-help' | translate}}"
|
||||
[routerLink]="[getWorkflowItemViewRoute((workflowitem$ | async))]">
|
||||
[routerLink]="[getWorkflowItemViewRoute(workflowitem)]">
|
||||
<i class="fa fa-info-circle"></i> {{"submission.workflow.generic.view" | translate}}
|
||||
</button>
|
||||
|
||||
<ds-claimed-task-actions-loader [option]="returnToPoolOption" [object]="object"
|
||||
(processCompleted)="this.processCompleted.emit($event)">
|
||||
<ds-claimed-task-actions-loader [item]="item"
|
||||
[option]="returnToPoolOption"
|
||||
[object]="object"
|
||||
[workflowitem]="workflowitem"
|
||||
(processCompleted)="this.processCompleted.emit($event)">
|
||||
</ds-claimed-task-actions-loader>
|
||||
</div>
|
||||
</ng-container>
|
||||
|
@@ -3,7 +3,6 @@ import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { cold } from 'jasmine-marbles';
|
||||
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
|
||||
|
||||
import { TranslateLoaderMock } from '../../mocks/translate-loader.mock';
|
||||
@@ -123,7 +122,9 @@ describe('ClaimedTaskActionsComponent', () => {
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ClaimedTaskActionsComponent);
|
||||
component = fixture.componentInstance;
|
||||
component.item = item;
|
||||
component.object = mockObject;
|
||||
component.workflowitem = workflowitem;
|
||||
notificationsServiceStub = TestBed.inject(NotificationsService as any);
|
||||
router = TestBed.inject(Router as any);
|
||||
fixture.detectChanges();
|
||||
@@ -133,11 +134,11 @@ describe('ClaimedTaskActionsComponent', () => {
|
||||
component.object = null;
|
||||
component.initObjects(mockObject);
|
||||
|
||||
expect(component.item).toEqual(item);
|
||||
|
||||
expect(component.object).toEqual(mockObject);
|
||||
|
||||
expect(component.workflowitem$).toBeObservable(cold('(b|)', {
|
||||
b: rdWorkflowitem.payload
|
||||
}));
|
||||
expect(component.workflowitem).toEqual(workflowitem);
|
||||
});
|
||||
|
||||
it('should reload page on process completed', waitForAsync(() => {
|
||||
|
@@ -2,12 +2,10 @@ import { Component, Injector, Input, OnInit } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
import { filter, map, take } from 'rxjs/operators';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
|
||||
import { ClaimedTaskDataService } from '../../../core/tasks/claimed-task-data.service';
|
||||
import { ClaimedTask } from '../../../core/tasks/models/claimed-task-object.model';
|
||||
import { isNotUndefined } from '../../empty.util';
|
||||
import { WorkflowItem } from '../../../core/submission/models/workflowitem.model';
|
||||
import { RemoteData } from '../../../core/data/remote-data';
|
||||
import { MyDSpaceActionsComponent } from '../mydspace-actions';
|
||||
@@ -18,6 +16,7 @@ import { WorkflowAction } from '../../../core/tasks/models/workflow-action-objec
|
||||
import { WorkflowActionDataService } from '../../../core/data/workflow-action-data.service';
|
||||
import { WORKFLOW_TASK_OPTION_RETURN_TO_POOL } from './return-to-pool/claimed-task-actions-return-to-pool.component';
|
||||
import { getWorkflowItemViewRoute } from '../../../workflowitems-edit-page/workflowitems-edit-page-routing-paths';
|
||||
import { Item } from '../../../core/shared/item.model';
|
||||
|
||||
/**
|
||||
* This component represents actions related to ClaimedTask object.
|
||||
@@ -34,10 +33,15 @@ export class ClaimedTaskActionsComponent extends MyDSpaceActionsComponent<Claime
|
||||
*/
|
||||
@Input() object: ClaimedTask;
|
||||
|
||||
/**
|
||||
* The item object that belonging to the ClaimedTask object
|
||||
*/
|
||||
@Input() item: Item;
|
||||
|
||||
/**
|
||||
* The workflowitem object that belonging to the ClaimedTask object
|
||||
*/
|
||||
public workflowitem$: Observable<WorkflowItem>;
|
||||
@Input() workflowitem: WorkflowItem;
|
||||
|
||||
/**
|
||||
* The workflow action available for this task
|
||||
@@ -87,11 +91,6 @@ export class ClaimedTaskActionsComponent extends MyDSpaceActionsComponent<Claime
|
||||
*/
|
||||
initObjects(object: ClaimedTask) {
|
||||
this.object = object;
|
||||
|
||||
this.workflowitem$ = (this.object.workflowitem as Observable<RemoteData<WorkflowItem>>).pipe(
|
||||
filter((rd: RemoteData<WorkflowItem>) => ((!rd.isRequestPending) && isNotUndefined(rd.payload))),
|
||||
map((rd: RemoteData<WorkflowItem>) => rd.payload),
|
||||
take(1));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import { ClaimedTaskActionsLoaderComponent } from './claimed-task-actions-loader.component';
|
||||
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
||||
import { ChangeDetectionStrategy, Injector, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { ClaimedTaskActionsDirective } from './claimed-task-actions.directive';
|
||||
import { ClaimedTask } from '../../../../core/tasks/models/claimed-task-object.model';
|
||||
@@ -15,6 +15,8 @@ import { RequestService } from '../../../../core/data/request.service';
|
||||
import { PoolTaskDataService } from '../../../../core/tasks/pool-task-data.service';
|
||||
import { getMockSearchService } from '../../../mocks/search-service.mock';
|
||||
import { getMockRequestService } from '../../../mocks/request.service.mock';
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { WorkflowItem } from '../../../../core/submission/models/workflowitem.model';
|
||||
|
||||
const searchService = getMockSearchService();
|
||||
|
||||
@@ -27,6 +29,37 @@ describe('ClaimedTaskActionsLoaderComponent', () => {
|
||||
const option = 'test_option';
|
||||
const object = Object.assign(new ClaimedTask(), { id: 'claimed-task-1' });
|
||||
|
||||
const item = Object.assign(new Item(), {
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
{
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
}
|
||||
],
|
||||
'dc.type': [
|
||||
{
|
||||
language: null,
|
||||
value: 'Article'
|
||||
}
|
||||
],
|
||||
'dc.contributor.author': [
|
||||
{
|
||||
language: 'en_US',
|
||||
value: 'Smith, Donald'
|
||||
}
|
||||
],
|
||||
'dc.date.issued': [
|
||||
{
|
||||
language: null,
|
||||
value: '2015-06-26'
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
const workflowitem = Object.assign(new WorkflowItem(), { id: '333' });
|
||||
|
||||
beforeEach(waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [TranslateModule.forRoot()],
|
||||
@@ -52,8 +85,10 @@ describe('ClaimedTaskActionsLoaderComponent', () => {
|
||||
beforeEach(waitForAsync(() => {
|
||||
fixture = TestBed.createComponent(ClaimedTaskActionsLoaderComponent);
|
||||
comp = fixture.componentInstance;
|
||||
comp.item = item;
|
||||
comp.object = object;
|
||||
comp.option = option;
|
||||
comp.workflowitem = workflowitem;
|
||||
spyOn(comp, 'getComponentByWorkflowTaskOption').and.returnValue(ClaimedTaskActionsEditMetadataComponent);
|
||||
|
||||
fixture.detectChanges();
|
||||
|
@@ -15,6 +15,8 @@ import { ClaimedTaskActionsAbstractComponent } from '../abstract/claimed-task-ac
|
||||
import { hasValue } from '../../../empty.util';
|
||||
import { Subscription } from 'rxjs';
|
||||
import { MyDSpaceActionsResult } from '../../mydspace-actions';
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { WorkflowItem } from '../../../../core/submission/models/workflowitem.model';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-claimed-task-actions-loader',
|
||||
@@ -25,6 +27,11 @@ import { MyDSpaceActionsResult } from '../../mydspace-actions';
|
||||
* Passes on the ClaimedTask to the component and subscribes to the processCompleted output
|
||||
*/
|
||||
export class ClaimedTaskActionsLoaderComponent implements OnInit, OnDestroy {
|
||||
/**
|
||||
* The item object that belonging to the ClaimedTask object
|
||||
*/
|
||||
@Input() item: Item;
|
||||
|
||||
/**
|
||||
* The ClaimedTask object
|
||||
*/
|
||||
@@ -36,6 +43,11 @@ export class ClaimedTaskActionsLoaderComponent implements OnInit, OnDestroy {
|
||||
*/
|
||||
@Input() option: string;
|
||||
|
||||
/**
|
||||
* The workflowitem object that belonging to the ClaimedTask object
|
||||
*/
|
||||
@Input() workflowitem: WorkflowItem;
|
||||
|
||||
/**
|
||||
* Emits the success or failure of a processed action
|
||||
*/
|
||||
@@ -69,7 +81,9 @@ export class ClaimedTaskActionsLoaderComponent implements OnInit, OnDestroy {
|
||||
|
||||
const componentRef = viewContainerRef.createComponent(componentFactory);
|
||||
const componentInstance = (componentRef.instance as ClaimedTaskActionsAbstractComponent);
|
||||
componentInstance.item = this.item;
|
||||
componentInstance.object = this.object;
|
||||
componentInstance.workflowitem = this.workflowitem;
|
||||
if (hasValue(componentInstance.processCompleted)) {
|
||||
this.subs.push(componentInstance.processCompleted.subscribe((result) => this.processCompleted.emit(result)));
|
||||
}
|
||||
|
@@ -12,10 +12,7 @@ import { RouterStub } from '../testing/router.stub';
|
||||
import { getMockSearchService } from '../mocks/search-service.mock';
|
||||
import { getMockRequestService } from '../mocks/request.service.mock';
|
||||
import { Item } from '../../core/shared/item.model';
|
||||
import {
|
||||
createFailedRemoteDataObject,
|
||||
createSuccessfulRemoteDataObject
|
||||
} from '../remote-data.utils';
|
||||
import { createFailedRemoteDataObject, createSuccessfulRemoteDataObject } from '../remote-data.utils';
|
||||
import { WorkflowItem } from '../../core/submission/models/workflowitem.model';
|
||||
import { TranslateLoaderMock } from '../mocks/translate-loader.mock';
|
||||
import { NotificationsService } from '../notifications/notifications.service';
|
||||
@@ -103,7 +100,9 @@ describe('MyDSpaceReloadableActionsComponent', () => {
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(PoolTaskActionsComponent);
|
||||
component = fixture.componentInstance;
|
||||
component.item = item;
|
||||
component.object = mockObject;
|
||||
component.workflowitem = workflowitem;
|
||||
notificationsServiceStub = TestBed.get(NotificationsService);
|
||||
router = TestBed.get(Router);
|
||||
fixture.detectChanges();
|
||||
|
@@ -8,6 +8,6 @@
|
||||
</button>
|
||||
<button class="btn btn-primary workflow-view ml-1 mt-1 mb-3" data-test="view-btn"
|
||||
ngbTooltip="{{'submission.workflow.generic.view-help' | translate}}"
|
||||
[routerLink]="[getWorkflowItemViewRoute((workflowitem$ | async))]">
|
||||
[routerLink]="[getWorkflowItemViewRoute(workflowitem)]">
|
||||
<i class="fa fa-info-circle"></i> {{"submission.workflow.generic.view" | translate}}
|
||||
</button>
|
||||
|
@@ -4,7 +4,6 @@ import { Router } from '@angular/router';
|
||||
import { By } from '@angular/platform-browser';
|
||||
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { cold } from 'jasmine-marbles';
|
||||
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
|
||||
|
||||
import { TranslateLoaderMock } from '../../mocks/translate-loader.mock';
|
||||
@@ -105,7 +104,9 @@ describe('PoolTaskActionsComponent', () => {
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(PoolTaskActionsComponent);
|
||||
component = fixture.componentInstance;
|
||||
component.item = item;
|
||||
component.object = mockObject;
|
||||
component.workflowitem = workflowitem;
|
||||
notificationsServiceStub = TestBed.inject(NotificationsService as any);
|
||||
router = TestBed.inject(Router as any);
|
||||
fixture.detectChanges();
|
||||
@@ -120,11 +121,11 @@ describe('PoolTaskActionsComponent', () => {
|
||||
component.object = null;
|
||||
component.initObjects(mockObject);
|
||||
|
||||
expect(component.item).toEqual(item);
|
||||
|
||||
expect(component.object).toEqual(mockObject);
|
||||
|
||||
expect(component.workflowitem$).toBeObservable(cold('(b|)', {
|
||||
b: rdWorkflowitem.payload
|
||||
}));
|
||||
expect(component.workflowitem).toEqual(workflowitem);
|
||||
});
|
||||
|
||||
it('should display claim task button', () => {
|
||||
|
@@ -2,19 +2,17 @@ import { Component, Injector, Input, OnDestroy } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
import { filter, map, switchMap, take } from 'rxjs/operators';
|
||||
import { switchMap, take } from 'rxjs/operators';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
|
||||
import { WorkflowItem } from '../../../core/submission/models/workflowitem.model';
|
||||
import { RemoteData } from '../../../core/data/remote-data';
|
||||
import { PoolTask } from '../../../core/tasks/models/pool-task-object.model';
|
||||
import { PoolTaskDataService } from '../../../core/tasks/pool-task-data.service';
|
||||
import { isNotUndefined } from '../../empty.util';
|
||||
import { NotificationsService } from '../../notifications/notifications.service';
|
||||
import { RequestService } from '../../../core/data/request.service';
|
||||
import { SearchService } from '../../../core/shared/search/search.service';
|
||||
import { ClaimedTaskDataService } from '../../../core/tasks/claimed-task-data.service';
|
||||
import { getFirstSucceededRemoteDataPayload } from '../../../core/shared/operators';
|
||||
import { Item } from '../../../core/shared/item.model';
|
||||
import { DSpaceObject } from '../../../core/shared/dspace-object.model';
|
||||
import { MyDSpaceReloadableActionsComponent } from '../mydspace-reloadable-actions';
|
||||
@@ -36,10 +34,15 @@ export class PoolTaskActionsComponent extends MyDSpaceReloadableActionsComponent
|
||||
*/
|
||||
@Input() object: PoolTask;
|
||||
|
||||
/**
|
||||
* The item object that belonging to the PoolTask object
|
||||
*/
|
||||
@Input() item: Item;
|
||||
|
||||
/**
|
||||
* The workflowitem object that belonging to the PoolTask object
|
||||
*/
|
||||
public workflowitem$: Observable<WorkflowItem>;
|
||||
@Input() workflowitem: WorkflowItem;
|
||||
|
||||
/**
|
||||
* Anchor used to reload the pool task.
|
||||
@@ -83,10 +86,6 @@ export class PoolTaskActionsComponent extends MyDSpaceReloadableActionsComponent
|
||||
*/
|
||||
initObjects(object: PoolTask) {
|
||||
this.object = object;
|
||||
this.workflowitem$ = (this.object.workflowitem as Observable<RemoteData<WorkflowItem>>).pipe(
|
||||
filter((rd: RemoteData<WorkflowItem>) => ((!rd.isRequestPending) && isNotUndefined(rd.payload))),
|
||||
map((rd: RemoteData<WorkflowItem>) => rd.payload),
|
||||
take(1));
|
||||
}
|
||||
|
||||
actionExecution(): Observable<ProcessTaskResponse> {
|
||||
@@ -104,13 +103,7 @@ export class PoolTaskActionsComponent extends MyDSpaceReloadableActionsComponent
|
||||
* Retrieve the itemUuid.
|
||||
*/
|
||||
initReloadAnchor() {
|
||||
(this.object as any).workflowitem.pipe(
|
||||
getFirstSucceededRemoteDataPayload(),
|
||||
switchMap((workflowItem: WorkflowItem) => workflowItem.item.pipe(getFirstSucceededRemoteDataPayload())
|
||||
))
|
||||
.subscribe((item: Item) => {
|
||||
this.itemUuid = item.uuid;
|
||||
});
|
||||
this.itemUuid = this.item.uuid;
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
|
@@ -1,10 +1,12 @@
|
||||
<ng-container *ngVar="(workflowitemRD$ | async)?.payload as workflowitem">
|
||||
<ds-item-detail-preview *ngIf="workflowitem"
|
||||
[item]="(workflowitem.item | async)?.payload"
|
||||
<ng-container *ngIf="(workflowitem$ | async) && (item$ | async)">
|
||||
<ds-item-detail-preview [item]="item$?.value"
|
||||
[object]="object"
|
||||
[showSubmitter]="showSubmitter"
|
||||
[status]="status">
|
||||
</ds-item-detail-preview>
|
||||
|
||||
<ds-claimed-task-actions *ngIf="workflowitem" [object]="dso" (processCompleted)="reloadedObject.emit($event.reloadedObject)"></ds-claimed-task-actions>
|
||||
<ds-claimed-task-actions [item]="item$.value"
|
||||
[object]="dso"
|
||||
[workflowitem]="workflowitem$.value"
|
||||
(processCompleted)="reloadedObject.emit($event.reloadedObject)"></ds-claimed-task-actions>
|
||||
</ng-container>
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { ComponentFixture, TestBed, tick, waitForAsync, fakeAsync} 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 { ClaimedTaskSearchResultDetailElementComponent } from './claimed-task-search-result-detail-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';
|
||||
@@ -15,6 +17,7 @@ import { VarDirective } from '../../../utils/var.directive';
|
||||
import { LinkService } from '../../../../core/cache/builders/link.service';
|
||||
import { getMockLinkService } from '../../../mocks/link-service.mock';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { ObjectCacheService } from '../../../../core/cache/object-cache.service';
|
||||
|
||||
let component: ClaimedTaskSearchResultDetailElementComponent;
|
||||
let fixture: ComponentFixture<ClaimedTaskSearchResultDetailElementComponent>;
|
||||
@@ -58,6 +61,9 @@ const workflowitem = Object.assign(new WorkflowItem(), { item: observableOf(rdIt
|
||||
const rdWorkflowitem = createSuccessfulRemoteDataObject(workflowitem);
|
||||
mockResultObject.indexableObject = Object.assign(new ClaimedTask(), { workflowitem: observableOf(rdWorkflowitem) });
|
||||
const linkService = getMockLinkService();
|
||||
const objectCacheServiceMock = jasmine.createSpyObj('ObjectCacheService', {
|
||||
remove: jasmine.createSpy('remove')
|
||||
});
|
||||
|
||||
describe('ClaimedTaskSearchResultDetailElementComponent', () => {
|
||||
beforeEach(waitForAsync(() => {
|
||||
@@ -65,7 +71,8 @@ describe('ClaimedTaskSearchResultDetailElementComponent', () => {
|
||||
imports: [NoopAnimationsModule],
|
||||
declarations: [ClaimedTaskSearchResultDetailElementComponent, VarDirective],
|
||||
providers: [
|
||||
{ provide: LinkService, useValue: linkService }
|
||||
{ provide: LinkService, useValue: linkService },
|
||||
{ provide: ObjectCacheService, useValue: objectCacheServiceMock }
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).overrideComponent(ClaimedTaskSearchResultDetailElementComponent, {
|
||||
@@ -83,18 +90,16 @@ describe('ClaimedTaskSearchResultDetailElementComponent', () => {
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should init workflowitem properly', (done) => {
|
||||
component.workflowitemRD$.subscribe((workflowitemRD) => {
|
||||
// Make sure the necessary links are being resolved
|
||||
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);
|
||||
expect(component.item$.value).toEqual(item);
|
||||
}));
|
||||
|
||||
it('should have properly status', () => {
|
||||
expect(component.status).toEqual(MyDspaceItemStatusType.VALIDATION);
|
||||
|
@@ -1,17 +1,24 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { Component, OnDestroy, OnInit } from '@angular/core';
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
import { BehaviorSubject, EMPTY, Observable } from 'rxjs';
|
||||
import { mergeMap, tap } from 'rxjs/operators';
|
||||
|
||||
import { RemoteData } from '../../../../core/data/remote-data';
|
||||
import { ViewMode } from '../../../../core/shared/view-mode.model';
|
||||
import { WorkflowItem } from '../../../../core/submission/models/workflowitem.model';
|
||||
import { ClaimedTask } from '../../../../core/tasks/models/claimed-task-object.model';
|
||||
import { SearchResultDetailElementComponent } from '../search-result-detail-element.component';
|
||||
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 { ClaimedTaskSearchResult } from '../../../object-collection/shared/claimed-task-search-result.model';
|
||||
import { followLink } from '../../../utils/follow-link-config.model';
|
||||
import { LinkService } from '../../../../core/cache/builders/link.service';
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { getFirstCompletedRemoteData } from '../../../../core/shared/operators';
|
||||
import { isNotEmpty } from '../../../empty.util';
|
||||
import { ObjectCacheService } from '../../../../core/cache/object-cache.service';
|
||||
|
||||
/**
|
||||
* This component renders claimed task object for the search result in the detail view.
|
||||
@@ -23,7 +30,12 @@ import { LinkService } from '../../../../core/cache/builders/link.service';
|
||||
})
|
||||
|
||||
@listableObjectComponent(ClaimedTaskSearchResult, ViewMode.DetailedListElement)
|
||||
export class ClaimedTaskSearchResultDetailElementComponent extends SearchResultDetailElementComponent<ClaimedTaskSearchResult, ClaimedTask> {
|
||||
export class ClaimedTaskSearchResultDetailElementComponent extends SearchResultDetailElementComponent<ClaimedTaskSearchResult, ClaimedTask> implements OnInit, OnDestroy {
|
||||
|
||||
/**
|
||||
* The item object that belonging to the result object
|
||||
*/
|
||||
public item$: BehaviorSubject<Item> = new BehaviorSubject<Item>(null);
|
||||
|
||||
/**
|
||||
* A boolean representing if to show submitter information
|
||||
@@ -38,9 +50,9 @@ export class ClaimedTaskSearchResultDetailElementComponent extends SearchResultD
|
||||
/**
|
||||
* The workflowitem object that belonging to the result object
|
||||
*/
|
||||
public workflowitemRD$: Observable<RemoteData<WorkflowItem>>;
|
||||
public workflowitem$: BehaviorSubject<WorkflowItem> = new BehaviorSubject<WorkflowItem>(null);
|
||||
|
||||
constructor(protected linkService: LinkService) {
|
||||
constructor(protected linkService: LinkService, protected objectCache: ObjectCacheService) {
|
||||
super();
|
||||
}
|
||||
|
||||
@@ -53,7 +65,30 @@ export class ClaimedTaskSearchResultDetailElementComponent extends SearchResultD
|
||||
followLink('item', {}, followLink('bundles')),
|
||||
followLink('submitter')
|
||||
), followLink('action'));
|
||||
this.workflowitemRD$ = this.dso.workflowitem as Observable<RemoteData<WorkflowItem>>;
|
||||
|
||||
(this.dso.workflowitem as Observable<RemoteData<WorkflowItem>>).pipe(
|
||||
getFirstCompletedRemoteData(),
|
||||
mergeMap((wfiRD: RemoteData<WorkflowItem>) => {
|
||||
if (wfiRD.hasSucceeded) {
|
||||
this.workflowitem$.next(wfiRD.payload);
|
||||
return (wfiRD.payload.item as Observable<RemoteData<Item>>).pipe(
|
||||
getFirstCompletedRemoteData()
|
||||
);
|
||||
} else {
|
||||
return EMPTY;
|
||||
}
|
||||
}),
|
||||
tap((itemRD: RemoteData<Item>) => {
|
||||
if (isNotEmpty(itemRD) && itemRD.hasSucceeded) {
|
||||
this.item$.next(itemRD.payload);
|
||||
}
|
||||
})
|
||||
).subscribe();
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
// This ensures the object is removed from cache, when action is performed on task
|
||||
this.objectCache.remove(this.dso._links.workflowitem.href);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,9 +1,12 @@
|
||||
<ng-container *ngVar="(workflowitemRD$ | async)?.payload as workflowitem">
|
||||
<ds-item-detail-preview *ngIf="workflowitem"
|
||||
[item]="(workflowitem?.item | async)?.payload"
|
||||
<ng-container *ngIf="(workflowitem$ | async) && (item$ | async)">
|
||||
<ds-item-detail-preview [item]="item$?.value"
|
||||
[object]="object"
|
||||
[showSubmitter]="showSubmitter"
|
||||
[status]="status"></ds-item-detail-preview>
|
||||
|
||||
<ds-pool-task-actions *ngIf="workflowitem" [object]="dso" (processCompleted)="reloadedObject.emit($event.reloadedObject)"></ds-pool-task-actions>
|
||||
<ds-pool-task-actions [item]="item$.value"
|
||||
[object]="dso"
|
||||
[workflowitem]="workflowitem$.value"
|
||||
(processCompleted)="reloadedObject.emit($event.reloadedObject)"></ds-pool-task-actions>
|
||||
</ng-container>
|
||||
|
||||
|
@@ -1,12 +1,14 @@
|
||||
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { waitForAsync, ComponentFixture, TestBed, fakeAsync, 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';
|
||||
|
||||
import { Item } from '../../../../core/shared/item.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 { WorkflowItem } from '../../../../core/submission/models/workflowitem.model';
|
||||
import { createSuccessfulRemoteDataObject } from '../../../remote-data.utils';
|
||||
import { PoolSearchResultDetailElementComponent } from './pool-search-result-detail-element.component';
|
||||
@@ -15,8 +17,7 @@ import { VarDirective } from '../../../utils/var.directive';
|
||||
import { LinkService } from '../../../../core/cache/builders/link.service';
|
||||
import { getMockLinkService } from '../../../mocks/link-service.mock';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { DSONameService } from '../../../../core/breadcrumbs/dso-name.service';
|
||||
import { DSONameServiceMock } from '../../../mocks/dso-name.service.mock';
|
||||
import { ObjectCacheService } from '../../../../core/cache/object-cache.service';
|
||||
|
||||
let component: PoolSearchResultDetailElementComponent;
|
||||
let fixture: ComponentFixture<PoolSearchResultDetailElementComponent>;
|
||||
@@ -60,6 +61,9 @@ const workflowitem = Object.assign(new WorkflowItem(), { item: observableOf(rdIt
|
||||
const rdWorkflowitem = createSuccessfulRemoteDataObject(workflowitem);
|
||||
mockResultObject.indexableObject = Object.assign(new PoolTask(), { workflowitem: observableOf(rdWorkflowitem) });
|
||||
const linkService = getMockLinkService();
|
||||
const objectCacheServiceMock = jasmine.createSpyObj('ObjectCacheService', {
|
||||
remove: jasmine.createSpy('remove')
|
||||
});
|
||||
|
||||
describe('PoolSearchResultDetailElementComponent', () => {
|
||||
beforeEach(waitForAsync(() => {
|
||||
@@ -70,7 +74,7 @@ describe('PoolSearchResultDetailElementComponent', () => {
|
||||
{ provide: 'objectElementProvider', useValue: (mockResultObject) },
|
||||
{ provide: 'indexElementProvider', useValue: (compIndex) },
|
||||
{ provide: LinkService, useValue: linkService },
|
||||
{ provide: DSONameService, useClass: DSONameServiceMock },
|
||||
{ provide: ObjectCacheService, useValue: objectCacheServiceMock }
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).overrideComponent(PoolSearchResultDetailElementComponent, {
|
||||
@@ -88,17 +92,16 @@ describe('PoolSearchResultDetailElementComponent', () => {
|
||||
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);
|
||||
expect(component.item$.value).toEqual(item);
|
||||
}));
|
||||
|
||||
it('should have properly status', () => {
|
||||
expect(component.status).toEqual(MyDspaceItemStatusType.WAITING_CONTROLLER);
|
||||
|
@@ -1,16 +1,24 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { Component, OnDestroy, OnInit } from '@angular/core';
|
||||
|
||||
import { BehaviorSubject, EMPTY, Observable } from 'rxjs';
|
||||
import { mergeMap, tap } from 'rxjs/operators';
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
import { RemoteData } from '../../../../core/data/remote-data';
|
||||
import { PoolTask } from '../../../../core/tasks/models/pool-task-object.model';
|
||||
import { SearchResultDetailElementComponent } from '../search-result-detail-element.component';
|
||||
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 { ViewMode } from '../../../../core/shared/view-mode.model';
|
||||
import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator';
|
||||
import { PoolTaskSearchResult } from '../../../object-collection/shared/pool-task-search-result.model';
|
||||
import { followLink } from '../../../utils/follow-link-config.model';
|
||||
import { LinkService } from '../../../../core/cache/builders/link.service';
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { getFirstCompletedRemoteData } from '../../../../core/shared/operators';
|
||||
import { isNotEmpty } from '../../../empty.util';
|
||||
import { ObjectCacheService } from '../../../../core/cache/object-cache.service';
|
||||
|
||||
/**
|
||||
* This component renders pool task object for the search result in the detail view.
|
||||
@@ -22,7 +30,12 @@ import { LinkService } from '../../../../core/cache/builders/link.service';
|
||||
})
|
||||
|
||||
@listableObjectComponent(PoolTaskSearchResult, ViewMode.DetailedListElement)
|
||||
export class PoolSearchResultDetailElementComponent extends SearchResultDetailElementComponent<PoolTaskSearchResult, PoolTask> {
|
||||
export class PoolSearchResultDetailElementComponent extends SearchResultDetailElementComponent<PoolTaskSearchResult, PoolTask> implements OnInit, OnDestroy {
|
||||
|
||||
/**
|
||||
* The item object that belonging to the result object
|
||||
*/
|
||||
public item$: BehaviorSubject<Item> = new BehaviorSubject<Item>(null);
|
||||
|
||||
/**
|
||||
* A boolean representing if to show submitter information
|
||||
@@ -37,9 +50,9 @@ export class PoolSearchResultDetailElementComponent extends SearchResultDetailEl
|
||||
/**
|
||||
* The workflowitem object that belonging to the result object
|
||||
*/
|
||||
public workflowitemRD$: Observable<RemoteData<WorkflowItem>>;
|
||||
public workflowitem$: BehaviorSubject<WorkflowItem> = new BehaviorSubject<WorkflowItem>(null);
|
||||
|
||||
constructor(protected linkService: LinkService) {
|
||||
constructor(protected linkService: LinkService, protected objectCache: ObjectCacheService) {
|
||||
super();
|
||||
}
|
||||
|
||||
@@ -52,7 +65,31 @@ export class PoolSearchResultDetailElementComponent extends SearchResultDetailEl
|
||||
followLink('item', {}, followLink('bundles')),
|
||||
followLink('submitter')
|
||||
), followLink('action'));
|
||||
this.workflowitemRD$ = this.dso.workflowitem as Observable<RemoteData<WorkflowItem>>;
|
||||
|
||||
(this.dso.workflowitem as Observable<RemoteData<WorkflowItem>>).pipe(
|
||||
getFirstCompletedRemoteData(),
|
||||
mergeMap((wfiRD: RemoteData<WorkflowItem>) => {
|
||||
if (wfiRD.hasSucceeded) {
|
||||
this.workflowitem$.next(wfiRD.payload);
|
||||
return (wfiRD.payload.item as Observable<RemoteData<Item>>).pipe(
|
||||
getFirstCompletedRemoteData()
|
||||
);
|
||||
} else {
|
||||
return EMPTY;
|
||||
}
|
||||
}),
|
||||
tap((itemRD: RemoteData<Item>) => {
|
||||
if (isNotEmpty(itemRD) && itemRD.hasSucceeded) {
|
||||
this.item$.next(itemRD.payload);
|
||||
}
|
||||
})
|
||||
).subscribe();
|
||||
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
// This ensures the object is removed from cache, when action is performed on task
|
||||
this.objectCache.remove(this.dso._links.workflowitem.href);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,18 +1,15 @@
|
||||
<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>
|
||||
<ng-container *ngIf="(workflowitem$ | async) && (item$ | async)">
|
||||
<ds-themed-item-list-preview [item]="item$.value"
|
||||
[object]="object"
|
||||
[showSubmitter]="showSubmitter"
|
||||
[status]="status"></ds-themed-item-list-preview>
|
||||
|
||||
<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 class="row">
|
||||
<div [ngClass]="showThumbnails ? 'offset-3 offset-md-2 pl-3' : ''">
|
||||
<ds-claimed-task-actions [item]="item$.value"
|
||||
[object]="dso"
|
||||
[workflowitem]="workflowitem$.value"
|
||||
(processCompleted)="reloadedObject.emit($event.reloadedObject)"></ds-claimed-task-actions>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</ng-container>
|
||||
|
@@ -104,6 +104,7 @@ describe('ClaimedSearchResultListElementComponent', () => {
|
||||
jasmine.objectContaining({ name: 'action' })
|
||||
);
|
||||
expect(component.workflowitem$.value).toEqual(workflowitem);
|
||||
expect(component.item$.value).toEqual(item);
|
||||
}));
|
||||
|
||||
it('should have properly status', () => {
|
||||
|
@@ -8,7 +8,7 @@ import { TruncatableService } from '../../../truncatable/truncatable.service';
|
||||
import {
|
||||
MyDspaceItemStatusType
|
||||
} from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type';
|
||||
import { BehaviorSubject, Observable } from 'rxjs';
|
||||
import { BehaviorSubject, EMPTY, 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';
|
||||
@@ -20,6 +20,9 @@ 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';
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { mergeMap, tap } from 'rxjs/operators';
|
||||
import { isNotEmpty } from '../../../empty.util';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-claimed-search-result-list-element',
|
||||
@@ -39,6 +42,11 @@ export class ClaimedSearchResultListElementComponent extends SearchResultListEle
|
||||
*/
|
||||
public status = MyDspaceItemStatusType.VALIDATION;
|
||||
|
||||
/**
|
||||
* The item object that belonging to the result object
|
||||
*/
|
||||
public item$: BehaviorSubject<Item> = new BehaviorSubject<Item>(null);
|
||||
|
||||
/**
|
||||
* The workflowitem object that belonging to the result object
|
||||
*/
|
||||
@@ -65,15 +73,29 @@ export class ClaimedSearchResultListElementComponent extends SearchResultListEle
|
||||
ngOnInit() {
|
||||
super.ngOnInit();
|
||||
this.linkService.resolveLinks(this.dso, followLink('workflowitem', {},
|
||||
followLink('item'), followLink('submitter')
|
||||
followLink('item', {}, followLink('bundles')),
|
||||
followLink('submitter')
|
||||
), followLink('action'));
|
||||
|
||||
(this.dso.workflowitem as Observable<RemoteData<WorkflowItem>>).pipe(
|
||||
getFirstCompletedRemoteData()
|
||||
).subscribe((wfiRD: RemoteData<WorkflowItem>) => {
|
||||
if (wfiRD.hasSucceeded) {
|
||||
this.workflowitem$.next(wfiRD.payload);
|
||||
}
|
||||
});
|
||||
getFirstCompletedRemoteData(),
|
||||
mergeMap((wfiRD: RemoteData<WorkflowItem>) => {
|
||||
if (wfiRD.hasSucceeded) {
|
||||
this.workflowitem$.next(wfiRD.payload);
|
||||
return (wfiRD.payload.item as Observable<RemoteData<Item>>).pipe(
|
||||
getFirstCompletedRemoteData()
|
||||
);
|
||||
} else {
|
||||
return EMPTY;
|
||||
}
|
||||
}),
|
||||
tap((itemRD: RemoteData<Item>) => {
|
||||
if (isNotEmpty(itemRD) && itemRD.hasSucceeded) {
|
||||
this.item$.next(itemRD.payload);
|
||||
}
|
||||
})
|
||||
).subscribe();
|
||||
|
||||
this.showThumbnails = this.appConfig.browseBy.showThumbnails;
|
||||
}
|
||||
|
||||
|
@@ -1,12 +1,15 @@
|
||||
<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 [ngClass]="showThumbnails ? 'offset-3 offset-md-2 pl-3' : ''">
|
||||
<ds-pool-task-actions id="actions" *ngIf="workflowitem$.value"
|
||||
[object]="dso"
|
||||
(processCompleted)="this.reloadedObject.emit($event.reloadedObject)"></ds-pool-task-actions>
|
||||
<ng-container *ngIf="(workflowitem$ | async) && (item$ | async)">
|
||||
<ds-themed-item-list-preview [item]="item$.value"
|
||||
[object]="object"
|
||||
[showSubmitter]="showSubmitter"
|
||||
[status]="status"></ds-themed-item-list-preview>
|
||||
<div class="row">
|
||||
<div [ngClass]="showThumbnails ? 'offset-3 offset-md-2 pl-3' : ''">
|
||||
<ds-pool-task-actions id="actions"
|
||||
[item]="item$.value"
|
||||
[object]="dso"
|
||||
[workflowitem]="workflowitem$.value"
|
||||
(processCompleted)="this.reloadedObject.emit($event.reloadedObject)"></ds-pool-task-actions>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ng-container>
|
||||
|
@@ -110,6 +110,7 @@ describe('PoolSearchResultListElementComponent', () => {
|
||||
jasmine.objectContaining({ name: 'action' })
|
||||
);
|
||||
expect(component.workflowitem$.value).toEqual(workflowitem);
|
||||
expect(component.item$.value).toEqual(item);
|
||||
}));
|
||||
|
||||
it('should have properly status', () => {
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import { Component, Inject, OnDestroy, OnInit } from '@angular/core';
|
||||
|
||||
import { BehaviorSubject, Observable } from 'rxjs';
|
||||
import { BehaviorSubject, EMPTY, Observable } from 'rxjs';
|
||||
import { mergeMap, tap } from 'rxjs/operators';
|
||||
|
||||
import { ViewMode } from '../../../../core/shared/view-mode.model';
|
||||
import { RemoteData } from '../../../../core/data/remote-data';
|
||||
@@ -21,6 +22,8 @@ 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';
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { isNotEmpty } from '../../../empty.util';
|
||||
|
||||
/**
|
||||
* This component renders pool task object for the search result in the list view.
|
||||
@@ -44,6 +47,11 @@ export class PoolSearchResultListElementComponent extends SearchResultListElemen
|
||||
*/
|
||||
public status = MyDspaceItemStatusType.WAITING_CONTROLLER;
|
||||
|
||||
/**
|
||||
* The item object that belonging to the result object
|
||||
*/
|
||||
public item$: BehaviorSubject<Item> = new BehaviorSubject<Item>(null);
|
||||
|
||||
/**
|
||||
* The workflowitem object that belonging to the result object
|
||||
*/
|
||||
@@ -75,15 +83,29 @@ export class PoolSearchResultListElementComponent extends SearchResultListElemen
|
||||
ngOnInit() {
|
||||
super.ngOnInit();
|
||||
this.linkService.resolveLinks(this.dso, followLink('workflowitem', {},
|
||||
followLink('item'), followLink('submitter')
|
||||
followLink('item', {}, followLink('bundles')),
|
||||
followLink('submitter')
|
||||
), followLink('action'));
|
||||
|
||||
(this.dso.workflowitem as Observable<RemoteData<WorkflowItem>>).pipe(
|
||||
getFirstCompletedRemoteData()
|
||||
).subscribe((wfiRD: RemoteData<WorkflowItem>) => {
|
||||
if (wfiRD.hasSucceeded) {
|
||||
this.workflowitem$.next(wfiRD.payload);
|
||||
}
|
||||
});
|
||||
getFirstCompletedRemoteData(),
|
||||
mergeMap((wfiRD: RemoteData<WorkflowItem>) => {
|
||||
if (wfiRD.hasSucceeded) {
|
||||
this.workflowitem$.next(wfiRD.payload);
|
||||
return (wfiRD.payload.item as Observable<RemoteData<Item>>).pipe(
|
||||
getFirstCompletedRemoteData()
|
||||
);
|
||||
} else {
|
||||
return EMPTY;
|
||||
}
|
||||
}),
|
||||
tap((itemRD: RemoteData<Item>) => {
|
||||
if (isNotEmpty(itemRD) && itemRD.hasSucceeded) {
|
||||
this.item$.next(itemRD.payload);
|
||||
}
|
||||
})
|
||||
).subscribe();
|
||||
|
||||
this.showThumbnails = this.appConfig.browseBy.showThumbnails;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user