All files / src/app/extensions/order-templates/shared/order-create-order-template order-create-order-template.component.ts

88.88% Statements 8/9
75% Branches 3/4
66.66% Functions 2/3
88.88% Lines 8/9

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 391x 1x     1x   1x                           1x           3x 3x               1x      
import { ChangeDetectionStrategy, Component, Input, Signal } from '@angular/core';
import { toSignal } from '@angular/core/rxjs-interop';
 
import { LineItemView } from 'ish-core/models/line-item/line-item.model';
import { GenerateLazyComponent } from 'ish-core/utils/module-loader/generate-lazy-component.decorator';
 
import { OrderTemplatesFacade } from '../../facades/order-templates.facade';
import { OrderTemplate } from '../../models/order-template/order-template.model';
import { OrderTemplatePreferencesDialogComponent } from '../order-template-preferences-dialog/order-template-preferences-dialog.component';
 
@Component({
  selector: 'ish-order-create-order-template',
  templateUrl: './order-create-order-template.component.html',
  changeDetection: ChangeDetectionStrategy.OnPush,
})
/**
 * The Create Order Template from Order displays a button which adds the current order to to a new order template.
 */
 
@GenerateLazyComponent()
export class OrderCreateOrderTemplateComponent {
  @Input({ required: true }) lineItems: LineItemView[];
  @Input() cssClass: string;
 
  displaySpinner: Signal<boolean>;
 
  constructor(private orderTemplatesFacade: OrderTemplatesFacade) {
    this.displaySpinner = toSignal(this.orderTemplatesFacade.orderTemplateLoading$, { initialValue: false });
  }
 
  openModal(modal: OrderTemplatePreferencesDialogComponent) {
    modal.show();
  }
 
  createOrderTemplate(orderTemplate: OrderTemplate) {
    this.orderTemplatesFacade.createOrderTemplateFromLineItems(orderTemplate, this.lineItems);
  }
}