diff --git a/client/src/app/instance/search/components/criteria/search-type/between-date.component.html b/client/src/app/instance/search/components/criteria/search-type/between-date.component.html index 99ece1107ac9d47ec345d4f9a23e3c0b6f213aab..7b8dc70369502a202ceee754b392185ec92747fb 100644 --- a/client/src/app/instance/search/components/criteria/search-type/between-date.component.html +++ b/client/src/app/instance/search/components/criteria/search-type/between-date.component.html @@ -1,8 +1,8 @@ <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" (change)="labelOnChange($event.target.value)"> - <option [value]="">Bw</option> + <select class="custom-select" (change)="labelOnChange()" formControlName ="label"> + <option [value]="'Bw'">Bw</option> <option [value]="'nl'">Null</option> <option [value]="'nnl'">Not Null</option> </select> diff --git a/client/src/app/instance/search/components/criteria/search-type/between-date.component.ts b/client/src/app/instance/search/components/criteria/search-type/between-date.component.ts index f7f973bf725bc5fb52d49ff978510dc38f7fab6d..ae689cc90d73e9d1658705d40a1c869443b5f4a5 100644 --- a/client/src/app/instance/search/components/criteria/search-type/between-date.component.ts +++ b/client/src/app/instance/search/components/criteria/search-type/between-date.component.ts @@ -13,19 +13,21 @@ export class BetweenDateComponent extends AbstractSearchTypeComponent { super(); this.form = new FormGroup({ dateRange: new FormControl('', [Validators.required]), + label: new FormControl() }); + } setCriterion(criterion: Criterion) { super.setCriterion(criterion); - - + this.form.controls.label.setValue('Bw'); if (criterion) { const betweenCriterion = criterion as BetweenCriterion; this.form.controls.dateRange.setValue([ new Date(betweenCriterion.min), new Date(betweenCriterion.max) ]); + } } @@ -53,9 +55,9 @@ export class BetweenDateComponent extends AbstractSearchTypeComponent { * * @return string */ - labelOnChange(value: string) { - if (value === 'nl' || value === 'nnl') { - this.nullOrNotNull = value; + labelOnChange() { + if (this.form.controls.label.value === 'nl' || this.form.controls.label.value === 'nnl') { + this.nullOrNotNull = this.form.controls.label.value ; this.form.controls.dateRange.disable(); } else { this.nullOrNotNull = ''; @@ -68,4 +70,5 @@ export class BetweenDateComponent extends AbstractSearchTypeComponent { const day = ('0' + (date.getDate())).slice(-2); return `${date.getFullYear()}-${month}-${day}`; } + } diff --git a/client/src/app/instance/search/components/criteria/search-type/between.component.html b/client/src/app/instance/search/components/criteria/search-type/between.component.html index f1438d59b83917d85868e982c9087b3b71634d60..6e74e24441f9ba3b58340807806a2bc5bca87d98 100644 --- a/client/src/app/instance/search/components/criteria/search-type/between.component.html +++ b/client/src/app/instance/search/components/criteria/search-type/between.component.html @@ -1,8 +1,8 @@ <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" (change)="labelOnChange($event.target.value)"> - <option [value]="">Min/Max</option> + <select class="custom-select" (change)="labelOnChange()" formControlName="label"> + <option [value]="'Min/Max'">Min/Max</option> <option [value]="'nl'">Null</option> <option [value]="'nnl'">Not Null</option> </select> diff --git a/client/src/app/instance/search/components/criteria/search-type/between.component.ts b/client/src/app/instance/search/components/criteria/search-type/between.component.ts index bc0649a74a5abef098638f142d5a60e83c192bc0..0a2a83168ecdfeccb0a830e07ada13676c5d7939 100644 --- a/client/src/app/instance/search/components/criteria/search-type/between.component.ts +++ b/client/src/app/instance/search/components/criteria/search-type/between.component.ts @@ -1,4 +1,4 @@ -import { Component } from '@angular/core'; +import { Component, OnInit } from '@angular/core'; import { FormGroup, FormControl, Validators } from '@angular/forms'; import { AbstractSearchTypeComponent } from './abstract-search-type.component'; @@ -8,15 +8,23 @@ import { Criterion, BetweenCriterion } from 'src/app/instance/store/models'; selector: 'app-between', templateUrl: 'between.component.html' }) -export class BetweenComponent extends AbstractSearchTypeComponent { +export class BetweenComponent extends AbstractSearchTypeComponent implements OnInit { + + constructor() { super(); this.form = new FormGroup({ min: new FormControl('', [Validators.required]), - max: new FormControl('', [Validators.required]) + max: new FormControl('', [Validators.required]), + label: new FormControl('') }); - } + + } + ngOnInit(): void { + this.form.controls.label.setValue("Min/Max"); + } + /** * Return new criterion * @@ -42,9 +50,9 @@ export class BetweenComponent extends AbstractSearchTypeComponent { return this.attribute.placeholder_min; } } - labelOnChange(value: string) { - if (value === 'nl' || value === 'nnl') { - this.nullOrNotNull = value; + labelOnChange() { + if (this.form.controls.label.value === 'nl' || this.form.controls.label.value === 'nnl') { + this.nullOrNotNull = this.form.controls.label.value; this.form.controls.min.disable(); this.form.controls.max.disable(); } else { @@ -74,5 +82,12 @@ export class BetweenComponent extends AbstractSearchTypeComponent { isValid() { return this.form.controls.min.value || this.form.controls.max.value; } + + enable() { + super.enable(); + if (this.criteriaList) { + this.form.controls.label.disable(); + } + } } 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 2a0fb789b9cff61ea1cc5b084ef41931a3a3920f..e524f73683f6a36783fa76ff683572817b629037 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,7 @@ <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"> - <select class="custom-select" (change)="labelOnChange($event.target.value)"> + <select class="custom-select" (change)="labelOnChange()" formControlName="label"> <option [value]="">In</option> <option [value]="'nl'">Null</option> <option [value]="'nnl'">Not Null</option> 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 c94a23eb8b1f264a0dd36faeea0f36773fc0fa7f..7eb30b45f75810c6beb7745b3f18e904e4d46fc3 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 @@ -13,7 +13,9 @@ import { Attribute } from 'src/app/metamodel/models'; export class CheckboxComponent extends AbstractSearchTypeComponent { constructor() { super(); - this.form = new FormGroup({}); + this.form = new FormGroup({ + label: new FormControl('') + }); } setAttribute(attribute: Attribute): void { @@ -78,12 +80,18 @@ export class CheckboxComponent extends AbstractSearchTypeComponent { return this.getCheckboxes().controls.filter(formControl => formControl.value).length > 0; } - labelOnChange(value: string) { - if (value === 'nl' || value === 'nnl') { - this.nullOrNotNull = value; + labelOnChange() { + if (this.form.controls.label.value === 'nl' || this.form.controls.label.value === 'nnl') { + + this.getCheckboxes().controls.map((value, index)=>{ + value.disable(); + }) } else { this.nullOrNotNull = ''; + this.getCheckboxes().controls.map((value, index)=>{ + value.enable(); + }) } } diff --git a/client/src/app/instance/search/components/criteria/search-type/list.component.html b/client/src/app/instance/search/components/criteria/search-type/list.component.html index 5e36555e6bd91bd72eec07b08b8809b60ea19bcb..5f53e5f1098358df5b6678bd81b849307c23c9c7 100644 --- a/client/src/app/instance/search/components/criteria/search-type/list.component.html +++ b/client/src/app/instance/search/components/criteria/search-type/list.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-lg-0"> - <select class="custom-select" (change)="labelOnChange($event.target.value)"> + <select class="custom-select" (change)="labelOnChange($event.target.value)" formControlName="label"> <option [value]="">=</option> <option [value]="'nl'">Null</option> <option [value]="'nnl'">Not Null</option> diff --git a/client/src/app/instance/search/components/criteria/search-type/list.component.ts b/client/src/app/instance/search/components/criteria/search-type/list.component.ts index 3ba0cbb37bed58c480c602e83ddcca45a2924dbf..91a2f7401d99a4825b9fbf12d94922a8d54ee977 100644 --- a/client/src/app/instance/search/components/criteria/search-type/list.component.ts +++ b/client/src/app/instance/search/components/criteria/search-type/list.component.ts @@ -12,7 +12,8 @@ export class ListComponent extends AbstractSearchTypeComponent { constructor() { super(); this.form = new FormGroup({ - list: new FormControl('', [Validators.required]) + list: new FormControl('', [Validators.required]), + label: new FormControl('') }); } @@ -61,4 +62,10 @@ export class ListComponent extends AbstractSearchTypeComponent { } } + enable(): void { + if(this.criteriaList){ + this.form.controls.label.disable(); + + } + } }