wip: better way of computing isMin/MaxModified in facets fields
This commit is contained in:
parent
53458053a7
commit
86ae6bb816
1 changed files with 14 additions and 12 deletions
|
@ -825,11 +825,14 @@ L.FormBuilder.MinMaxBase = L.FormBuilder.FacetSearchBase.extend({
|
||||||
this.minInput.min = this.prepareForHTML(min)
|
this.minInput.min = this.prepareForHTML(min)
|
||||||
this.minInput.max = this.prepareForHTML(max)
|
this.minInput.max = this.prepareForHTML(max)
|
||||||
if (min != null) {
|
if (min != null) {
|
||||||
this.minInput.dataset.value = min
|
// The value stored using setAttribute is not modified by
|
||||||
// Use setAttribute so to restore to this value when resetting
|
// user input, and will be used as initial value when calling
|
||||||
// form.
|
// form.reset(), and can also be retrieve later on by using
|
||||||
|
// getAttributing, to compare with current value and know
|
||||||
|
// if this value has been modified by the user
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/reset
|
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/reset
|
||||||
this.minInput.setAttribute('value', this.prepareForHTML(min))
|
this.minInput.setAttribute('value', this.prepareForHTML(min))
|
||||||
|
this.minInput.value = this.prepareForHTML(currentMin)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.maxLabel = L.DomUtil.create('label', '', this.container)
|
this.maxLabel = L.DomUtil.create('label', '', this.container)
|
||||||
|
@ -841,8 +844,9 @@ L.FormBuilder.MinMaxBase = L.FormBuilder.FacetSearchBase.extend({
|
||||||
this.maxInput.min = this.prepareForHTML(min)
|
this.maxInput.min = this.prepareForHTML(min)
|
||||||
this.maxInput.max = this.prepareForHTML(max)
|
this.maxInput.max = this.prepareForHTML(max)
|
||||||
if (max != null) {
|
if (max != null) {
|
||||||
this.maxInput.dataset.value = max
|
// Cf comment above about setAttribute vs value
|
||||||
this.maxInput.setAttribute('value', this.prepareForHTML(max))
|
this.maxInput.setAttribute('value', this.prepareForHTML(max))
|
||||||
|
this.maxInput.value = this.prepareForHTML(currentMax)
|
||||||
}
|
}
|
||||||
this.toggleStatus()
|
this.toggleStatus()
|
||||||
|
|
||||||
|
@ -861,17 +865,15 @@ L.FormBuilder.MinMaxBase = L.FormBuilder.FacetSearchBase.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
isMinModified: function () {
|
isMinModified: function () {
|
||||||
return (
|
const default_ = this.minInput.getAttribute("value")
|
||||||
this.prepareForHTML(this.prepareForJS(this.minInput.value)) !==
|
const current = this.minInput.value
|
||||||
this.prepareForHTML(this.prepareForJS(this.minInput.dataset.value))
|
return current != default_
|
||||||
)
|
|
||||||
},
|
},
|
||||||
|
|
||||||
isMaxModified: function () {
|
isMaxModified: function () {
|
||||||
return (
|
const default_ = this.maxInput.getAttribute("value")
|
||||||
this.prepareForHTML(this.prepareForJS(this.maxInput.value)) !==
|
const current = this.maxInput.value
|
||||||
this.prepareForHTML(this.prepareForJS(this.maxInput.dataset.value))
|
return current != default_
|
||||||
)
|
|
||||||
},
|
},
|
||||||
|
|
||||||
toJS: function () {
|
toJS: function () {
|
||||||
|
|
Loading…
Reference in a new issue