dynamic machines
parent
8c3431a60d
commit
9a4f08bacd
|
@ -326,8 +326,6 @@ export function handleWebSocketMessage(
|
|||
|
||||
// update input value
|
||||
|
||||
console.log("body", body);
|
||||
|
||||
if (body.inputType === "text") {
|
||||
// html based DOM manipulation
|
||||
const foundInput = document.getElementById(body.element);
|
||||
|
@ -340,8 +338,6 @@ export function handleWebSocketMessage(
|
|||
groupTasksContext.setSelectInputs((prev) => {
|
||||
const newInputs = { ...prev };
|
||||
|
||||
console.log("newInputs", newInputs);
|
||||
|
||||
if (newInputs[body.parameterName] === undefined) {
|
||||
newInputs[body.parameterName] = {
|
||||
value: body.value,
|
||||
|
@ -371,7 +367,7 @@ export function handleWebSocketMessage(
|
|||
|
||||
if (stepIndex === -1) return newArr;
|
||||
|
||||
let inputs = [];
|
||||
let inputs = {};
|
||||
|
||||
if (newArr[stepIndex].Inputs !== "") {
|
||||
inputs = JSON.parse(newArr[stepIndex].Inputs);
|
||||
|
@ -379,25 +375,34 @@ export function handleWebSocketMessage(
|
|||
|
||||
let parameterFound = false;
|
||||
|
||||
for (let i = 0; i < inputs.length; i++) {
|
||||
if (inputs[i].parameterName === body.parameterName) {
|
||||
inputs[i].value = body.value;
|
||||
const inputKeys = Object.keys(inputs);
|
||||
|
||||
for (let i = 0; i < inputKeys.length; i++) {
|
||||
if (inputKeys[i] === body.parameterName) {
|
||||
inputs[inputKeys[i]].value = body.value;
|
||||
parameterFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!parameterFound) {
|
||||
let obj = {};
|
||||
let newObj = {
|
||||
value: body.value,
|
||||
};
|
||||
|
||||
obj["parameterName"] = body.parameterName;
|
||||
obj["value"] = body.value;
|
||||
if (body.data !== undefined) {
|
||||
newObj.data = body.data;
|
||||
}
|
||||
|
||||
inputs.push(obj);
|
||||
inputs[body.parameterName] = newObj;
|
||||
} else {
|
||||
inputs[body.parameterName].value = body.value;
|
||||
|
||||
if (body.data !== undefined) {
|
||||
inputs[body.parameterName].data = body.data;
|
||||
}
|
||||
}
|
||||
|
||||
newArr[stepIndex].Inputs = JSON.stringify(inputs);
|
||||
|
||||
return newArr;
|
||||
});
|
||||
|
||||
|
|
|
@ -146,7 +146,7 @@ export default function GroupTasksViewModal({ isOpen }) {
|
|||
);
|
||||
|
||||
let canTaskContinued = true;
|
||||
let taskInputs = [];
|
||||
let taskInputs = {}; // example format: { "parameterNameAsKey": { value: "value", data: "data" } }
|
||||
let foundSelectInputs = 0;
|
||||
|
||||
if (groupTasksViewModalRequiredInputsForm !== null) {
|
||||
|
@ -165,13 +165,17 @@ export default function GroupTasksViewModal({ isOpen }) {
|
|||
break;
|
||||
}
|
||||
|
||||
taskInputs[specifiedTaskInputs[i].id.split("-")[6]] = {
|
||||
value: specifiedTaskInputs[i].value,
|
||||
}; /*,
|
||||
/*
|
||||
taskInputs.push({
|
||||
parameterName:
|
||||
specifiedTaskInputs[i].id.split(
|
||||
"-"
|
||||
)[6] /* Format: UUID-STEP-PARAMETER_NAME */,
|
||||
)[6] /* Format: UUID-STEP-PARAMETER_NAME */ /*
|
||||
value: specifiedTaskInputs[i].value,
|
||||
});
|
||||
}); */
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -183,15 +187,19 @@ export default function GroupTasksViewModal({ isOpen }) {
|
|||
if (specifiedTaskTextareas[i].value === "") {
|
||||
canTaskContinued = false;
|
||||
break;
|
||||
}
|
||||
} /*,
|
||||
|
||||
taskInputs.push({
|
||||
/* taskInputs.push({
|
||||
parameterName:
|
||||
specifiedTaskTextareas[i].id.split(
|
||||
"-"
|
||||
)[6] /* Format: UUID-STEP-PARAMETER_NAME */,
|
||||
)[6] /* Format: UUID-STEP-PARAMETER_NAME */ /*
|
||||
value: specifiedTaskTextareas[i].value,
|
||||
});
|
||||
});*/
|
||||
|
||||
taskInputs[specifiedTaskInputs[i].id.split("-")[6]] = {
|
||||
value: specifiedTaskInputs[i].value,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -206,11 +214,16 @@ export default function GroupTasksViewModal({ isOpen }) {
|
|||
canTaskContinued = false;
|
||||
} else {
|
||||
selectInputsObjectKeys.forEach((key) => {
|
||||
taskInputs.push({
|
||||
/*taskInputs.push({
|
||||
parameterName: key,
|
||||
value: groupTasksContext.selectInputs[key].value,
|
||||
data: groupTasksContext.selectInputs[key].data,
|
||||
});
|
||||
});*/
|
||||
|
||||
taskInputs[key] = {
|
||||
value: groupTasksContext.selectInputs[key].value,
|
||||
data: groupTasksContext.selectInputs[key].data,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -403,10 +416,9 @@ export default function GroupTasksViewModal({ isOpen }) {
|
|||
</span>
|
||||
<span>
|
||||
{
|
||||
JSON.parse(groupTaskSteps[index].Inputs).find(
|
||||
(input) =>
|
||||
input.parameterName === task.parameterName
|
||||
)?.value
|
||||
JSON.parse(groupTaskSteps[index].Inputs)[
|
||||
task.parameterName
|
||||
]?.value
|
||||
}
|
||||
</span>
|
||||
<br />
|
||||
|
@ -505,6 +517,7 @@ export default function GroupTasksViewModal({ isOpen }) {
|
|||
groupTaskSteps[index].Status ===
|
||||
Constants.GROUP_TASKS_STATUS.INPUT_REQUIRED ? (
|
||||
<div id={`${currentGroupTask.current.Id}-scroll-${index}`}>
|
||||
{console.log("inputrequ handl", groupTaskSteps[index])}
|
||||
<InputRequiredHandler
|
||||
webSocketContext={webSocketContext}
|
||||
appContext={appContext}
|
||||
|
@ -734,7 +747,6 @@ function InputRequiredHandler({
|
|||
taskLockedByUserId,
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
//const [inputFields, setInputFields] = useState({});
|
||||
|
||||
const globalInputs = JSON.parse(currentGroupTask.GlobalInputs);
|
||||
const stepInputs = JSON.parse(groupTaskStepInputs);
|
||||
|
@ -753,7 +765,10 @@ function InputRequiredHandler({
|
|||
|
||||
if (globalInputs === undefined || !groupTaskParameter.global) return "";
|
||||
|
||||
const globalInputValue = globalInputs[groupTaskParameter.parameterName];
|
||||
const globalInputValue = globalInputs.find(
|
||||
(globalInput) =>
|
||||
globalInput.parameterName === groupTaskParameter.parameterName
|
||||
);
|
||||
|
||||
return globalInputValue !== undefined ? globalInputValue.value : "";
|
||||
};
|
||||
|
@ -846,6 +861,10 @@ function InputRequiredHandler({
|
|||
)}
|
||||
required
|
||||
>
|
||||
{console.log(
|
||||
"getDefaultValue",
|
||||
getDefaultValue(groupTaskParameter)
|
||||
)}
|
||||
<Input
|
||||
id={`${currentGroupTask.Id}-${step}-${groupTaskParameter.parameterName}`}
|
||||
defaultValue={getDefaultValue(groupTaskParameter)}
|
||||
|
@ -858,7 +877,6 @@ function InputRequiredHandler({
|
|||
groupTaskParameter.parameterName
|
||||
)
|
||||
}
|
||||
//value={inputFields[groupTaskParameter.parameterName]}
|
||||
/>
|
||||
</Form.Item>
|
||||
);
|
||||
|
@ -886,7 +904,6 @@ function InputRequiredHandler({
|
|||
groupTaskParameter.parameterName
|
||||
)
|
||||
}
|
||||
//value={inputFields[groupTaskParameter.parameterName]}
|
||||
/>
|
||||
</Form.Item>
|
||||
);
|
||||
|
@ -912,7 +929,6 @@ function InputRequiredHandler({
|
|||
groupTaskParameter.parameterName
|
||||
)
|
||||
}
|
||||
//value={inputFields[groupTaskParameter.parameterName]}
|
||||
/>
|
||||
</Form.Item>
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue