Browse Source

Added tags to query editor.

pull/448/head
Sebastian 6 years ago
parent
commit
33244550bb
  1. 20
      frontend/app/shared/components/queries/filter-comparison.component.html
  2. 12
      frontend/app/shared/state/query.ts

20
frontend/app/shared/components/queries/filter-comparison.component.html

@ -1,16 +1,15 @@
<div class="row"> <div class="row no-gutters mb-1" *ngIf="fieldModel">
<div class="col"> <div class="col-auto path">
<div class="form-inline"> <select class="form-control" [ngModel]="filter.path" (ngModelChange)="changePath($event)">
<select class="form-control path mb-1 mr-2" [ngModel]="filter.path" (ngModelChange)="changePath($event)">
<option *ngFor="let fieldName of model.fields | sqxKeys" [ngValue]="fieldName">{{fieldName}}</option> <option *ngFor="let fieldName of model.fields | sqxKeys" [ngValue]="fieldName">{{fieldName}}</option>
</select> </select>
</div>
<ng-container *ngIf="fieldModel"> <div class="col-auto pl-2">
<select class="form-control mb-1 mr-2" [ngModel]="filter.op" (ngModelChange)="changeOp($event)"> <select class="form-control" [ngModel]="filter.op" (ngModelChange)="changeOp($event)">
<option *ngFor="let operator of fieldModel.operators" [ngValue]="operator.value">{{operator.name || operator.value}}</option> <option *ngFor="let operator of fieldModel.operators" [ngValue]="operator.value">{{operator.name || operator.value}}</option>
</select> </select>
</div>
<div class="mb-1" *ngIf="!noValue" [ngSwitch]="fieldModel.type"> <div class="col pl-2" *ngIf="!noValue" [ngSwitch]="fieldModel.type">
<ng-container *ngSwitchCase="'boolean'"> <ng-container *ngSwitchCase="'boolean'">
<input type="checkbox" class="form-control" <input type="checkbox" class="form-control"
[ngModel]="filter.value" [ngModel]="filter.value"
@ -57,9 +56,6 @@
(ngModelChange)="changeValue($event)" /> (ngModelChange)="changeValue($event)" />
</ng-container> </ng-container>
</div> </div>
</ng-container>
</div>
</div>
<div class="col-auto pl-2"> <div class="col-auto pl-2">
<button type="button" class="btn btn-text-danger" (click)="emitRemove()"> <button type="button" class="btn btn-text-danger" (click)="emitRemove()">
<i class="icon-bin2"></i> <i class="icon-bin2"></i>

12
frontend/app/shared/state/query.ts

@ -20,7 +20,8 @@ export type QueryValueType =
'number' | 'number' |
'reference' | 'reference' |
'status' | 'status' |
'string'; 'string' |
'tags';
export interface FilterOperator { export interface FilterOperator {
// The optional display value. // The optional display value.
@ -171,6 +172,11 @@ const TypeString: QueryFieldModel = {
operators: [...EqualOperators, ...CompareOperator, ...StringOperators, ...ArrayOperators] operators: [...EqualOperators, ...CompareOperator, ...StringOperators, ...ArrayOperators]
}; };
const TypeTags: QueryFieldModel = {
type: 'string',
operators: EqualOperators
};
export function queryModelFromSchema(schema: SchemaDetailsDto, languages: ReadonlyArray<LanguageDto>, statuses: ReadonlyArray<StatusInfo> | undefined) { export function queryModelFromSchema(schema: SchemaDetailsDto, languages: ReadonlyArray<LanguageDto>, statuses: ReadonlyArray<StatusInfo> | undefined) {
const languagesCodes = languages.map(x => x.iso2Code); const languagesCodes = languages.map(x => x.iso2Code);
@ -193,7 +199,9 @@ export function queryModelFromSchema(schema: SchemaDetailsDto, languages: Readon
for (const field of schema.fields) { for (const field of schema.fields) {
let type: QueryFieldModel | null = null; let type: QueryFieldModel | null = null;
if (field.properties.fieldType === 'Boolean') { if (field.properties.fieldType === 'Tags') {
type = TypeTags;
} else if (field.properties.fieldType === 'Boolean') {
type = TypeBoolean; type = TypeBoolean;
} else if (field.properties.fieldType === 'Number') { } else if (field.properties.fieldType === 'Number') {
type = TypeNumber; type = TypeNumber;

Loading…
Cancel
Save