fix(labs): keep a reading's conversion record unless its value actually changes

The single-reading edit cleared sourceValue and sourceUnit whenever the body
carried a value, and the web edit sheet always sends one, so a date or note
edit erased the "converted from" hint. It is now cleared only when the value
differs from the stored one. The sheet also opened a converted reading at its
stored precision (100.90191999999999); it now starts from the value as the lab
surfaces show it and leaves an untouched value out of the request, so the
stored full-precision number is not replaced by its rounded display.
This commit is contained in:
Marc-André Bombeck committed 2026-10-14 19:15:33 +02:00
1 parent 47a91d6922
commit cd1449e63e
6 files changed
+118 -9

No files matched your search

+8 -2
View File
@@ -195,8 +195,14 @@ export const PUT = apiHandler(
if (d.value !== undefined) {
data.value = d.value;
// A number the person typed is no longer the conversion of what the
// report printed, so the "converted from" record would now be wrong.
if (existing.sourceValue !== null || existing.sourceUnit !== null) {
// report printed, so the "converted from" record would now be wrong. Only
// a CHANGED value says so: a client that sends the whole form back with
// the value untouched (the web edit dialog does) must not erase the
// record. Both sides are plain numbers (`value` is a Float column).
if (
d.value !== existing.value &&
(existing.sourceValue !== null || existing.sourceUnit !== null)
) {
data.sourceValue = null;
data.sourceUnit = null;
}