mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-17 15:03:07 +00:00
[CST-6876] fix error when submitter is empty
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
<div class="mt-2 mb-2">
|
||||
<div class="mt-2 mb-2" *ngIf="(submitter$ | async)">
|
||||
<span class="text-muted">{{'submission.workflow.tasks.generic.submitter' | translate}} : <span class="badge badge-info">{{(submitter$ | async)?.name}}</span></span>
|
||||
</div>
|
||||
|
@@ -1,12 +1,13 @@
|
||||
import { Component, Input, OnInit } from '@angular/core';
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
import { filter, find, map, mergeMap } from 'rxjs/operators';
|
||||
import { EMPTY, Observable } from 'rxjs';
|
||||
import { map, mergeMap } from 'rxjs/operators';
|
||||
|
||||
import { EPerson } from '../../../../core/eperson/models/eperson.model';
|
||||
import { RemoteData } from '../../../../core/data/remote-data';
|
||||
import { isNotEmpty, isNotUndefined } from '../../../empty.util';
|
||||
import { isNotEmpty } from '../../../empty.util';
|
||||
import { WorkflowItem } from '../../../../core/submission/models/workflowitem.model';
|
||||
import { getFirstCompletedRemoteData } from '../../../../core/shared/operators';
|
||||
|
||||
/**
|
||||
* This component represents a badge with submitter information.
|
||||
@@ -24,7 +25,7 @@ export class ItemSubmitterComponent implements OnInit {
|
||||
@Input() object: any;
|
||||
|
||||
/**
|
||||
* The Eperson object
|
||||
* The submitter object
|
||||
*/
|
||||
submitter$: Observable<EPerson>;
|
||||
|
||||
@@ -33,9 +34,22 @@ export class ItemSubmitterComponent implements OnInit {
|
||||
*/
|
||||
ngOnInit() {
|
||||
this.submitter$ = (this.object.workflowitem as Observable<RemoteData<WorkflowItem>>).pipe(
|
||||
filter((rd: RemoteData<WorkflowItem>) => (rd.hasSucceeded && isNotUndefined(rd.payload))),
|
||||
mergeMap((rd: RemoteData<WorkflowItem>) => rd.payload.submitter as Observable<RemoteData<EPerson>>),
|
||||
find((rd: RemoteData<EPerson>) => rd.hasSucceeded && isNotEmpty(rd.payload)),
|
||||
map((rd: RemoteData<EPerson>) => rd.payload));
|
||||
getFirstCompletedRemoteData(),
|
||||
mergeMap((rd: RemoteData<WorkflowItem>) => {
|
||||
if (rd.hasSucceeded && isNotEmpty(rd.payload)) {
|
||||
return (rd.payload.submitter as Observable<RemoteData<EPerson>>).pipe(
|
||||
getFirstCompletedRemoteData(),
|
||||
map((rds: RemoteData<EPerson>) => {
|
||||
if (rds.hasSucceeded && isNotEmpty(rds.payload)) {
|
||||
return rds.payload;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
})
|
||||
);
|
||||
} else {
|
||||
return EMPTY;
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user