All files / confirmation confirmation.service.ts

72.72% Statements 8/11
100% Branches 4/4
25% Functions 1/4
85.71% Lines 6/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23  1x 1x     1x     1x 5x     5x                    
import { ConfirmationConfig } from './confirmation.types';
import { ModalService } from '../modal/services/modal.service';
import { Injectable, inject } from '@angular/core';
import { Observable } from 'rxjs';
 
const DEFAULT_WIDTH = '450px';
 
@Injectable({ providedIn: 'root' })
export class ConfirmationService {
    private readonly modalService = inject(ModalService);
 
    open(config: ConfirmationConfig): Observable<string | undefined> {
        return this.modalService.open<ConfirmationConfig, string>(
            () => import('./confirmation-dialog.component').then(m => m.ConfirmationDialogComponent),
            {
                data: config,
                width: config.width ?? DEFAULT_WIDTH,
                disableClose: config.disableClose ?? false,
            },
        );
    }
}