diff --git a/forms-flow-web/src/components/ServiceFlow/list/sort/TaskAttributeComponent.js b/forms-flow-web/src/components/ServiceFlow/list/sort/TaskAttributeComponent.js
index 17c1874418..b3b679366f 100644
--- a/forms-flow-web/src/components/ServiceFlow/list/sort/TaskAttributeComponent.js
+++ b/forms-flow-web/src/components/ServiceFlow/list/sort/TaskAttributeComponent.js
@@ -1,50 +1,114 @@
-import React from "react";
+import React, { useState } from "react";
import { Row, Col } from "react-bootstrap";
import Modal from "react-bootstrap/Modal";
import ModalTitle from "react-bootstrap/ModalTitle";
import Form from "react-bootstrap/Form";
-import {Translation, useTranslation } from "react-i18next";
+import { Translation, useTranslation } from "react-i18next";
import { useSelector } from "react-redux";
function TaskAttributeComponent({
show,
+ selectedForm,
onHide,
- setCheckboxes,
- checkboxes,
- showUndefinedVariable,
- setShowUndefinedVariable,
- handleChangeTaskVariables,
+ selectedTaskAttrbutes,
+ selectedTaskVariablesKeys,
selectedTaskVariables,
- selectedForm
+ onSaveTaskAttribute,
+ processLoading,
+ // showUndefinedVariable,
}) {
-
- const taskVariables = useSelector(state => state.process?.formProcessList?.taskVariable || []);
+ const taskVariables = useSelector(
+ (state) => state.process?.formProcessList?.taskVariable || []
+ );
const { t } = useTranslation();
+
+ const [variables, setVariables] = useState(selectedTaskVariables);
+ const [taskVariablesKeys, setTaskVariablesKeys] = useState(
+ selectedTaskVariablesKeys
+ );
+ const [checkboxes, setCheckboxes] = useState(selectedTaskAttrbutes);
+ // const [selectUndefinedVariable, setSelectUndefinedVariable] = useState(
+ // showUndefinedVariable
+ // );
+
+ // const UndefinedVaribaleCheckboxChange = (e) => {
+ // setSelectUndefinedVariable(e.target.checked);
+ // };
+
const handleCheckboxChange = (event) => {
const { name, checked } = event.target;
setCheckboxes({ ...checkboxes, [name]: checked });
};
-
-
- const UndefinedVaribaleCheckboxChange = (e) => {
- setShowUndefinedVariable(e.target.checked);
+
+ /**
+ * Handles changing the selected task variables.
+ *
+ * When a variable is checked, adds it to the variables array.
+ * When a variable is unchecked, removes it from the variables array.
+ * Also updates the taskVariablesKeys object with the checked state.
+ */
+ const handleChangeTaskVariables = (e, variable) => {
+ const { checked } = e.target;
+ if (checked) {
+ setVariables((prev) => [
+ ...prev,
+ { name: variable.key, label: variable.label },
+ ]);
+ } else {
+ setVariables((prev) => prev.filter((i) => i.name !== variable.key));
+ }
+ /**
+ * Updates the taskVariablesKeys object with the checked state
+ * of the variable. If checked is true, adds the variable key.
+ * If checked is false, removes the variable key.
+ */
+ setTaskVariablesKeys((prev) => ({
+ ...prev,
+ [variable.key]: checked ? variable.key : null,
+ }));
+ };
+
+ const handleSave = () => {
+ onSaveTaskAttribute(
+ taskVariablesKeys,
+ variables,
+ checkboxes,
+ // selectUndefinedVariable
+ );
+ onHide();
};
+
return (
- {(t) => t("Task Attribute")}
-
+
+ {(t) => t("Task Attribute")}
+
+
-
{(t) => t("Only selected task attributes will be available on task list view")}
+
+
+ {(t) =>
+ t(
+ "Select the predefined attributes and custom task variables created as part of form submission you wish to display in the task list"
+ )
+ }
+ {" "}
+