projects/netgrif-components-core/src/lib/dialog/components/confirm-dialog/confirm-dialog.component.ts
Question modal dialog with its own layout (which asks the user a question with two answers - yes or no) based on a material design that injected data and inherits from an AbstractDialog.
selector | ncc-question-dialog |
styleUrls | ./confirm-dialog.component.scss |
templateUrl | ./confirm-dialog.component.html |
Properties |
|
Methods |
|
constructor(dialogRef: MatDialogRef<ConfirmDialogComponent | DialogResult>, data: DialogData, sanitizer: DomSanitizer)
|
||||||||||||||||
Only injecting.
Parameters :
|
Public onClose | ||||||
onClose(isSubmitted: boolean)
|
||||||
Inherited from
AbstractDialogComponent
|
||||||
Defined in
AbstractDialogComponent:39
|
||||||
Parameters :
Returns :
void
|
Public choice |
Type : boolean
|
Public data |
Type : DialogData
|
Decorators :
@Inject(MAT_DIALOG_DATA)
|
Inherited from
AbstractDialogComponent
|
Defined in
AbstractDialogComponent:29
|
Injected data that was passed in to a dialog.
|
Public dialogRef |
Type : MatDialogRef<ConfirmDialogComponent | DialogResult>
|
Inherited from
AbstractDialogComponent
|
Defined in
AbstractDialogComponent:28
|
Reference to a dialog opened via the MatDialog service.
|
Public parsedContent |
Type : SafeHtml
|
import {Component, Inject} from '@angular/core';
import {AbstractDialogComponent} from '../../models/abstract-dialog.component';
import {DialogResult} from '../../models/DialogResult';
import {DialogData} from '../../models/DialogData';
import {MAT_DIALOG_DATA, MatDialogRef} from '@angular/material/dialog';
import {DomSanitizer, SafeHtml} from '@angular/platform-browser';
/**
* Question modal dialog with its own layout (which asks the user a question with two answers - yes or no)
* based on a material design that injected data and inherits from an [AbstractDialog]{@link AbstractDialogComponent}.
*/
@Component({
selector: 'ncc-question-dialog',
templateUrl: './confirm-dialog.component.html',
styleUrls: ['./confirm-dialog.component.scss']
})
export class ConfirmDialogComponent extends AbstractDialogComponent<ConfirmDialogComponent> {
public choice: boolean;
public parsedContent: SafeHtml;
/**
* Only injecting.
* @param dialogRef Reference to a dialog opened via the MatDialog service.
* @param data Injected data that was passed in to a dialog.
* @param sanitizer sanitize HTML
*/
constructor(public dialogRef: MatDialogRef<ConfirmDialogComponent, DialogResult>,
@Inject(MAT_DIALOG_DATA) public data: DialogData, private sanitizer: DomSanitizer) {
super(dialogRef, data);
this.choice = false;
if (data && data.content) {
this.parsedContent = sanitizer.bypassSecurityTrustHtml(data.content.replace('\\n', '<br>'));
} else {
this.parsedContent = sanitizer.bypassSecurityTrustHtml('');
}
}
public onClose(isSubmitted: boolean) {
this.dialogRef.close({
confirmed: isSubmitted
});
}
}
<h1 mat-dialog-title>{{data.title}}</h1>
<div mat-dialog-content class="dialog-container dialog-content-margin" [innerHTML]="parsedContent"></div>
<mat-dialog-actions fxLayoutAlign="end">
<button mat-button color="warn" (click)="onClose(false)">{{data.negativeLabel}}</button>
<button mat-flat-button color="primary" (click)="onClose(true)">{{data.positiveLabel}}</button>
</mat-dialog-actions>
./confirm-dialog.component.scss