Skip to content

Commit

Permalink
Added new "hidden" field type for data source settings (#1008)
Browse files Browse the repository at this point in the history
  • Loading branch information
ushahidlee authored Apr 17, 2024
1 parent 4523b59 commit 23a19f4
Showing 1 changed file with 57 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,58 +135,66 @@ <h2>{{ 'survey.choose_survey_field' | translate }}</h2>
<br />

<div *ngFor="let control of provider?.options" [data-qa]="'provider-options'">
<ng-container *ngIf="control.input === 'read-only-text'">
<h2 *ngIf="control.label?.length">{{ control.label }}</h2>
<p *ngIf="control.description?.length" [innerHTML]="control.description"></p>
</ng-container>

<ng-container *ngIf="control.input !== 'read-only-text'">
<div class="form-row">
<mat-label>
{{ control.label }}
<span class="color-accent" *ngIf="control.rules?.indexOf('required') > -1">*</span>
</mat-label>
<mat-form-field
*ngIf="control.input === 'text'"
appearance="outline"
[data-qa]="'control-type-text'"
>
<input
matInput
[placeholder]="control.description"
[formControlName]="control.id"
[type]="control.input"
[data-qa]="'control-text' + control.id"
/>
<mat-hint
*ngIf="control.description?.length"
[innerHTML]="control.description"
></mat-hint>
<mat-error
*ngIf="
(form.get(control.id)?.touched || form.get(control.id)?.dirty) &&
form.get(control.id)?.hasError('required')
"
<ng-container [ngSwitch]="control.input">
<ng-container *ngSwitchCase="'read-only-text'">
<h2 *ngIf="control.label?.length">{{ control.label }}</h2>
<p *ngIf="control.description?.length" [innerHTML]="control.description"></p>
</ng-container>
<ng-container *ngSwitchCase="'hidden'">
<input
[formControlName]="control.id"
type="hidden"
[data-qa]="'control-text' + control.id"
/>
</ng-container>
<ng-container *ngSwitchDefault>
<div class="form-row">
<mat-label>
{{ control.label }}
<span class="color-accent" *ngIf="control.rules?.indexOf('required') > -1">*</span>
</mat-label>
<mat-form-field
*ngIf="control.input === 'text'"
appearance="outline"
[data-qa]="'control-type-text'"
>
{{ 'form.field_required' | translate }}
</mat-error>
</mat-form-field>
<input
matInput
[placeholder]="control.description"
[formControlName]="control.id"
[type]="control.input"
[data-qa]="'control-text' + control.id"
/>
<mat-hint
*ngIf="control.description?.length"
[innerHTML]="control.description"
></mat-hint>
<mat-error
*ngIf="
(form.get(control.id)?.touched || form.get(control.id)?.dirty) &&
form.get(control.id)?.hasError('required')
"
>
{{ 'form.field_required' | translate }}
</mat-error>
</mat-form-field>

<mat-radio-group
*ngIf="control.input === 'radio'"
aria-label="Select an option"
[formControlName]="control.id"
[data-qa]="'control-type-radio'"
>
<mat-radio-button
*ngFor="let item of control.options"
[value]="item"
[data-qa]="'control-text' + item"
<mat-radio-group
*ngIf="control.input === 'radio'"
aria-label="Select an option"
[formControlName]="control.id"
[data-qa]="'control-type-radio'"
>
{{ item }}
</mat-radio-button>
</mat-radio-group>
</div>
<mat-radio-button
*ngFor="let item of control.options"
[value]="item"
[data-qa]="'control-text' + item"
>
{{ item }}
</mat-radio-button>
</mat-radio-group>
</div>
</ng-container>
</ng-container>
</div>

Expand Down

0 comments on commit 23a19f4

Please sign in to comment.