52 lines
1.1 KiB
TypeScript
52 lines
1.1 KiB
TypeScript
|
import {
|
||
|
Component,
|
||
|
OnInit,
|
||
|
Inject,
|
||
|
ViewChild,
|
||
|
ElementRef
|
||
|
} from '@angular/core';
|
||
|
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
|
||
|
|
||
|
export interface ConfirmDialogData {
|
||
|
title: string;
|
||
|
message?: string;
|
||
|
html?: string;
|
||
|
hideAction?: boolean;
|
||
|
}
|
||
|
|
||
|
export interface ConfirmDialogResult {
|
||
|
choice: boolean;
|
||
|
}
|
||
|
|
||
|
@Component({
|
||
|
selector: 'ucap-ui-confirm-dialog',
|
||
|
templateUrl: './confirm.dialog.component.html',
|
||
|
styleUrls: ['./confirm.dialog.component.scss']
|
||
|
})
|
||
|
export class ConfirmDialogComponent implements OnInit {
|
||
|
@ViewChild('messageContainer', { static: true })
|
||
|
messageContainer: ElementRef;
|
||
|
|
||
|
hideAction = false;
|
||
|
|
||
|
constructor(
|
||
|
public dialogRef: MatDialogRef<ConfirmDialogComponent, ConfirmDialogResult>,
|
||
|
@Inject(MAT_DIALOG_DATA) public data: ConfirmDialogData
|
||
|
) {}
|
||
|
|
||
|
ngOnInit(): void {
|
||
|
if (!!this.data.html) {
|
||
|
this.messageContainer.nativeElement.innerHTML = this.data.html;
|
||
|
}
|
||
|
if (!!this.data.hideAction) {
|
||
|
this.hideAction = this.data.hideAction;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
onClickChoice(choice: boolean): void {
|
||
|
this.dialogRef.close({
|
||
|
choice
|
||
|
});
|
||
|
}
|
||
|
}
|