Spaces:
Paused
Paused
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
|
@@ -1,7 +1,10 @@
|
|
| 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;
|
|
@@ -9,20 +12,48 @@ export interface ConfirmDialogData {
|
|
| 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: [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
|
|
|
|
|
|
|
|
|
| 26 |
{{ data.confirmText || 'Confirm' }}
|
| 27 |
</button>
|
| 28 |
</mat-dialog-actions>
|
|
@@ -30,27 +61,49 @@ export interface ConfirmDialogData {
|
|
| 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.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
}
|
| 55 |
|
| 56 |
onCancel(): void {
|
|
|
|
| 1 |
import { Component, Inject } from '@angular/core';
|
| 2 |
import { CommonModule } from '@angular/common';
|
| 3 |
+
import { FormsModule } from '@angular/forms';
|
| 4 |
import { MatDialogRef, MAT_DIALOG_DATA, MatDialogModule } from '@angular/material/dialog';
|
| 5 |
import { MatButtonModule } from '@angular/material/button';
|
| 6 |
+
import { MatSelectModule } from '@angular/material/select';
|
| 7 |
+
import { MatFormFieldModule } from '@angular/material/form-field';
|
| 8 |
|
| 9 |
export interface ConfirmDialogData {
|
| 10 |
title: string;
|
|
|
|
| 12 |
confirmText?: string;
|
| 13 |
cancelText?: string;
|
| 14 |
confirmColor?: 'primary' | 'accent' | 'warn';
|
| 15 |
+
showVersionSelect?: boolean;
|
| 16 |
+
versions?: any[];
|
| 17 |
}
|
| 18 |
|
| 19 |
@Component({
|
| 20 |
selector: 'app-confirm-dialog',
|
| 21 |
standalone: true,
|
| 22 |
+
imports: [
|
| 23 |
+
CommonModule,
|
| 24 |
+
FormsModule,
|
| 25 |
+
MatDialogModule,
|
| 26 |
+
MatButtonModule,
|
| 27 |
+
MatSelectModule,
|
| 28 |
+
MatFormFieldModule
|
| 29 |
+
],
|
| 30 |
template: `
|
| 31 |
<h2 mat-dialog-title>{{ data.title }}</h2>
|
| 32 |
<mat-dialog-content>
|
| 33 |
<p>{{ data.message }}</p>
|
| 34 |
+
|
| 35 |
+
@if (data.showVersionSelect && data.versions) {
|
| 36 |
+
<mat-form-field appearance="outline" class="full-width">
|
| 37 |
+
<mat-label>Select Source Version</mat-label>
|
| 38 |
+
<mat-select [(ngModel)]="selectedVersionId" required>
|
| 39 |
+
@for (version of data.versions; track version.id) {
|
| 40 |
+
<mat-option [value]="version.id">
|
| 41 |
+
Version {{ version.id }} - {{ version.caption }}
|
| 42 |
+
@if (version.published) {
|
| 43 |
+
<span class="published-badge">(Published)</span>
|
| 44 |
+
}
|
| 45 |
+
</mat-option>
|
| 46 |
+
}
|
| 47 |
+
</mat-select>
|
| 48 |
+
</mat-form-field>
|
| 49 |
+
}
|
| 50 |
</mat-dialog-content>
|
| 51 |
<mat-dialog-actions align="end">
|
| 52 |
<button mat-button (click)="onCancel()">{{ data.cancelText || 'Cancel' }}</button>
|
| 53 |
+
<button mat-raised-button
|
| 54 |
+
[color]="data.confirmColor || 'primary'"
|
| 55 |
+
(click)="onConfirm()"
|
| 56 |
+
[disabled]="data.showVersionSelect && !selectedVersionId">
|
| 57 |
{{ data.confirmText || 'Confirm' }}
|
| 58 |
</button>
|
| 59 |
</mat-dialog-actions>
|
|
|
|
| 61 |
styles: [`
|
| 62 |
mat-dialog-content {
|
| 63 |
padding: 20px 24px;
|
| 64 |
+
min-width: 400px;
|
| 65 |
}
|
| 66 |
|
| 67 |
p {
|
| 68 |
+
margin: 0 0 16px 0;
|
| 69 |
color: rgba(0,0,0,0.87);
|
| 70 |
line-height: 1.5;
|
| 71 |
}
|
| 72 |
|
| 73 |
+
.full-width {
|
| 74 |
+
width: 100%;
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
.published-badge {
|
| 78 |
+
color: #4caf50;
|
| 79 |
+
font-weight: 500;
|
| 80 |
+
margin-left: 8px;
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
mat-dialog-actions {
|
| 84 |
padding: 16px 24px;
|
| 85 |
}
|
| 86 |
`]
|
| 87 |
})
|
| 88 |
export default class ConfirmDialogComponent {
|
| 89 |
+
selectedVersionId: number | null = null;
|
| 90 |
+
|
| 91 |
constructor(
|
| 92 |
public dialogRef: MatDialogRef<ConfirmDialogComponent>,
|
| 93 |
@Inject(MAT_DIALOG_DATA) public data: ConfirmDialogData
|
| 94 |
+
) {
|
| 95 |
+
// Pre-select first version if available
|
| 96 |
+
if (data.showVersionSelect && data.versions && data.versions.length > 0) {
|
| 97 |
+
this.selectedVersionId = data.versions[0].id;
|
| 98 |
+
}
|
| 99 |
+
}
|
| 100 |
|
| 101 |
onConfirm(): void {
|
| 102 |
+
if (this.data.showVersionSelect) {
|
| 103 |
+
this.dialogRef.close(this.selectedVersionId);
|
| 104 |
+
} else {
|
| 105 |
+
this.dialogRef.close(true);
|
| 106 |
+
}
|
| 107 |
}
|
| 108 |
|
| 109 |
onCancel(): void {
|