Spaces:
Running
Running
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
@@ -50,13 +50,29 @@ export interface ConfirmDialogData {
|
|
50 |
</mat-select>
|
51 |
</mat-form-field>
|
52 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
</mat-dialog-content>
|
54 |
<mat-dialog-actions align="end">
|
55 |
<button mat-button (click)="onCancel()">{{ data.cancelText || 'Cancel' }}</button>
|
56 |
<button mat-raised-button
|
57 |
[color]="data.confirmColor || 'primary'"
|
58 |
(click)="onConfirm()"
|
59 |
-
[disabled]="data.showVersionSelect && !selectedVersionId">
|
60 |
{{ data.confirmText || 'Confirm' }}
|
61 |
</button>
|
62 |
</mat-dialog-actions>
|
@@ -90,6 +106,7 @@ export interface ConfirmDialogData {
|
|
90 |
})
|
91 |
export default class ConfirmDialogComponent {
|
92 |
selectedVersionId: number | null = null;
|
|
|
93 |
|
94 |
constructor(
|
95 |
public dialogRef: MatDialogRef<ConfirmDialogComponent>,
|
@@ -99,11 +116,18 @@ export default class ConfirmDialogComponent {
|
|
99 |
if (data.showVersionSelect && data.versions && data.versions.length > 0) {
|
100 |
this.selectedVersionId = data.versions[0].id;
|
101 |
}
|
|
|
|
|
|
|
|
|
|
|
102 |
}
|
103 |
|
104 |
onConfirm(): void {
|
105 |
if (this.data.showVersionSelect) {
|
106 |
this.dialogRef.close(this.selectedVersionId);
|
|
|
|
|
107 |
} else {
|
108 |
this.dialogRef.close(true);
|
109 |
}
|
|
|
50 |
</mat-select>
|
51 |
</mat-form-field>
|
52 |
}
|
53 |
+
|
54 |
+
@if (data.showDropdown && data.dropdownOptions) {
|
55 |
+
<mat-form-field appearance="outline" class="full-width">
|
56 |
+
<mat-label>{{ data.dropdownPlaceholder || 'Select an option' }}</mat-label>
|
57 |
+
<mat-select [(ngModel)]="selectedValue">
|
58 |
+
<mat-option [value]="null">
|
59 |
+
<em>None (Create blank)</em>
|
60 |
+
</mat-option>
|
61 |
+
@for (option of data.dropdownOptions; track option.value) {
|
62 |
+
<mat-option [value]="option.value">
|
63 |
+
{{ option.label }}
|
64 |
+
</mat-option>
|
65 |
+
}
|
66 |
+
</mat-select>
|
67 |
+
</mat-form-field>
|
68 |
+
}
|
69 |
</mat-dialog-content>
|
70 |
<mat-dialog-actions align="end">
|
71 |
<button mat-button (click)="onCancel()">{{ data.cancelText || 'Cancel' }}</button>
|
72 |
<button mat-raised-button
|
73 |
[color]="data.confirmColor || 'primary'"
|
74 |
(click)="onConfirm()"
|
75 |
+
[disabled]="(data.showVersionSelect && !selectedVersionId) || (data.showDropdown === true && selectedValue === undefined)">
|
76 |
{{ data.confirmText || 'Confirm' }}
|
77 |
</button>
|
78 |
</mat-dialog-actions>
|
|
|
106 |
})
|
107 |
export default class ConfirmDialogComponent {
|
108 |
selectedVersionId: number | null = null;
|
109 |
+
selectedValue: any = undefined;
|
110 |
|
111 |
constructor(
|
112 |
public dialogRef: MatDialogRef<ConfirmDialogComponent>,
|
|
|
116 |
if (data.showVersionSelect && data.versions && data.versions.length > 0) {
|
117 |
this.selectedVersionId = data.versions[0].id;
|
118 |
}
|
119 |
+
|
120 |
+
// Initialize dropdown to null (not undefined) to show "None" option selected
|
121 |
+
if (data.showDropdown) {
|
122 |
+
this.selectedValue = null;
|
123 |
+
}
|
124 |
}
|
125 |
|
126 |
onConfirm(): void {
|
127 |
if (this.data.showVersionSelect) {
|
128 |
this.dialogRef.close(this.selectedVersionId);
|
129 |
+
} else if (this.data.showDropdown) {
|
130 |
+
this.dialogRef.close({ confirmed: true, selectedValue: this.selectedValue });
|
131 |
} else {
|
132 |
this.dialogRef.close(true);
|
133 |
}
|