validatedCity, mask for input, confirmatonService, Version Info,
This commit is contained in:
@@ -24,7 +24,9 @@ import { ConfirmationService } from './confirmation.service';
|
||||
<svg class="mx-auto mb-4 text-gray-400 w-12 h-12 dark:text-gray-200" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 20 20">
|
||||
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 11V6m0 8h.01M19 10a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z" />
|
||||
</svg>
|
||||
<h3 class="mb-5 text-lg font-normal text-gray-500 dark:text-gray-400">{{ confirmationService.message$ | async }}</h3>
|
||||
@let confirmation = (confirmationService.confirmation$ | async);
|
||||
<h3 class="mb-5 text-lg font-normal text-gray-500 dark:text-gray-400">{{ confirmation.message }}</h3>
|
||||
@if(confirmation.buttons==='both'){
|
||||
<button
|
||||
(click)="confirmationService.accept()"
|
||||
type="button"
|
||||
@@ -39,6 +41,7 @@ import { ConfirmationService } from './confirmation.service';
|
||||
>
|
||||
No, cancel
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,19 +1,25 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { BehaviorSubject, Observable } from 'rxjs';
|
||||
|
||||
export interface Confirmation {
|
||||
message: string;
|
||||
buttons?: 'both' | 'none';
|
||||
button_accept_label?: string;
|
||||
button_reject_label?: string;
|
||||
}
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class ConfirmationService {
|
||||
private modalVisibleSubject = new BehaviorSubject<boolean>(false);
|
||||
private messageSubject = new BehaviorSubject<string>('');
|
||||
private confirmationSubject = new BehaviorSubject<Confirmation>({ message: '' });
|
||||
private resolvePromise!: (value: boolean) => void;
|
||||
|
||||
modalVisible$: Observable<boolean> = this.modalVisibleSubject.asObservable();
|
||||
message$: Observable<string> = this.messageSubject.asObservable();
|
||||
confirmation$: Observable<Confirmation> = this.confirmationSubject.asObservable();
|
||||
|
||||
showConfirmation(message: string): Promise<boolean> {
|
||||
this.messageSubject.next(message);
|
||||
showConfirmation(confirmation: Confirmation): Promise<boolean> {
|
||||
confirmation.buttons = confirmation.buttons ? confirmation.buttons : 'both';
|
||||
this.confirmationSubject.next(confirmation);
|
||||
this.modalVisibleSubject.next(true);
|
||||
return new Promise<boolean>(resolve => {
|
||||
this.resolvePromise = resolve;
|
||||
|
||||
Reference in New Issue
Block a user