checkbox and select
parent
ec337b4c5b
commit
4fed6f4540
|
@ -237,11 +237,6 @@ export function handleWebSocketMessage(
|
|||
onClick: () => navigator.clipboard.writeText(body),
|
||||
});
|
||||
|
||||
console.log(
|
||||
"here1",
|
||||
scannerContext.checkboxAutomaticFillingOfInputFieldsCheckedRef.current
|
||||
);
|
||||
|
||||
if (
|
||||
scannerContext
|
||||
.checkboxAutomaticRecognitionOfEquipmentDocumentationCheckedRef
|
||||
|
@ -268,10 +263,7 @@ export function handleWebSocketMessage(
|
|||
) {
|
||||
// get the current focused input on the page and set the value
|
||||
const foundInput = document.activeElement;
|
||||
console.log(
|
||||
"here",
|
||||
scannerContext.checkboxAutomaticFillingOfInputFieldsCheckedRef.current
|
||||
);
|
||||
|
||||
if (foundInput) {
|
||||
setNativeValue(foundInput, body);
|
||||
}
|
||||
|
@ -298,8 +290,6 @@ export function handleWebSocketMessage(
|
|||
|
||||
// update input value
|
||||
|
||||
console.log("body", body.inputType, body.value, body.element);
|
||||
|
||||
if (body.inputType === "text") {
|
||||
// html based DOM manipulation
|
||||
const foundInput = document.getElementById(body.element);
|
||||
|
@ -346,7 +336,6 @@ export function handleWebSocketMessage(
|
|||
}
|
||||
|
||||
let parameterFound = false;
|
||||
|
||||
const inputKeys = Object.keys(inputs);
|
||||
|
||||
for (let i = 0; i < inputKeys.length; i++) {
|
||||
|
|
|
@ -69,6 +69,20 @@ export default function GroupTasksViewModal({ isOpen }) {
|
|||
).then((data) => {
|
||||
currentGroupTask.current = data.GroupTask;
|
||||
groupTasksContext.setGroupTasksSteps(data.GroupTaskSteps);
|
||||
|
||||
// set the select inputs
|
||||
|
||||
if (
|
||||
data.GroupTaskSteps[data.GroupTaskSteps.length - 1].Inputs !== "" &&
|
||||
data.GroupTaskSteps[data.GroupTaskSteps.length - 1].Status ===
|
||||
Constants.GROUP_TASKS_STATUS.INPUT_REQUIRED
|
||||
) {
|
||||
const inputs = JSON.parse(
|
||||
data.GroupTaskSteps[data.GroupTaskSteps.length - 1].Inputs
|
||||
);
|
||||
|
||||
groupTasksContext.setSelectInputs(inputs);
|
||||
}
|
||||
});
|
||||
}, [isOpen, paramCategory]);
|
||||
|
||||
|
@ -151,7 +165,7 @@ export default function GroupTasksViewModal({ isOpen }) {
|
|||
|
||||
let canTaskContinued = true;
|
||||
let taskInputs = {}; // example format: { "parameterNameAsKey": { value: "value", data: "data" } }
|
||||
let foundSelectInputs = 0;
|
||||
let foundSelectInputs = [];
|
||||
|
||||
if (groupTasksViewModalRequiredInputsForm !== null) {
|
||||
const specifiedTaskInputs =
|
||||
|
@ -159,8 +173,15 @@ export default function GroupTasksViewModal({ isOpen }) {
|
|||
|
||||
if (specifiedTaskInputs.length > 0) {
|
||||
for (let i = 0; i < specifiedTaskInputs.length; i++) {
|
||||
if (specifiedTaskInputs[i].type !== "text") {
|
||||
foundSelectInputs = foundSelectInputs + 1;
|
||||
if (specifiedTaskInputs[i].type === "search") {
|
||||
foundSelectInputs.push(specifiedTaskInputs[i].id);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (specifiedTaskInputs[i].type === "checkbox") {
|
||||
taskInputs[specifiedTaskInputs[i].id.split("-")[6]] = {
|
||||
value: specifiedTaskInputs[i].checked.toString(),
|
||||
};
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -195,11 +216,13 @@ export default function GroupTasksViewModal({ isOpen }) {
|
|||
const selectInputsObjectKeys = Object.keys(groupTasksContext.selectInputs);
|
||||
|
||||
// if there are select inputs, we need to check if they are all selected
|
||||
if (
|
||||
foundSelectInputs > 0 &&
|
||||
foundSelectInputs !== selectInputsObjectKeys.length
|
||||
) {
|
||||
canTaskContinued = false;
|
||||
if (foundSelectInputs.length > 0) {
|
||||
for (let i = 0; i < foundSelectInputs.length; i++) {
|
||||
if (!selectInputsObjectKeys.includes(foundSelectInputs[i])) {
|
||||
canTaskContinued = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
selectInputsObjectKeys.forEach(
|
||||
(key) =>
|
||||
|
@ -236,8 +259,6 @@ export default function GroupTasksViewModal({ isOpen }) {
|
|||
|
||||
// reset the select inputs
|
||||
groupTasksContext.setSelectInputs({});
|
||||
|
||||
console.log("onContinue", groupTasksContext.groupTasksSteps);
|
||||
};
|
||||
|
||||
const handleUserActionTaskStep = (action, taskStepId, step) => {
|
||||
|
@ -740,12 +761,9 @@ function InputRequiredHandler({
|
|||
|
||||
const getDefaultValue = (groupTaskParameter) => {
|
||||
if (stepInputs !== false) {
|
||||
const stepInput = stepInputs.find(
|
||||
(stepInput) =>
|
||||
stepInput.parameterName === groupTaskParameter.parameterName
|
||||
)?.value;
|
||||
const stepInput = stepInputs[groupTaskParameter.parameterName]?.value;
|
||||
|
||||
if (stepInput) {
|
||||
if (stepInput !== undefined && stepInput !== null) {
|
||||
return stepInput;
|
||||
}
|
||||
}
|
||||
|
@ -905,6 +923,8 @@ function InputRequiredHandler({
|
|||
isGlobal={groupTaskParameter.global}
|
||||
>
|
||||
<SelectMachineComponent
|
||||
// id needed for the validation to check if task continue is possible
|
||||
id={groupTaskParameter.parameterName}
|
||||
disabled={taskLockedByUserId !== ""}
|
||||
t={t}
|
||||
notificationApi={notificationApi}
|
||||
|
@ -935,10 +955,11 @@ function InputRequiredHandler({
|
|||
}}
|
||||
>
|
||||
<Checkbox
|
||||
defaultChecked={getDefaultValue(groupTaskParameter)}
|
||||
disabled={taskLockedByUserId !== ""}
|
||||
checked={
|
||||
groupTaskStepInputs[groupTaskParameter.parameterName]?.value
|
||||
groupTasksContext.selectInputs[
|
||||
groupTaskParameter.parameterName
|
||||
]?.value
|
||||
}
|
||||
onChange={(e) => {
|
||||
groupTasksContext.setSelectInputs((prevState) => ({
|
||||
|
@ -956,7 +977,6 @@ function InputRequiredHandler({
|
|||
);
|
||||
}}
|
||||
>
|
||||
{console.log("checked", groupTaskStepInputs)}
|
||||
<MyFormItemLabel
|
||||
t={t}
|
||||
displayName={groupTaskParameter.displayName}
|
||||
|
@ -974,6 +994,8 @@ function InputRequiredHandler({
|
|||
isGlobal={groupTaskParameter.global}
|
||||
>
|
||||
<SelectComponent
|
||||
// id needed for the validation to check if task continue is possible
|
||||
id={groupTaskParameter.parameterName}
|
||||
t={t}
|
||||
disabled={taskLockedByUserId !== ""}
|
||||
options={groupTaskParameter.options}
|
||||
|
|
|
@ -266,6 +266,8 @@ export function SelectComponent({
|
|||
parameterName,
|
||||
onSelectChange,
|
||||
disabled,
|
||||
defaultValue,
|
||||
id,
|
||||
}) {
|
||||
const groupTasksContext = useGroupTasksContext();
|
||||
|
||||
|
@ -279,6 +281,7 @@ export function SelectComponent({
|
|||
|
||||
return (
|
||||
<Select
|
||||
id={id}
|
||||
disabled={disabled}
|
||||
placeholder={t(
|
||||
"groupTasks.groupTypeSelectionModal.select.valuePlaceholder"
|
||||
|
@ -290,7 +293,12 @@ export function SelectComponent({
|
|||
value: option,
|
||||
};
|
||||
})}
|
||||
value={groupTasksContext.selectInputs[parameterName]?.value}
|
||||
defaultValue={defaultValue}
|
||||
value={
|
||||
groupTasksContext.selectInputs[parameterName]?.value === undefined
|
||||
? null
|
||||
: groupTasksContext.selectInputs[parameterName]?.value
|
||||
}
|
||||
onSelect={(value) => {
|
||||
groupTasksContext.setSelectInputs((prevState) => ({
|
||||
...prevState,
|
||||
|
@ -308,11 +316,13 @@ export function SelectComponent({
|
|||
}
|
||||
|
||||
export function SelectMachineComponent({
|
||||
id,
|
||||
t,
|
||||
notificationApi,
|
||||
globalInput,
|
||||
onSelectChange,
|
||||
disabled,
|
||||
defaultValue,
|
||||
}) {
|
||||
const groupTasksContext = useGroupTasksContext();
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
@ -390,6 +400,7 @@ export function SelectMachineComponent({
|
|||
|
||||
return (
|
||||
<Select
|
||||
id={id}
|
||||
disabled={disabled}
|
||||
loading={loading}
|
||||
placeholder={t(
|
||||
|
@ -397,7 +408,12 @@ export function SelectMachineComponent({
|
|||
)}
|
||||
style={{ width: "100%" }}
|
||||
options={options}
|
||||
value={groupTasksContext.selectInputs[globalInput.parameterName]?.value}
|
||||
value={
|
||||
groupTasksContext.selectInputs[globalInput.parameterName]?.value ===
|
||||
undefined
|
||||
? null
|
||||
: groupTasksContext.selectInputs[globalInput.parameterName]?.value
|
||||
}
|
||||
onSelect={(value) => {
|
||||
const parsedNotes = JSON.parse(responseData.current[value].Notes);
|
||||
|
||||
|
|
Loading…
Reference in New Issue