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