GEOLYTIX / xyz

An open source javascript framework for spatial data and application interfaces.
MIT License
87 stars 25 forks source link

ui.elements.input #1310

Closed cityremade closed 3 months ago

cityremade commented 3 months ago

Added an element for input of type 'number'. Used in numeric entry as a test area.

{
                    "title": "numeric field",
                    "field": "numeric_field",
                    "type": "numeric",
                    "edit": {
                      "min": 0,
                      "max": 100,
                      "placeholder": "Number between 0 and 100"
                    }
                },
                {
                    "title": "integer field",
                    "field": "integer_field",
                    "type": "integer",
                    "edit": true
                }

Includes validation if min/max defined in parameters.

cityremade commented 3 months ago

To clarify further:

Let me know your thoughts.

dbauszus-glx commented 3 months ago

mapp.language is assigned as mapp.user.language and will always have a value.

hence formatterParams.locale will always have a value and doesn't need to be checked before creating the localeValue as const.

undefined is not a number hence only null and NaN need to be checked in the condition for the value.

cityremade commented 3 months ago
    onblur=${e => {
      if (e.target.value === '') e.target.classList.remove('invalid');
    }}

When .invalid class is on it is toggled off when input is emptied and on blur. Otherwise the .invalid style would be left there on cleared and valid (null) input. One of edge cases: null => set value out of range => failed checks => invalid => set back to null => blur => no longer invalid 😂

sonarcloud[bot] commented 3 months ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud