You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

38 lines
2.2 KiB

<h2 mat-dialog-title>{{ (id ? 'shared.operation.edit' : 'shared.operation.add') | translate }}</h2>
<div mat-dialog-content>
<form autocomplete="off" [formGroup]="form" class="form">
<ng-container *ngFor="let item of fields | sort: 'order'">
<ng-template [ngTemplateOutlet]="item.template" [ngTemplateOutletContext]="{ $implicit: form, form: form, field: item, data: data }" *ngIf="item.template;else $control"></ng-template>
<ng-template #$control [ngSwitch]="item.type">
<mat-form-field class="" *ngSwitchCase="'text'">
<mat-label>{{ item.label | translate }}</mat-label>
<input matInput [formControlName]="item.id" [required]="item.required">
</mat-form-field>
<mat-form-field *ngSwitchCase="'number'">
<mat-label>{{ item.label | translate }}</mat-label>
<input type="number" matInput [formControlName]="item.id" [min]="item.range && item.range[0]" [max]="item.range && item.range[1]" [required]="item.required">
</mat-form-field>
<mat-form-field *ngSwitchCase="'select'">
<mat-label>{{ item.label | translate }}</mat-label>
<mat-select [formControlName]="item.id" [required]="item.required">
<mat-option *ngFor="let i of item.range" [value]="i.id">{{i.name}}</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field *ngSwitchCase="'multi-select'">
<mat-label>{{ item.label | translate }}</mat-label>
<mat-select [formControlName]="item.id" [required]="item.required" multiple>
<mat-option *ngFor="let i of item.range" [value]="i.id">{{i.name}}</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field *ngSwitchDefault>
<mat-label>{{ item.label | translate }}</mat-label>
<input matInput [formControlName]="item.id" [required]="item.required">
</mat-form-field>
</ng-template>
</ng-container>
</form>
</div>
<div mat-dialog-actions align="end">
<button mat-button color="primary" [disabled]="form.invalid" (click)="save()">{{ 'shared.dialog.ok' | translate | uppercase }}</button>
<button mat-button mat-dialog-close>{{ 'shared.dialog.cancel' | translate | uppercase }}</button>
</div>