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'; import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator'; import { ClaimedTaskSearchResult } from '../../../object-collection/shared/claimed-task-search-result.model'; import { SearchResultListElementComponent } from '../../search-result-list-element/search-result-list-element.component'; /** * This component renders claimed task object for the search result in the list view. */ @Component({ selector: 'ds-claimed-search-result-list-element', styleUrls: ['../../search-result-list-element/search-result-list-element.component.scss'], templateUrl: './claimed-search-result-list-element.component.html', providers: [Location, { provide: LocationStrategy, useClass: PathLocationStrategy }] }) @listableObjectComponent(ClaimedTaskSearchResult, ViewMode.ListElement) export class ClaimedSearchResultListElementComponent extends SearchResultListElementComponent { /** * A boolean representing if to show submitter information */ public showSubmitter = true; /** * Represent item's status */ public status = MyDspaceItemStatusType.VALIDATION; /** * The workflowitem object that belonging to the result object */ public workflowitem: WorkflowItem; /** * Initialize all instance variables */ ngOnInit() { super.ngOnInit(); this.initWorkflowItem(this.dso.workflowitem as Observable>); } /** * Retrieve workflowitem from result object */ initWorkflowItem(wfi$: Observable>) { wfi$.pipe( find((rd: RemoteData) => (rd.hasSucceeded && isNotUndefined(rd.payload))) ).subscribe((rd: RemoteData) => { this.workflowitem = rd.payload; }); } }