49 lines
1.5 KiB
HTML
49 lines
1.5 KiB
HTML
<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>
|