Skip to content

Commit

Permalink
Conditionally show language picker
Browse files Browse the repository at this point in the history
  • Loading branch information
JeltevanBoheemen committed Oct 1, 2024
1 parent bdf4ce6 commit a10906e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ <h1 class="title">Fields</h1>
<p-dropdown [options]="fieldTypeOptions" formControlName="type" optionLabel="label" optionValue="value"
placeholder="select type" />
</div>
<p *ngIf="helpText(field) as help" class="help">{{help}}</p>
<p *ngIf="getFieldProperty(field, 'helpText') as help" class="help">{{help}}</p>
</div>

<div class="field">
Expand Down Expand Up @@ -54,7 +54,7 @@ <h1 class="title">Fields</h1>
</div>
</ng-container>
</div>
<div class="field">
<div *ngIf="getFieldProperty(field, 'hasLanguage')" class="field">
<div class="control">
<p-dropdown [options]="languageOptions" formControlName="language" optionLabel="name" optionValue="code"
placeholder="select language (optional)" [filter]="true" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,24 @@ export class FieldFormComponent {
{
label: 'text (content)',
value: 'text_content',
tooltip:
helpText:
'Main document text. Can consist of multiple paragraphs. Can be used to search.',
hasLanguage: true,
},
{
label: 'text (metadata)',
value: 'text_metadata',
tooltip:
helpText:
'Metadata text. Limited to a single paragraph. Can be used to filter and/or search.',
hasLanguage: true,
},
{ label: 'number (integer)', value: 'integer' },
{ label: 'number (decimal)', value: 'float' },
{ label: 'date', value: 'date' },
{
label: 'boolean',
value: 'boolean',
tooltip: 'True/false field. Can be used to filter.',
helpText: 'True/false field. Can be used to filter.',
},
];

Expand Down Expand Up @@ -78,11 +80,10 @@ export class FieldFormComponent {
return fg;
}

helpText(field: FormGroup): string | undefined {
getFieldProperty(field: FormGroup, prop: string) {
const fieldType = field.get('type').value;
return _.find(this.fieldTypeOptions, {
value: fieldType,
}).tooltip;
const option = _.find(this.fieldTypeOptions, { value: fieldType });
return option[prop];
}

ngOnChanges(changes: SimpleChanges): void {
Expand Down

0 comments on commit a10906e

Please sign in to comment.