Skip to content
Snippets Groups Projects
Commit 2d4286d8 authored by Angapay Divin's avatar Angapay Divin
Browse files

make selector desabled in checkbox searchTYPE when the user validate a criteria

parent 5c410294
No related branches found
No related tags found
2 merge requests!72Develop,!38Resolve "Réorganisation criterion (null, not null)"
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<div class="row form-group"> <div class="row form-group">
<div class="col-md-3 col-sm-auto pr-sm-1 mb-1 mb-lg-0"> <div class="col-md-3 col-sm-auto pr-sm-1 mb-1 mb-lg-0">
<select class="custom-select" (change)="labelOnChange()" formControlName="label"> <select class="custom-select" (change)="labelOnChange()" formControlName="label">
<option [value]="">In</option> <option [value]="'In'">In</option>
<option [value]="'nl'">Null</option> <option [value]="'nl'">Null</option>
<option [value]="'nnl'">Not Null</option> <option [value]="'nnl'">Not Null</option>
</select> </select>
......
...@@ -8,13 +8,13 @@ import { Attribute } from 'src/app/metamodel/models'; ...@@ -8,13 +8,13 @@ import { Attribute } from 'src/app/metamodel/models';
@Component({ @Component({
selector: 'app-checkbox', selector: 'app-checkbox',
templateUrl: 'checkbox.component.html', templateUrl: 'checkbox.component.html',
styleUrls: ['checkbox.component.scss' ], styleUrls: ['checkbox.component.scss'],
}) })
export class CheckboxComponent extends AbstractSearchTypeComponent { export class CheckboxComponent extends AbstractSearchTypeComponent {
constructor() { constructor() {
super(); super();
this.form = new FormGroup({ this.form = new FormGroup({
label: new FormControl('') label: new FormControl(''),
}); });
} }
...@@ -30,6 +30,7 @@ export class CheckboxComponent extends AbstractSearchTypeComponent { ...@@ -30,6 +30,7 @@ export class CheckboxComponent extends AbstractSearchTypeComponent {
setCriterion(criterion: Criterion) { setCriterion(criterion: Criterion) {
super.setCriterion(criterion); super.setCriterion(criterion);
this.form.controls.label.setValue('In');
if (criterion) { if (criterion) {
for (let i = 0; i < this.attribute.options.length; i++) { for (let i = 0; i < this.attribute.options.length; i++) {
if ((criterion as SelectMultipleCriterion).options.find(o => o.label === this.attribute.options[i].label)) { if ((criterion as SelectMultipleCriterion).options.find(o => o.label === this.attribute.options[i].label)) {
...@@ -38,7 +39,7 @@ export class CheckboxComponent extends AbstractSearchTypeComponent { ...@@ -38,7 +39,7 @@ export class CheckboxComponent extends AbstractSearchTypeComponent {
} }
} }
} }
/** /**
* Return new criterion * Return new criterion
* *
...@@ -79,20 +80,20 @@ export class CheckboxComponent extends AbstractSearchTypeComponent { ...@@ -79,20 +80,20 @@ export class CheckboxComponent extends AbstractSearchTypeComponent {
// If one of the checkboxes is checked returns true else returns false // If one of the checkboxes is checked returns true else returns false
return this.getCheckboxes().controls.filter(formControl => formControl.value).length > 0; return this.getCheckboxes().controls.filter(formControl => formControl.value).length > 0;
} }
labelOnChange() { labelOnChange() {
if (this.form.controls.label.value === 'nl' || this.form.controls.label.value === 'nnl') { if (this.form.controls.label.value === 'nl' || this.form.controls.label.value === 'nnl') {
this.nullOrNotNull = this.form.controls.label.value;
this.getCheckboxes().controls.map((value, index)=>{ this.getCheckboxes().controls.map((value, index) => {
value.disable(); value.disable();
}) })
} else { } else {
this.nullOrNotNull = ''; this.nullOrNotNull = '';
this.getCheckboxes().controls.map((value, index)=>{ this.getCheckboxes().controls.map((value, index) => {
value.enable(); value.enable();
}) })
} }
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment