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

improve between and between date serach type

parent 11d59b62
No related branches found
No related tags found
2 merge requests!72Develop,!38Resolve "Réorganisation criterion (null, not null)"
......@@ -15,7 +15,7 @@ export class BetweenDateComponent extends AbstractSearchTypeComponent {
dateRange: new FormControl('', [Validators.required]),
label: new FormControl()
});
}
setCriterion(criterion: Criterion) {
......@@ -27,7 +27,7 @@ export class BetweenDateComponent extends AbstractSearchTypeComponent {
new Date(betweenCriterion.min),
new Date(betweenCriterion.max)
]);
}
}
......@@ -55,9 +55,18 @@ export class BetweenDateComponent extends AbstractSearchTypeComponent {
*
* @return string
*/
getDateString(date: Date): string {
const month = ('0' + (date.getMonth() + 1)).slice(-2);
const day = ('0' + (date.getDate())).slice(-2);
return `${date.getFullYear()}-${month}-${day}`;
}
/**
* manage label change
*/
labelOnChange() {
if (this.form.controls.label.value === 'nl' || this.form.controls.label.value === 'nnl') {
this.nullOrNotNull = this.form.controls.label.value ;
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 = '';
......@@ -65,10 +74,5 @@ export class BetweenDateComponent extends AbstractSearchTypeComponent {
}
}
getDateString(date: Date): string {
const month = ('0' + (date.getMonth() + 1)).slice(-2);
const day = ('0' + (date.getDate())).slice(-2);
return `${date.getFullYear()}-${month}-${day}`;
}
}
......@@ -9,8 +9,8 @@ import { Criterion, BetweenCriterion } from 'src/app/instance/store/models';
templateUrl: 'between.component.html'
})
export class BetweenComponent extends AbstractSearchTypeComponent implements OnInit {
constructor() {
super();
this.form = new FormGroup({
......@@ -19,12 +19,12 @@ export class BetweenComponent extends AbstractSearchTypeComponent implements OnI
label: new FormControl('')
});
}
ngOnInit(): void {
this.form.controls.label.setValue("Min/Max");
}
/**
* Return new criterion
*
......@@ -50,15 +50,18 @@ export class BetweenComponent extends AbstractSearchTypeComponent implements OnI
return this.attribute.placeholder_min;
}
}
/**
* manage label change
*/
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.form.controls.min.disable();
this.form.controls.max.disable();
} else {
if(!(this.form.controls.min.value || this.form.controls.max.value)){
if (!(this.form.controls.min.value || this.form.controls.max.value)) {
this.nullOrNotNull = '';
}
this.form.controls.max.enable();
......@@ -82,12 +85,12 @@ export class BetweenComponent extends AbstractSearchTypeComponent implements OnI
isValid() {
return this.form.controls.min.value || this.form.controls.max.value;
}
enable() {
super.enable();
if (this.criteriaList) {
this.form.controls.label.disable();
}
}
}
......@@ -26,6 +26,7 @@ export class CheckboxComponent extends AbstractSearchTypeComponent {
formControls.push(new FormControl());
}
this.form.addControl('checkboxes', new FormArray(formControls));
}
setCriterion(criterion: Criterion) {
......@@ -39,6 +40,7 @@ export class CheckboxComponent extends AbstractSearchTypeComponent {
}
}else{
this.form.controls.label.setValue('In');
}
}
......@@ -85,10 +87,11 @@ export class CheckboxComponent extends AbstractSearchTypeComponent {
labelOnChange() {
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();
})
this.nullOrNotNull = this.form.controls.label.value;
} else {
this.nullOrNotNull = '';
......
......@@ -29,7 +29,6 @@ export class DatalistComponent extends AbstractSearchTypeComponent {
}
}
}
/**
* Return new criterion
*
......
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