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);
};
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 = () => {
let calibrate = form.component.settings.calibrate;
let coefficient = Number(form.coefficient);
let valid = !isNaN(coefficient) && (!calibrate || (calibrate && coefficient > 0));
return valid;
if (isNaN(coefficient)) {
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) => {
@ -485,8 +503,8 @@ export default function ComponentForm(props: Props) {
};
const isOffsetValid = (min?: number, max?: number) => {
let minimum = min ?? 0;
let maximum = max ?? 100;
let minimum = min ?? modeDictionaryValue(compMode?.mode.dictionaryB, "min") ?? 0;
let maximum = max ?? modeDictionaryValue(compMode?.mode.dictionaryB, "max") ?? 100;
if (compMode && form.component.settings.calibrate) {
return Number(form.offset) <= maximum && Number(form.offset) >= minimum;
}

View file

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