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 | 2x 2x 2x 2x 1x 1x 1x | import { ChangeDetectionStrategy, Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core'; import { Observable } from 'rxjs'; import { ProductContextFacade } from 'ish-core/facades/product-context.facade'; import { LineItemUpdate } from 'ish-core/models/line-item-update/line-item-update.model'; import { ProductView } from 'ish-core/models/product-view/product-view.model'; import { ModalDialogComponent } from 'ish-shared/components/common/modal-dialog/modal-dialog.component'; /** * The Line Item Edit Component displays an edit-link and edit-dialog. */ @Component({ selector: 'ish-line-item-edit', templateUrl: './line-item-edit.component.html', changeDetection: ChangeDetectionStrategy.OnPush, }) export class LineItemEditComponent implements OnInit { @ViewChild('modalDialog') modalDialogRef: ModalDialogComponent<unknown>; @Input({ required: true }) itemId: string; @Output() updateItem = new EventEmitter<LineItemUpdate>(); product$: Observable<ProductView>; constructor(private context: ProductContextFacade) {} ngOnInit() { this.product$ = this.context.select('product'); } show() { this.modalDialogRef.show(); this.context.hold(this.context.select('product'), product => { this.modalDialogRef.options.confirmDisabled = !product.available; }); this.context.hold(this.modalDialogRef.confirmed, () => this.updateItem.emit({ itemId: this.itemId, sku: this.context.get('sku'), quantity: this.context.get('quantity'), }) ); } } |