fix: only set date/number facets selected if values have changed

For displaying the badge, we need to know when custom values have
been set. Also, this prevent useless facet checks when user has
changed one value then changed it back to default.
This commit is contained in:
Yohan Boniface 2024-05-07 12:23:17 +02:00
parent 701b00f4f7
commit 43755c81fa

View file

@ -843,11 +843,22 @@ L.FormBuilder.MinMaxBase = L.FormBuilder.Element.extend({
},
toJS: function () {
return {
const opts = {
type: this.type,
min: this.minInput.value,
max: this.maxInput.value,
}
if (
this.minInput.value !== '' &&
this.minInput.value !== this.minInput.dataset.value
) {
opts.min = this.minInput.value
}
if (
this.maxInput.value !== '' &&
this.maxInput.value !== this.maxInput.dataset.value
) {
opts.max = this.maxInput.value
}
return opts
},
})