paperless-ngx/src-ui/src/app/components/common/confirm-dialog/confirm-dialog.component.ts

81 lines
1.7 KiB
TypeScript
Raw Normal View History

2025-01-01 22:26:53 -08:00
import { DecimalPipe } from '@angular/common'
import { Component, EventEmitter, Input, Output } from '@angular/core'
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
2024-12-13 00:27:30 -08:00
import { Subject } from 'rxjs'
2025-01-01 22:26:53 -08:00
import { SafeHtmlPipe } from 'src/app/pipes/safehtml.pipe'
2024-12-06 00:26:38 -08:00
import { LoadingComponentWithPermissions } from '../../loading-component/loading.component'
2020-10-27 01:10:18 +01:00
@Component({
2023-09-14 14:03:28 -07:00
selector: 'pngx-confirm-dialog',
templateUrl: './confirm-dialog.component.html',
styleUrls: ['./confirm-dialog.component.scss'],
2025-01-01 22:26:53 -08:00
imports: [DecimalPipe, SafeHtmlPipe],
2020-10-27 01:10:18 +01:00
})
2024-12-06 00:26:38 -08:00
export class ConfirmDialogComponent extends LoadingComponentWithPermissions {
constructor(public activeModal: NgbActiveModal) {
super()
}
2021-01-25 23:32:02 -08:00
2020-10-27 01:10:18 +01:00
@Output()
public confirmClicked = new EventEmitter()
2020-10-27 01:10:18 +01:00
@Output()
public alternativeClicked = new EventEmitter()
2020-10-27 01:10:18 +01:00
@Input()
2020-12-28 15:39:53 +01:00
title = $localize`Confirmation`
2020-10-27 01:10:18 +01:00
@Input()
messageBold
2020-10-27 01:10:18 +01:00
@Input()
message
2020-10-27 01:10:18 +01:00
@Input()
btnClass = 'btn-primary'
@Input()
2020-12-28 15:39:53 +01:00
btnCaption = $localize`Confirm`
@Input()
alternativeBtnClass = 'btn-secondary'
@Input()
alternativeBtnCaption
@Input()
cancelBtnClass = 'btn-outline-secondary'
@Input()
cancelBtnCaption = $localize`Cancel`
2021-01-03 21:44:53 +01:00
@Input()
buttonsEnabled = true
2021-01-25 22:44:26 -08:00
confirmButtonEnabled = true
alternativeButtonEnabled = true
seconds = 0
2022-03-16 13:17:08 -07:00
secondsTotal = 0
2022-02-15 23:43:02 -08:00
confirmSubject: Subject<boolean>
alternativeSubject: Subject<boolean>
2021-01-25 22:44:26 -08:00
cancel() {
2022-02-15 23:43:02 -08:00
this.confirmSubject?.next(false)
this.confirmSubject?.complete()
2020-10-27 01:10:18 +01:00
this.activeModal.close()
}
2021-01-25 22:44:26 -08:00
confirm() {
2021-01-25 23:32:02 -08:00
this.confirmClicked.emit()
2022-02-15 23:43:02 -08:00
this.confirmSubject?.next(true)
this.confirmSubject?.complete()
2021-01-25 22:44:26 -08:00
}
alternative() {
this.alternativeClicked.emit()
this.alternativeSubject?.next(true)
this.alternativeSubject?.complete()
}
2020-10-27 01:10:18 +01:00
}