The-EG / OctoPrint-UBLMeshEdit

An OctoPrint plugin that can be used to view, edit and manage Marlin Unified Bed Leveling (UBL) meshes.
GNU Affero General Public License v3.0
17 stars 5 forks source link

Validate the Z value input #20

Open ali1234 opened 2 months ago

ali1234 commented 2 months ago

Checks that the Z value and row and column are numbers and enables the save button as appropriate. Automatically rounds the input field to the displayed precision. The precision may be adjusted, perhaps with a configuration option?

Also tweaks the HTML: Changes the default step from 0.025 to 0.01 (this seems to be the default precision in Marlin) and sets autocomplete="false" on the save button, to prevent Firefox from remembering the state across reloads, potentially leaving the button enabled when it should not be.

Fixes #18

ali1234 commented 2 months ago

This uses ko observer subscriptions to detect changes, and an extender to provide rounding on the input field. The extender is mostly taken from the ko documentation, which uses numeric rounding as an example. I have modified it slightly by removing the checks on current value and (IMO) better handle invalid input.

Some whitespace also slipped through. Sorry about that.

Open questions: