]>
Commit | Line | Data |
---|---|---|
1378c0d3 | 1 | import { firstValueFrom, Subject } from 'rxjs' |
df98563e | 2 | import { Injectable } from '@angular/core' |
5769e1db | 3 | |
22b59e80 C |
4 | type ConfirmOptions = { |
5 | title: string | |
6 | message: string | |
7 | inputLabel?: string | |
8 | expectedInputValue?: string | |
9 | confirmButtonText?: string | |
10 | } | |
11 | ||
5769e1db C |
12 | @Injectable() |
13 | export class ConfirmService { | |
22b59e80 | 14 | showConfirm = new Subject<ConfirmOptions>() |
df98563e | 15 | confirmResponse = new Subject<boolean>() |
5769e1db | 16 | |
22b59e80 C |
17 | confirm (message: string, title = '', confirmButtonText?: string) { |
18 | this.showConfirm.next({ title, message, confirmButtonText }) | |
5769e1db | 19 | |
1378c0d3 | 20 | return firstValueFrom(this.confirmResponse.asObservable()) |
1f30a185 C |
21 | } |
22 | ||
22b59e80 C |
23 | confirmWithInput (message: string, inputLabel: string, expectedInputValue: string, title = '', confirmButtonText?: string) { |
24 | this.showConfirm.next({ title, message, inputLabel, expectedInputValue, confirmButtonText }) | |
1f30a185 | 25 | |
1378c0d3 | 26 | return firstValueFrom(this.confirmResponse.asObservable()) |
5769e1db C |
27 | } |
28 | } |