Spaces:
Building
Building
Update flare-ui/src/app/dialogs/confirm-dialog/confirm-dialog.component.ts
Browse files
flare-ui/src/app/dialogs/confirm-dialog/confirm-dialog.component.ts
CHANGED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { Component, Inject } from '@angular/core';
|
2 |
+
import { CommonModule } from '@angular/common';
|
3 |
+
import { MatDialogRef, MAT_DIALOG_DATA, MatDialogModule } from '@angular/material/dialog';
|
4 |
+
import { MatButtonModule } from '@angular/material/button';
|
5 |
+
|
6 |
+
export interface ConfirmDialogData {
|
7 |
+
title: string;
|
8 |
+
message: string;
|
9 |
+
confirmText?: string;
|
10 |
+
cancelText?: string;
|
11 |
+
confirmColor?: 'primary' | 'accent' | 'warn';
|
12 |
+
}
|
13 |
+
|
14 |
+
@Component({
|
15 |
+
selector: 'app-confirm-dialog',
|
16 |
+
standalone: true,
|
17 |
+
imports: [CommonModule, MatDialogModule, MatButtonModule],
|
18 |
+
template: `
|
19 |
+
<h2 mat-dialog-title>{{ data.title }}</h2>
|
20 |
+
<mat-dialog-content>
|
21 |
+
<p>{{ data.message }}</p>
|
22 |
+
</mat-dialog-content>
|
23 |
+
<mat-dialog-actions align="end">
|
24 |
+
<button mat-button (click)="onCancel()">{{ data.cancelText || 'Cancel' }}</button>
|
25 |
+
<button mat-raised-button [color]="data.confirmColor || 'primary'" (click)="onConfirm()">
|
26 |
+
{{ data.confirmText || 'Confirm' }}
|
27 |
+
</button>
|
28 |
+
</mat-dialog-actions>
|
29 |
+
`,
|
30 |
+
styles: [`
|
31 |
+
mat-dialog-content {
|
32 |
+
padding: 20px 24px;
|
33 |
+
}
|
34 |
+
|
35 |
+
p {
|
36 |
+
margin: 0;
|
37 |
+
color: rgba(0,0,0,0.87);
|
38 |
+
line-height: 1.5;
|
39 |
+
}
|
40 |
+
|
41 |
+
mat-dialog-actions {
|
42 |
+
padding: 16px 24px;
|
43 |
+
}
|
44 |
+
`]
|
45 |
+
})
|
46 |
+
export default class ConfirmDialogComponent {
|
47 |
+
constructor(
|
48 |
+
public dialogRef: MatDialogRef<ConfirmDialogComponent>,
|
49 |
+
@Inject(MAT_DIALOG_DATA) public data: ConfirmDialogData
|
50 |
+
) {}
|
51 |
+
|
52 |
+
onConfirm(): void {
|
53 |
+
this.dialogRef.close(true);
|
54 |
+
}
|
55 |
+
|
56 |
+
onCancel(): void {
|
57 |
+
this.dialogRef.close(false);
|
58 |
+
}
|
59 |
+
}
|