Stringify 0 as axios treats it as ""
Also add a check that we don't try to log(0)
This commit is contained in:
parent
eec4b6c380
commit
25a839bf88
2 changed files with 4 additions and 3 deletions
|
|
@ -346,7 +346,8 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rounding to about 5 sig figs to stop weird javascript rounding.
|
// Rounding to about 5 sig figs to stop weird javascript rounding.
|
||||||
const magnitude = Math.floor(Math.log10(Math.abs(newValue)));
|
const absVal = Math.abs(newValue);
|
||||||
|
const magnitude = absVal > 0 ? Math.floor(Math.log10(absVal)) : 0;
|
||||||
const factor = 10 ** -(Math.floor(magnitude) - 4);
|
const factor = 10 ** -(Math.floor(magnitude) - 4);
|
||||||
this.internalValue = Math.round(newValue * factor) / factor;
|
this.internalValue = Math.round(newValue * factor) / factor;
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -56,10 +56,10 @@ export default {
|
||||||
"writeproperty",
|
"writeproperty",
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
// `false` fails because axios somehow eats it!
|
// `false` and 0 fail because axios turns it to ""
|
||||||
// Other values should not be stringified or pydantic
|
// Other values should not be stringified or pydantic
|
||||||
// can't parse them.
|
// can't parse them.
|
||||||
if (value === false || value === true) {
|
if (value === false || value === true || value === 0) {
|
||||||
value = JSON.stringify(value);
|
value = JSON.stringify(value);
|
||||||
}
|
}
|
||||||
await axios.put(url, value);
|
await axios.put(url, value);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue