From 43755c81fa6eebdf54ae179cd45392d94d971a64 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Tue, 7 May 2024 12:23:17 +0200 Subject: [PATCH] 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. --- umap/static/umap/js/umap.forms.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/umap/static/umap/js/umap.forms.js b/umap/static/umap/js/umap.forms.js index 4098e0ec..85bda31d 100644 --- a/umap/static/umap/js/umap.forms.js +++ b/umap/static/umap/js/umap.forms.js @@ -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 }, })