/** * @license * Copyright (C) 2017 "IoT.bzh" * Author Sebastien Douheret * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { Component, OnInit, Input } from '@angular/core'; import { DomSanitizer } from '@angular/platform-browser'; import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; export enum EType { YesNo = 1, OKCancel, OK, } @Component({ selector: 'xds-confirm-modal', template: `
`, }) export class ConfirmModalComponent implements OnInit { @Input() title; @Input() footer = ''; @Input() type; @Input() question; bodyQuestion = ''; textBtn: Array = ['', '', '']; constructor( private modalRef: NgbActiveModal, private sanitizer: DomSanitizer, ) { } ngOnInit() { switch (this.type) { case EType.OK: this.textBtn = [ 'OK', '', '' ]; break; case EType.OKCancel: this.textBtn = [ 'OK', 'Cancel', '' ]; break; default: case EType.YesNo: this.textBtn = [ 'Yes', 'No', '' ]; break; } } onClick(txt: string): void { this.modalRef.close(txt.toLowerCase()); } }