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 @@
<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()" formControlName="label">
<option [value]="">In</option>
<option [value]="'In'">In</option>
<option [value]="'nl'">Null</option>
<option [value]="'nnl'">Not Null</option>
</select>
......
......@@ -8,13 +8,13 @@ import { Attribute } from 'src/app/metamodel/models';
@Component({
selector: 'app-checkbox',
templateUrl: 'checkbox.component.html',
styleUrls: ['checkbox.component.scss' ],
styleUrls: ['checkbox.component.scss'],
})
export class CheckboxComponent extends AbstractSearchTypeComponent {
constructor() {
super();
this.form = new FormGroup({
label: new FormControl('')
label: new FormControl(''),
});
}
......@@ -30,6 +30,7 @@ export class CheckboxComponent extends AbstractSearchTypeComponent {
setCriterion(criterion: Criterion) {
super.setCriterion(criterion);
this.form.controls.label.setValue('In');
if (criterion) {
for (let i = 0; i < this.attribute.options.length; i++) {
if ((criterion as SelectMultipleCriterion).options.find(o => o.label === this.attribute.options[i].label)) {
......@@ -38,7 +39,7 @@ export class CheckboxComponent extends AbstractSearchTypeComponent {
}
}
}
/**
* Return new criterion
*
......@@ -79,20 +80,20 @@ 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() {
if (this.form.controls.label.value === 'nl' || this.form.controls.label.value === 'nnl') {
this.getCheckboxes().controls.map((value, index)=>{
value.disable();
})
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) => {
value.disable();
})
} else {
this.nullOrNotNull = '';
this.getCheckboxes().controls.map((value, index)=>{
value.enable();
})
this.nullOrNotNull = '';
this.getCheckboxes().controls.map((value, index) => {
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