From 78b9458f509692af9b1cf9a02bf597678f00c663 Mon Sep 17 00:00:00 2001 From: Angapay Divin <divin.angapay@lam.fr> Date: Fri, 3 Jun 2022 10:30:54 +0200 Subject: [PATCH] datalist search type :move null and not null in operator select list, and manage no dynamic operator case --- .../criteria/search-type/checkbox.component.html | 6 +++++- .../criteria/search-type/checkbox.component.ts | 10 ++++++++++ .../criteria/search-type/datalist.component.html | 2 +- .../criteria/search-type/datalist.component.ts | 13 ++++++++++++- 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/client/src/app/instance/search/components/criteria/search-type/checkbox.component.html b/client/src/app/instance/search/components/criteria/search-type/checkbox.component.html index 936cd878..2a0fb789 100644 --- a/client/src/app/instance/search/components/criteria/search-type/checkbox.component.html +++ b/client/src/app/instance/search/components/criteria/search-type/checkbox.component.html @@ -1,7 +1,11 @@ <form [formGroup]="form" novalidate> <div class="row form-group"> <div class="col-md-3 col-sm-auto pr-sm-1 mb-1 mb-lg-0"> - <div class="operator_readonly">in</div> + <select class="custom-select" (change)="labelOnChange($event.target.value)"> + <option [value]="">In</option> + <option [value]="'nl'">Null</option> + <option [value]="'nnl'">Not Null</option> + </select> </div> <div class="w-100 d-block d-sm-none"></div> <div class="col pl-sm-1" formArrayName="checkboxes"> diff --git a/client/src/app/instance/search/components/criteria/search-type/checkbox.component.ts b/client/src/app/instance/search/components/criteria/search-type/checkbox.component.ts index 8d9b1b07..c94a23eb 100644 --- a/client/src/app/instance/search/components/criteria/search-type/checkbox.component.ts +++ b/client/src/app/instance/search/components/criteria/search-type/checkbox.component.ts @@ -77,4 +77,14 @@ export class CheckboxComponent extends AbstractSearchTypeComponent { // If one of the checkboxes is checked returns true else returns false return this.getCheckboxes().controls.filter(formControl => formControl.value).length > 0; } + + labelOnChange(value: string) { + if (value === 'nl' || value === 'nnl') { + this.nullOrNotNull = value; + + } else { + this.nullOrNotNull = ''; + + } + } } diff --git a/client/src/app/instance/search/components/criteria/search-type/datalist.component.html b/client/src/app/instance/search/components/criteria/search-type/datalist.component.html index 0044b68c..e0f39d83 100644 --- a/client/src/app/instance/search/components/criteria/search-type/datalist.component.html +++ b/client/src/app/instance/search/components/criteria/search-type/datalist.component.html @@ -1,7 +1,7 @@ <form [formGroup]="form" novalidate> <div class="row form-group"> <div class="col-md-3 col-sm-auto pr-sm-1 mb-1 mb-sm-0"> - <select class="custom-select" formControlName="operator"> + <select class="custom-select" formControlName="operator" (change)="operatorOnChange()"> <option *ngFor="let o of operators" [ngValue]="o.value">{{ o.label }}</option> </select> </div> diff --git a/client/src/app/instance/search/components/criteria/search-type/datalist.component.ts b/client/src/app/instance/search/components/criteria/search-type/datalist.component.ts index ccbc14a5..81e6a673 100644 --- a/client/src/app/instance/search/components/criteria/search-type/datalist.component.ts +++ b/client/src/app/instance/search/components/criteria/search-type/datalist.component.ts @@ -3,6 +3,7 @@ import { FormGroup, FormControl, Validators } from '@angular/forms'; import { AbstractSearchTypeComponent } from './abstract-search-type.component'; import { Criterion, FieldCriterion } from 'src/app/instance/store/models'; +import { searchTypeOperators } from 'src/app/shared/utils'; @Component({ selector: 'app-datalist', @@ -22,7 +23,9 @@ export class DatalistComponent extends AbstractSearchTypeComponent { if (!criterion) { this.form.controls.operator.setValue(this.attribute.operator); if (!this.attribute.dynamic_operator) { - this.form.controls.operator.disable(); + this.operators = searchTypeOperators.filter( + operator => [this.attribute.operator, 'nl', 'nnl'].includes(operator.value) + ); } } } @@ -72,4 +75,12 @@ export class DatalistComponent extends AbstractSearchTypeComponent { getDatalistId(): string { return `datalist_${this.attribute.id}`; } + operatorOnChange() { + if (this.form.controls.operator.value === 'nl' || this.form.controls.operator.value === 'nnl') { + this.form.controls.value.disable(); + } else { + this.form.controls.value.enable(); + } + } + } -- GitLab