refactor: rename components and update dialog implementations; add confirm dialog for deletion actions
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
<form [formGroup]="form" (ngSubmit)="save()">
|
||||
<h2 mat-dialog-title>{{ data?.title ?? 'Edit' }}</h2>
|
||||
|
||||
<mat-dialog-content>
|
||||
@for (f of (fields ?? []); track $index) {
|
||||
|
||||
@if (f.type === 'checkbox') {
|
||||
<mat-checkbox [formControlName]="f.key">
|
||||
{{ f.label }}
|
||||
</mat-checkbox>
|
||||
} @else if (f.type === 'select') {
|
||||
<mat-form-field style="width:100%; margin-top:8px;">
|
||||
<mat-label>{{ f.label }}</mat-label>
|
||||
|
||||
<mat-select [formControlName]="f.key">
|
||||
@let opts = (f.options ?? (f.options$ | async) ?? []);
|
||||
|
||||
@for (opt of opts; track $index) {
|
||||
<mat-option [value]="f.valueKey ? opt?.[f.valueKey] : opt">
|
||||
{{ f.displayKey ? opt?.[f.displayKey] : (opt?.name ?? opt?.label ?? opt) }}
|
||||
</mat-option>
|
||||
}
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
} @else {
|
||||
<mat-form-field style="width:100%; margin-top:8px;">
|
||||
<mat-label>{{ f.label }}</mat-label>
|
||||
|
||||
@if (f.type === 'textarea') {
|
||||
<textarea matInput [formControlName]="f.key"></textarea>
|
||||
} @else {
|
||||
<input
|
||||
matInput
|
||||
[type]="f.type ?? 'text'"
|
||||
[formControlName]="f.key"
|
||||
/>
|
||||
}
|
||||
</mat-form-field>
|
||||
}
|
||||
|
||||
}
|
||||
</mat-dialog-content>
|
||||
|
||||
<mat-dialog-actions align="end">
|
||||
<button mat-button type="button" (click)="close()">Annuler</button>
|
||||
<button mat-flat-button color="primary" type="submit">Enregistrer</button>
|
||||
</mat-dialog-actions>
|
||||
</form>
|
||||
Reference in New Issue
Block a user