All files / src/app/extensions/quoting/shared/product-add-to-quote-dialog product-add-to-quote-dialog.component.ts

81.25% Statements 13/16
75% Branches 6/8
40% Functions 2/5
92.3% Lines 12/13

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 431x 1x     1x       1x 1x                 1x                 4x     4x 4x 4x 4x   4x              
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
import { NavigationEnd, Router } from '@angular/router';
import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
import { Observable } from 'rxjs';
import { filter } from 'rxjs/operators';
 
import { HttpError } from 'ish-core/models/http-error/http-error.model';
 
import { ActiveQuoteContextFacade } from '../../facades/active-quote-context.facade';
import { QuoteContextFacade } from '../../facades/quote-context.facade';
import { Quote, QuoteRequest, QuoteStatus } from '../../models/quoting/quoting.model';
 
@Component({
  selector: 'ish-product-add-to-quote-dialog',
  templateUrl: './product-add-to-quote-dialog.component.html',
  changeDetection: ChangeDetectionStrategy.OnPush,
  providers: [{ provide: QuoteContextFacade, useClass: ActiveQuoteContextFacade }],
})
export class ProductAddToQuoteDialogComponent implements OnInit {
  activeQuoteRequest$: Observable<Quote | QuoteRequest>;
  loading$: Observable<boolean>;
  state$: Observable<QuoteStatus>;
  error$: Observable<HttpError>;
 
  // not-dead-code
  modalRef: NgbModalRef;
 
  constructor(private context: QuoteContextFacade, private router: Router) {}
 
  ngOnInit() {
    this.activeQuoteRequest$ = this.context.select('entity');
    this.loading$ = this.context.select('loading');
    this.state$ = this.context.select('state');
    this.error$ = this.context.select('error');
 
    this.context.hold(this.router.events.pipe(filter(event => event instanceof NavigationEnd)), () => this.hide());
  }
 
  hide() {
    this.modalRef.dismiss();
  }
}