Michael Shamoon d672455ad8 Cleanup
2021-01-25 23:32:02 -08:00

67 lines
1.3 KiB
TypeScript

import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { Subject } from 'rxjs';
@Component({
selector: 'app-confirm-dialog',
templateUrl: './confirm-dialog.component.html',
styleUrls: ['./confirm-dialog.component.scss']
})
export class ConfirmDialogComponent implements OnInit {
constructor(public activeModal: NgbActiveModal) { }
@Output()
public confirmClicked = new EventEmitter()
@Input()
title = $localize`Confirmation`
@Input()
messageBold
@Input()
message
@Input()
btnClass = "btn-primary"
@Input()
btnCaption = $localize`Confirm`
@Input()
buttonsEnabled = true
confirmButtonEnabled = true
seconds = 0
subject: Subject<boolean>
delayConfirm(seconds: number) {
this.confirmButtonEnabled = false
this.seconds = seconds
setTimeout(() => {
if (this.seconds <= 1) {
this.confirmButtonEnabled = true
} else {
this.delayConfirm(seconds - 1)
}
}, 1000)
}
ngOnInit(): void {
}
cancel() {
this.subject?.next(false)
this.subject?.complete()
this.activeModal.close()
}
confirm() {
this.confirmClicked.emit()
this.subject?.next(true)
this.subject?.complete()
}
}