All files / src/app/shared/components/confirmation-modal confirmation-modal.component.ts

83.33% Statements 15/18
80% Branches 4/5
50% Functions 2/4
81.25% Lines 13/16

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 4492x 92x   92x             92x                     1x   1x 1x     92x 1x 1x     92x             92x     92x  
import { Component, OnInit, TemplateRef } from '@angular/core';
import { FormGroup } from '@angular/forms';
 
import { BsModalRef } from 'ngx-bootstrap/modal';
 
@Component({
  selector: 'cd-confirmation-modal',
  template: require('./confirmation-modal.component.html'),
  styles: []
})
export class ConfirmationModalComponent implements OnInit {
  bodyData: object;
  bodyTpl: TemplateRef<any>;
  buttonText: string;
  onSubmit: Function;
  onCancel: Function;
  titleText: string;
 
  bodyContext: object;
  confirmationForm: FormGroup;
 
  boundCancel = this.cancel.bind(this);
 
  constructor(public modalRef: BsModalRef) {
    this.confirmationForm = new FormGroup({});
  }
 
  ngOnInit() {
    this.bodyContext = this.bodyContext || {};
    this.bodyContext['$implicit'] = this.bodyData;
  }
 
  cancel() {
    this.modalRef.hide();
    if (this.onCancel) {
      this.onCancel();
    }
  }
 
  stopLoadingSpinner() {
    this.confirmationForm.setErrors({ cdSubmitButton: true });
  }
}