delete dialog: delay enable delete button

This commit is contained in:
jonaswinkler 2020-12-11 14:47:33 +01:00
parent 2c702eb568
commit a8f27f79dd
2 changed files with 16 additions and 1 deletions

View File

@ -10,5 +10,5 @@
</div>
<div class="modal-footer">
<button type="button" class="btn btn-outline-dark" (click)="cancelClicked()">Cancel</button>
<button type="button" class="btn btn-danger" (click)="deleteClicked.emit()">Delete</button>
<button type="button" class="btn btn-danger" (click)="deleteClicked.emit()" [disabled]="!deleteButtonEnabled">Delete<span *ngIf="!deleteButtonEnabled"> ({{seconds}})</span></button>
</div>

View File

@ -22,6 +22,21 @@ export class DeleteDialogComponent implements OnInit {
@Input()
message2
deleteButtonEnabled = true
seconds = 0
delayConfirm(seconds: number) {
this.deleteButtonEnabled = false
this.seconds = seconds
setTimeout(() => {
if (this.seconds <= 1) {
this.deleteButtonEnabled = true
} else {
this.delayConfirm(seconds - 1)
}
}, 1000)
}
ngOnInit(): void {
}