Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | 1x 1x 1x 1x 5x 5x 5x 5x 5x 5x 5x 5x 5x 1x 1x 1x 1x 3x 3x | import { ChangeDetectionStrategy, Component, DestroyRef, OnInit, inject } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { Observable } from 'rxjs';
import { HttpError } from 'ish-core/models/http-error/http-error.model';
import { RequisitionColumnsType } from '../../components/requisitions-list/requisitions-list.component';
import { RequisitionManagementFacade } from '../../facades/requisition-management.facade';
import { Requisition, RequisitionStatus } from '../../models/requisition/requisition.model';
@Component({
selector: 'ish-buyer-page',
templateUrl: './buyer-page.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class BuyerPageComponent implements OnInit {
requisitions$: Observable<Requisition[]>;
error$: Observable<HttpError>;
loading$: Observable<boolean>;
status$: Observable<RequisitionStatus>;
status: RequisitionStatus;
columnsToDisplay: RequisitionColumnsType[];
private destroyRef = inject(DestroyRef);
constructor(private requisitionManagementFacade: RequisitionManagementFacade) {}
ngOnInit() {
this.requisitions$ = this.requisitionManagementFacade.requisitionsByRoute$;
this.error$ = this.requisitionManagementFacade.requisitionsError$;
this.loading$ = this.requisitionManagementFacade.requisitionsLoading$;
this.status$ = this.requisitionManagementFacade.requisitionsStatus$ as Observable<RequisitionStatus>;
this.status$.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(status => {
this.status = status;
switch (status) {
case 'APPROVED':
this.columnsToDisplay = [
'requisitionNo',
'orderNo',
'creationDate',
'approver',
'approvalDate',
'orderTotal',
];
break;
case 'REJECTED':
this.columnsToDisplay = [
'requisitionNo',
'creationDate',
'approver',
'rejectionDate',
'lineItems',
'orderTotal',
];
break;
default:
this.columnsToDisplay = ['requisitionNo', 'creationDate', 'lineItems', 'orderTotal'];
break;
}
});
}
}
|