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 | 1x 1x 1x 1x 1x 1x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x | import { ChangeDetectionStrategy, Component, DestroyRef, Input, OnInit, inject } from '@angular/core'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { Observable } from 'rxjs'; import { first } from 'rxjs/operators'; import { AccountFacade } from 'ish-core/facades/account.facade'; import { Basket } from 'ish-core/models/basket/basket.model'; import { Customer } from 'ish-core/models/customer/customer.model'; import { Order } from 'ish-core/models/order/order.model'; import { whenTruthy } from 'ish-core/utils/operators'; @Component({ selector: 'ish-basket-buyer', templateUrl: './basket-buyer.component.html', changeDetection: ChangeDetectionStrategy.OnPush, }) export class BasketBuyerComponent implements OnInit { @Input({ required: true }) object: Basket | Order; /** * Router link for editing the order reference id. If a routerLink is given a link is displayed to route to an edit page. */ @Input() editRouterLink: string; private customer$: Observable<Customer>; taxationID: string; costCenterName: string; companyName1: string; companyName2: string; private destroyRef = inject(DestroyRef); constructor(private accountFacade: AccountFacade) {} ngOnInit() { this.taxationID = this.object.taxationId; this.costCenterName = this.getAttributeValue('BusinessObjectAttributes#Order_CostCenter_Name'); this.companyName1 = this.object.user?.companyName || this.object.invoiceToAddress?.companyName1 || ''; this.companyName2 = (this.object.user?.companyName ? this.object.user?.companyName2 : this.object.invoiceToAddress?.companyName2) || ''; this.customer$ = this.accountFacade.customer$; // values for registered users and basket this.customer$.pipe(whenTruthy(), first(), takeUntilDestroyed(this.destroyRef)).subscribe(customer => { this.taxationID = this.taxationID || customer?.taxationID; }); } private getAttributeValue(attributeName: string): string { return this.object.attributes?.find(attr => attr.name === attributeName)?.value as string; } get userName(): string { return this.object.user ? `${this.object.user?.firstName} ${this.object.user?.lastName}` : `${this.object.invoiceToAddress?.firstName} ${this.object.invoiceToAddress?.lastName}`; } } |