122 lines
5.8 KiB
HTML
122 lines
5.8 KiB
HTML
<!-- <div [formGroup]="form" class="form-group">
|
|
|
|
|
|
<label [attr.for]="field.key">{{field.label}}</label>
|
|
|
|
<div [ngSwitch]="field.controlType">
|
|
|
|
|
|
<input *ngSwitchCase="'textbox'" class ="form-control" [formControlName]="field.key"
|
|
[id]="field.key" [type]="field.type" required ="field.required">
|
|
|
|
|
|
<select [id]="field.key" *ngSwitchCase="'dropdown'" class ="form-control" [formControlName]="field.key">
|
|
<option *ngFor="let opt of field.options" [value]="opt.key">{{opt.value}}</option>
|
|
</select>
|
|
|
|
|
|
<input *ngSwitchCase="'checkbox'" [formControlName]="field.key" [(ngModel)]="field.value"
|
|
[id]="field.key" [type]="field.type" (change)="field.value = ckb.checked" #ckb>
|
|
|
|
|
|
</div>
|
|
|
|
<div class="alert alert-danger" *ngIf="!isValid">{{field.label}} is required</div>
|
|
|
|
|
|
</div> -->
|
|
|
|
<div [formGroup]="form" class="form-group" [ngSwitch]="field.controlType">
|
|
<div [ngClass]="{true:'show', false:'hide'}[field.visible]">
|
|
|
|
<label *ngIf="field.controlType != 'checkbox'" [attr.for]="field.key">{{field.label}}</label>
|
|
<div>{{field.description}}</div>
|
|
|
|
<input *ngSwitchCase="'textbox'" class="form-control" [formControlName]="field.key" [id]="field.key" [type]="field.type"
|
|
[required]="field.required" [pattern] = "field.regex" (ngModelChange) = "toggleVisibility($event, field,false)"> <!--input or change event
|
|
on change event the listener is triggered on blur -->
|
|
|
|
<div *ngSwitchCase="'dropdown'">
|
|
<autocomplete-remote *ngIf="field.url" [form]="form" [formCtrlName]="field.key" [url]="field.url" ></autocomplete-remote>
|
|
<select *ngIf="!field.url" class="form-control" [id]="field.key" [formControlName]="field.key" [required]="field.required" (change)="toggleVisibility($event, field, false)">
|
|
<option *ngFor="let opt of field.options" [value]="opt._value" >{{opt._label}}</option>
|
|
</select>
|
|
</div>
|
|
|
|
|
|
<div *ngSwitchCase="'checkbox'" class="checkbox">
|
|
<label class="checkBoxLabelCustom">
|
|
<input *ngSwitchCase="'checkbox'" class="form-check" [formControlName]="field.key" [type]="field.type"
|
|
(change)="toggleVisibility($event, field, true)" [required]="field.required" [checked]="form.get(field.key).value">{{field.label}} <!--(change)="field.value = ckb.checked" has moved into the toggleVisibility
|
|
// without property [checked] as pages change the checkboxes of the previous pages lose the checked pro [checked] = "field.value" #ckb -->
|
|
</label>
|
|
</div>
|
|
|
|
|
|
<textarea *ngSwitchCase="'textarea'" class="form-control" [formControlName]="field.key" [id]="field.key"
|
|
[required]="field.required" (ngModelChange) = "toggleVisibility($event, field,false)"> </textarea>
|
|
|
|
<div *ngSwitchCase="'radiobox'">
|
|
<ng-container *ngFor="let answrBase of field.answers">
|
|
<div style="display: inline-block;margin-right:10px;" [id]="field.key">
|
|
<label for="{{answrBase.id}}" style="padding: 8px 10px; padding-right:5px;">{{answrBase.answer}}</label>
|
|
<input type="radio" [formControlName]="field.key" [id]= "answrBase.id" [value]= "answrBase.value" [(ngModel)]="field.value" (change) = "toggleVisibility($event, field,false)" [required]="field.required"/>
|
|
</div>
|
|
</ng-container>
|
|
</div>
|
|
</div>
|
|
|
|
<div *ngSwitchCase="'label'"> </div>
|
|
|
|
|
|
<div [hidden]="isValid">
|
|
<div class="invalid-feedbackCustom" *ngIf="isValidRequired">The field "{{field.label}}" is required</div>
|
|
<div class="invalid-feedbackCustom" *ngIf="isValidPattern">The field {{field.label}} must match a regular expression {{field.regex}}</div>
|
|
<div class="invalid-feedbackCustom" *ngIf="isValidCustom">The field {{field.label}} custom Validation</div>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
<!-- <div [formGroup]="form" class="form-group" [ngSwitch]="field.controlType">
|
|
<div *ngIf= "field.rules; else elseBlock ">
|
|
<div *ngIf="field.rules.length > 0; else elseBlock">
|
|
<div *ngFor="let rule of field.rules">
|
|
<div *ngIf="rule._type == 'fieldVisible'; else otherRuleBlock">
|
|
<div hidden="{{ruleVisibleMethod(field, rule, dataModel)}}">
|
|
<label [attr.for]="field.key">{{field.label}}</label>
|
|
|
|
<input *ngSwitchCase="'textbox'" class="form-control" [formControlName]="field.key" [id]="field.key" [type]="field.type"
|
|
required="field.required">
|
|
|
|
<select [id]="field.key" *ngSwitchCase="'dropdown'" class="form-control" [formControlName]="field.key">
|
|
<option *ngFor="let opt of field.options" [value]="opt.key">{{opt.value}}</option>
|
|
</select>
|
|
|
|
<input *ngSwitchCase="'checkbox'" [formControlName]="field.key" [(ngModel)]="field.value" [id]="field.key" [type]="field.type"
|
|
(change)="field.value = ckb.checked" #ckb>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<ng-template #elseBlock>
|
|
<label [attr.for]="field.key">{{field.label}}</label>
|
|
<input *ngSwitchCase="'textbox'" class="form-control" [formControlName]="field.key" [id]="field.key" [type]="field.type"
|
|
required="field.required">
|
|
|
|
<select [id]="field.key" *ngSwitchCase="'dropdown'" class="form-control" [formControlName]="field.key">
|
|
<option *ngFor="let opt of field.options" [value]="opt.key">{{opt.value}}</option>
|
|
</select>
|
|
|
|
<input *ngSwitchCase="'checkbox'" [formControlName]="field.key" [(ngModel)]="field.value" [id]="field.key" [type]="field.type"
|
|
(change)="field.value = ckb.checked" #ckb>
|
|
|
|
</ng-template>
|
|
|
|
<ng-template #otherRuleBlock>
|
|
|
|
</ng-template>
|
|
|
|
</div> --> |