69115: MyDSpace ClaimedTask proper link resolving

This commit is contained in:
Kristof De Langhe
2020-02-26 17:50:44 +01:00
parent a6f1a6d1ec
commit e1f940668a
9 changed files with 42 additions and 38 deletions

View File

@@ -1,7 +1,9 @@
<ds-item-list-preview *ngIf="workflowitem"
[item]="(workflowitem.item | async)?.payload"
[object]="object"
[showSubmitter]="showSubmitter"
[status]="status"></ds-item-list-preview>
<ng-container *ngVar="(workflowitemRD$ | async)?.payload as workflowitem">
<ds-item-list-preview *ngIf="workflowitem"
[item]="(workflowitem?.item | async)?.payload"
[object]="object"
[showSubmitter]="showSubmitter"
[status]="status"></ds-item-list-preview>
<ds-claimed-task-actions *ngIf="workflowitem" [object]="dso"></ds-claimed-task-actions>
<ds-claimed-task-actions *ngIf="workflowitem" [object]="dso"></ds-claimed-task-actions>
</ng-container>

View File

@@ -12,6 +12,7 @@ import { WorkflowItem } from '../../../../core/submission/models/workflowitem.mo
import { createSuccessfulRemoteDataObject } from '../../../testing/utils';
import { ClaimedTaskSearchResult } from '../../../object-collection/shared/claimed-task-search-result.model';
import { TruncatableService } from '../../../truncatable/truncatable.service';
import { VarDirective } from '../../../utils/var.directive';
let component: ClaimedSearchResultListElementComponent;
let fixture: ComponentFixture<ClaimedSearchResultListElementComponent>;
@@ -59,7 +60,7 @@ describe('ClaimedSearchResultListElementComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [NoopAnimationsModule],
declarations: [ClaimedSearchResultListElementComponent],
declarations: [ClaimedSearchResultListElementComponent, VarDirective],
providers: [
{ provide: TruncatableService, useValue: {} },
],
@@ -79,8 +80,11 @@ describe('ClaimedSearchResultListElementComponent', () => {
fixture.detectChanges();
});
it('should init item properly', () => {
expect(component.workflowitem).toEqual(workflowitem);
it('should init item properly', (done) => {
component.workflowitemRD$.subscribe((workflowitemRD) => {
expect(workflowitemRD.payload).toEqual(workflowitem);
done();
});
});
it('should have properly status', () => {

View File

@@ -2,11 +2,9 @@ import { Component } from '@angular/core';
import { Location, LocationStrategy, PathLocationStrategy } from '@angular/common';
import { Observable } from 'rxjs';
import { find } from 'rxjs/operators';
import { ViewMode } from '../../../../core/shared/view-mode.model';
import { RemoteData } from '../../../../core/data/remote-data';
import { isNotUndefined } from '../../../empty.util';
import { WorkflowItem } from '../../../../core/submission/models/workflowitem.model';
import { ClaimedTask } from '../../../../core/tasks/models/claimed-task-object.model';
import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type';
@@ -40,24 +38,13 @@ export class ClaimedSearchResultListElementComponent extends SearchResultListEle
/**
* The workflowitem object that belonging to the result object
*/
public workflowitem: WorkflowItem;
public workflowitemRD$: Observable<RemoteData<WorkflowItem>>;
/**
* Initialize all instance variables
*/
ngOnInit() {
super.ngOnInit();
this.initWorkflowItem(this.dso.workflowitem as Observable<RemoteData<WorkflowItem>>);
}
/**
* Retrieve workflowitem from result object
*/
initWorkflowItem(wfi$: Observable<RemoteData<WorkflowItem>>) {
wfi$.pipe(
find((rd: RemoteData<WorkflowItem>) => (rd.hasSucceeded && isNotUndefined(rd.payload)))
).subscribe((rd: RemoteData<WorkflowItem>) => {
this.workflowitem = rd.payload;
});
this.workflowitemRD$ = this.dso.workflowitem as Observable<RemoteData<WorkflowItem>>;
}
}