From 6156993536539dadc9c0431f869a7279da1aa326 Mon Sep 17 00:00:00 2001 From: David Larlet Date: Thu, 18 May 2023 14:20:46 -0400 Subject: [PATCH] Display the steps for inputs of type range Fix #877 --- umap/static/umap/base.css | 7 +++++++ umap/static/umap/js/umap.forms.js | 17 +++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/umap/static/umap/base.css b/umap/static/umap/base.css index b4006ad6..af18a94a 100644 --- a/umap/static/umap/base.css +++ b/umap/static/umap/base.css @@ -512,6 +512,13 @@ i.info { .umap-browse-datalayers { padding: 0 10px; } +.umap-field-datalist { + display: flex; + justify-content: space-between; + font-size: 9px; + margin-top: -8px; + padding: 0 5px; +} .umap-form-iconfield { position: relative; overflow: hidden; diff --git a/umap/static/umap/js/umap.forms.js b/umap/static/umap/js/umap.forms.js index 234bc048..5fb8e231 100644 --- a/umap/static/umap/js/umap.forms.js +++ b/umap/static/umap/js/umap.forms.js @@ -801,6 +801,23 @@ L.FormBuilder.Range = L.FormBuilder.Input.extend({ value: function () { return L.DomUtil.hasClass(this.wrapper, 'undefined') ? undefined : this.input.value }, + + buildHelpText: function () { + var datalist = L.DomUtil.create( + 'datalist', + 'umap-field-datalist', + this.getHelpTextParent() + ) + datalist.id = `range-${this.options.label}` + this.input.setAttribute('list', datalist.id) + var options = '' + for (var i = this.options.min; i <= this.options.max; i += this.options.step) { + options += `` + } + datalist.innerHTML = options + }, }) L.FormBuilder.ManageOwner = L.FormBuilder.Element.extend({