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