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 | 92x 92x 92x 92x 92x 92x 92x 15x 15x 92x 12x 1x 92x 1x 1x 92x 2x 92x 92x | import { Component, OnInit, TemplateRef, ViewChild } from '@angular/core';
import { FormControl, Validators } from '@angular/forms';
import { BsModalRef } from 'ngx-bootstrap/modal';
import { Observable } from 'rxjs';
import { CdFormGroup } from '../../forms/cd-form-group';
import { SubmitButtonComponent } from '../submit-button/submit-button.component';
@Component({
selector: 'cd-deletion-modal',
template: require('./critical-confirmation-modal.component.html'),
styles: []
})
export class CriticalConfirmationModalComponent implements OnInit {
@ViewChild(SubmitButtonComponent)
submitButton: SubmitButtonComponent;
bodyTemplate: TemplateRef<any>;
bodyContext: object;
submitActionObservable: () => Observable<any>;
submitAction: Function;
deletionForm: CdFormGroup;
itemDescription: 'entry';
actionDescription = 'delete';
constructor(public modalRef: BsModalRef) {}
ngOnInit() {
this.deletionForm = new CdFormGroup({
confirmation: new FormControl(false, [Validators.requiredTrue])
});
if (!(this.submitAction || this.submitActionObservable)) {
throw new Error('No submit action defined');
}
}
callSubmitAction() {
if (this.submitActionObservable) {
this.submitActionObservable().subscribe(
null,
this.stopLoadingSpinner.bind(this),
this.hideModal.bind(this)
);
} else {
this.submitAction();
}
}
hideModal() {
this.modalRef.hide();
}
stopLoadingSpinner() {
this.deletionForm.setErrors({ cdSubmitButton: true });
}
}
|