hotfix: mode node id inputs

This commit is contained in:
Carter 2026-07-16 12:47:56 -06:00
parent 199511e829
commit 65f8fd06d3
2 changed files with 23 additions and 5 deletions

View file

@ -457,11 +457,29 @@ export default function ComponentForm(props: Props) {
setForm(f); setForm(f);
}; };
const modeDictionaryValue = (dictionary: any, key: string): number | undefined => {
if (!Array.isArray(dictionary)) {
return undefined;
}
let entry = dictionary.find((elem: any) => elem.key === key);
return typeof entry?.value === "number" ? entry.value : undefined;
};
const isCoefficientValid = () => { const isCoefficientValid = () => {
let calibrate = form.component.settings.calibrate; let calibrate = form.component.settings.calibrate;
let coefficient = Number(form.coefficient); let coefficient = Number(form.coefficient);
let valid = !isNaN(coefficient) && (!calibrate || (calibrate && coefficient > 0)); if (isNaN(coefficient)) {
return valid; return false;
}
if (!calibrate) {
return true;
}
if (compMode && compMode.mode.entryA === "number") {
let minimum = modeDictionaryValue(compMode.mode.dictionaryA, "min") ?? 0;
let maximum = modeDictionaryValue(compMode.mode.dictionaryA, "max") ?? 100;
return coefficient >= minimum && coefficient <= maximum;
}
return coefficient > 0;
}; };
const changeCoefficient = (event: any) => { const changeCoefficient = (event: any) => {
@ -485,8 +503,8 @@ export default function ComponentForm(props: Props) {
}; };
const isOffsetValid = (min?: number, max?: number) => { const isOffsetValid = (min?: number, max?: number) => {
let minimum = min ?? 0; let minimum = min ?? modeDictionaryValue(compMode?.mode.dictionaryB, "min") ?? 0;
let maximum = max ?? 100; let maximum = max ?? modeDictionaryValue(compMode?.mode.dictionaryB, "max") ?? 100;
if (compMode && form.component.settings.calibrate) { if (compMode && form.component.settings.calibrate) {
return Number(form.offset) <= maximum && Number(form.offset) >= minimum; return Number(form.offset) <= maximum && Number(form.offset) >= minimum;
} }

View file

@ -110,7 +110,7 @@
"dictionaryA": [ "dictionaryA": [
{ {
"key": "min", "key": "min",
"value": 1, "value": 0,
"restricted": false "restricted": false
}, },
{ {