save dynamic inputs to task steps as its not working perfectly with getElementById if user has other task open
parent
0d9e79f6e6
commit
8d93066e5f
|
@ -236,7 +236,9 @@ export default function GroupTasksViewModal({ isOpen }) {
|
||||||
key: index,
|
key: index,
|
||||||
title:
|
title:
|
||||||
groupTaskSteps[index] !== undefined &&
|
groupTaskSteps[index] !== undefined &&
|
||||||
groupTaskSteps[index].Inputs !== "" ? (
|
groupTaskSteps[index].Inputs !== "" &&
|
||||||
|
groupTaskSteps[index].Status !==
|
||||||
|
Constants.GROUP_TASKS_STATUS.INPUT_REQUIRED ? (
|
||||||
<>
|
<>
|
||||||
{groupTask.name}{" "}
|
{groupTask.name}{" "}
|
||||||
<Popover
|
<Popover
|
||||||
|
@ -265,9 +267,9 @@ export default function GroupTasksViewModal({ isOpen }) {
|
||||||
<span>
|
<span>
|
||||||
{
|
{
|
||||||
JSON.parse(groupTaskSteps[index].Inputs).find(
|
JSON.parse(groupTaskSteps[index].Inputs).find(
|
||||||
(step) =>
|
(input) =>
|
||||||
step.parameterName === task.parameterName
|
input.parameterName === task.parameterName
|
||||||
).value
|
)?.value
|
||||||
}
|
}
|
||||||
</span>
|
</span>
|
||||||
<br />
|
<br />
|
||||||
|
@ -331,8 +333,6 @@ export default function GroupTasksViewModal({ isOpen }) {
|
||||||
)}
|
)}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
{console.log(groupTaskSteps[index])}
|
|
||||||
|
|
||||||
<Alert
|
<Alert
|
||||||
message={
|
message={
|
||||||
<b>
|
<b>
|
||||||
|
@ -357,6 +357,11 @@ export default function GroupTasksViewModal({ isOpen }) {
|
||||||
webSocketContext={webSocketContext}
|
webSocketContext={webSocketContext}
|
||||||
currentGroupTask={currentGroupTask}
|
currentGroupTask={currentGroupTask}
|
||||||
groupTaskParameters={groupTask.parameters}
|
groupTaskParameters={groupTask.parameters}
|
||||||
|
groupTaskStepInputs={
|
||||||
|
groupTaskSteps[index] !== undefined &&
|
||||||
|
groupTaskSteps[index].Inputs !== "" &&
|
||||||
|
groupTaskSteps[index].Inputs
|
||||||
|
}
|
||||||
notificationApi={notificationApi}
|
notificationApi={notificationApi}
|
||||||
step={index + 1}
|
step={index + 1}
|
||||||
taskLockedByUserId={groupTaskSteps[index].LockedByUserId}
|
taskLockedByUserId={groupTaskSteps[index].LockedByUserId}
|
||||||
|
@ -522,6 +527,7 @@ function InputRequiredHandler({
|
||||||
webSocketContext,
|
webSocketContext,
|
||||||
currentGroupTask,
|
currentGroupTask,
|
||||||
groupTaskParameters,
|
groupTaskParameters,
|
||||||
|
groupTaskStepInputs,
|
||||||
notificationApi,
|
notificationApi,
|
||||||
step,
|
step,
|
||||||
taskLockedByUserId,
|
taskLockedByUserId,
|
||||||
|
@ -529,8 +535,20 @@ function InputRequiredHandler({
|
||||||
const [inputFields, setInputFields] = useState({});
|
const [inputFields, setInputFields] = useState({});
|
||||||
|
|
||||||
const globalInputs = JSON.parse(currentGroupTask.GlobalInputs);
|
const globalInputs = JSON.parse(currentGroupTask.GlobalInputs);
|
||||||
|
const stepInputs = JSON.parse(groupTaskStepInputs);
|
||||||
|
|
||||||
const getDefaultValue = (groupTaskParameter) => {
|
const getDefaultValue = (groupTaskParameter) => {
|
||||||
|
if (stepInputs !== false) {
|
||||||
|
const stepInput = stepInputs.find(
|
||||||
|
(stepInput) =>
|
||||||
|
stepInput.parameterName === groupTaskParameter.parameterName
|
||||||
|
)?.value;
|
||||||
|
|
||||||
|
if (stepInput) {
|
||||||
|
return stepInput;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (globalInputs === undefined || !groupTaskParameter.global) return null;
|
if (globalInputs === undefined || !groupTaskParameter.global) return null;
|
||||||
|
|
||||||
return globalInputs.find(
|
return globalInputs.find(
|
||||||
|
|
45
src/utils.js
45
src/utils.js
|
@ -1,6 +1,6 @@
|
||||||
import { UserOutlined } from "@ant-design/icons";
|
import { UserOutlined } from "@ant-design/icons";
|
||||||
import { Avatar, Badge, Tooltip } from "antd";
|
import { Avatar, Badge, Tooltip } from "antd";
|
||||||
import { createContext, useContext, useEffect, useRef, useState } from "react";
|
import { createContext, useEffect, useRef, useState } from "react";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { Buffer } from "buffer";
|
import { Buffer } from "buffer";
|
||||||
|
|
||||||
|
@ -342,11 +342,54 @@ export function WebSocketProvider({
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case ReceivedMessagesCommands.UpdateGroupTaskStepUserInputValue:
|
case ReceivedMessagesCommands.UpdateGroupTaskStepUserInputValue:
|
||||||
|
// html based DOM manipulation
|
||||||
const foundInput = document.getElementById(body.element);
|
const foundInput = document.getElementById(body.element);
|
||||||
|
|
||||||
if (foundInput) {
|
if (foundInput) {
|
||||||
setNativeValue(foundInput, body.value);
|
setNativeValue(foundInput, body.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// update group task step as html based DOM manipulation only works if user has no other modal open
|
||||||
|
setGroupTasksSteps((arr) => {
|
||||||
|
const newArr = [...arr];
|
||||||
|
|
||||||
|
const stepIndex = arr.findIndex(
|
||||||
|
(arr1) =>
|
||||||
|
arr1.GroupTasksId === body.groupTaskId &&
|
||||||
|
arr1.Step === body.step
|
||||||
|
);
|
||||||
|
|
||||||
|
if (stepIndex === -1) return newArr;
|
||||||
|
|
||||||
|
let inputs = [];
|
||||||
|
|
||||||
|
if (newArr[stepIndex].Inputs !== "") {
|
||||||
|
inputs = JSON.parse(newArr[stepIndex].Inputs);
|
||||||
|
}
|
||||||
|
|
||||||
|
let parameterFound = false;
|
||||||
|
|
||||||
|
for (let i = 0; i < inputs.length; i++) {
|
||||||
|
if (inputs[i].parameterName === body.parameterName) {
|
||||||
|
inputs[i].value = body.value;
|
||||||
|
parameterFound = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!parameterFound) {
|
||||||
|
let obj = {};
|
||||||
|
|
||||||
|
obj["parameterName"] = body.parameterName;
|
||||||
|
obj["value"] = body.value;
|
||||||
|
|
||||||
|
inputs.push(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
newArr[stepIndex].Inputs = JSON.stringify(inputs);
|
||||||
|
|
||||||
|
return newArr;
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in New Issue