From 2e67643dc97ae57d8bb69de1edd72f9541c42f79 Mon Sep 17 00:00:00 2001 From: shuhaib s <95394061+shuhaib-aot@users.noreply.github.com> Date: Tue, 19 Mar 2024 13:45:45 +0530 Subject: [PATCH] set default value true to includeAssingnedTask (#1957) --- .../ServiceFlow/list/sort/CreateNewFilter.js | 183 ++++++++---------- 1 file changed, 82 insertions(+), 101 deletions(-) diff --git a/forms-flow-web/src/components/ServiceFlow/list/sort/CreateNewFilter.js b/forms-flow-web/src/components/ServiceFlow/list/sort/CreateNewFilter.js index 2536d6f7c0..6bb84faf84 100644 --- a/forms-flow-web/src/components/ServiceFlow/list/sort/CreateNewFilter.js +++ b/forms-flow-web/src/components/ServiceFlow/list/sort/CreateNewFilter.js @@ -32,9 +32,7 @@ import { import TaskAttributeComponent from "./TaskAttributeComponent"; import { toast } from "react-toastify"; import { getUserRoles } from "../../../../apiManager/services/authorizationService"; -import { - setUserGroups, -} from "../../../../actions/authorizationActions"; +import { setUserGroups } from "../../../../actions/authorizationActions"; import { Badge, ListGroup, OverlayTrigger, Popover } from "react-bootstrap"; import { trimFirstSlash } from "../../constants/taskConstants"; import { cloneDeep, omitBy } from "lodash"; @@ -49,7 +47,6 @@ import { } from "../../../../apiManager/services/processServices"; import { fetchUserList } from "../../../../apiManager/services/bpmTaskServices"; - const initialValueOfTaskAttribute = { applicationId: true, assignee: true, @@ -74,7 +71,6 @@ export default function CreateNewFilterDrawer({ const [candidateGroup, setCandidateGroup] = useState([]); const userRoles = useSelector((state) => state.user.roles || []); const [assignee, setAssignee] = useState(""); - const [includeAssignedTasks, setIncludeAssignedTasks] = useState(false); const [ isTasksForCurrentUserGroupsEnabled, @@ -112,7 +108,6 @@ export default function CreateNewFilterDrawer({ const [overlayGroupShow, setOverlayGroupShow] = useState(false); const [overlayUserShow, setOverlayUserShow] = useState(false); - const { t } = useTranslation(); const [modalShow, setModalShow] = useState(false); @@ -176,9 +171,6 @@ export default function CreateNewFilterDrawer({ } setCandidateGroup(candidateGroupName); setAssignee(selectedFilterData?.criteria?.assignee); - setIncludeAssignedTasks( - selectedFilterData?.criteria?.includeAssignedTasks - ); setShowUndefinedVariable( selectedFilterData?.properties?.showUndefinedVariable ); @@ -186,9 +178,11 @@ export default function CreateNewFilterDrawer({ if (selectedFilterData?.properties?.formId) { setSelectedForm(selectedFilterData?.properties?.formId || null); setProcessLoading(true); - dispatch(getFormProcesses(selectedFilterData?.properties?.formId, () => { - setProcessLoading(false); - })); + dispatch( + getFormProcesses(selectedFilterData?.properties?.formId, () => { + setProcessLoading(false); + }) + ); } setTaskVariablesAndItsKeys(selectedFilterData.variables); @@ -280,9 +274,11 @@ export default function CreateNewFilterDrawer({ const onChangeSelectForm = (e) => { if (e?.value) { setProcessLoading(true); - dispatch(getFormProcesses(e.value, () => { - setProcessLoading(false); - })); + dispatch( + getFormProcesses(e.value, () => { + setProcessLoading(false); + }) + ); if (e?.value === selectedFilterData?.properties?.formId) { setTaskVariablesAndItsKeys(selectedFilterData?.variables); } else { @@ -338,7 +334,6 @@ export default function CreateNewFilterDrawer({ setDefinitionKeyId(""); setCandidateGroup(""); setAssignee(""); - setIncludeAssignedTasks(""); setPermissions(PRIVATE_ONLY_YOU); setIdentifierId(""); setSelectUserGroupIcon(""); @@ -390,7 +385,8 @@ export default function CreateNewFilterDrawer({ ? tenantKey + "-" + candidateGroup : candidateGroup, assignee: assignee, - includeAssignedTasks: includeAssignedTasks, + includeAssignedTasks: + isTasksForCurrentUserGroupsEnabled || candidateGroup ? true : null, }, properties: { showUndefinedVariable: showUndefinedVariable, @@ -417,8 +413,9 @@ export default function CreateNewFilterDrawer({ } // Remove empty keys inside criteria - const cleanedCriteria = omitBy(data.criteria, value => - value === undefined || value === '' || value === null + const cleanedCriteria = omitBy( + data.criteria, + (value) => value === undefined || value === "" || value === null ); data.criteria = cleanedCriteria; @@ -472,12 +469,6 @@ export default function CreateNewFilterDrawer({ } }; - - //Function For checking includeAssignedTasksCheckbox is checked or not - const includeAssignedTasksCheckboxChange = (e) => { - setIncludeAssignedTasks(e.target.checked); - }; - //Function to checking which icon is selected const handleClickUserGroupIcon = (icon) => { if (icon === "user") { @@ -510,30 +501,33 @@ export default function CreateNewFilterDrawer({ const toggleModal = () => { setModalShow(!modalShow); setOpenFilterDrawer(!openFilterDrawer); - }; - const candidateGroups = useSelector((state) => state.user?.userDetail?.groups || []); - const userListResponse = useSelector((state) => state.bpmTasks.userList) || { data: [] }; + const candidateGroups = useSelector( + (state) => state.user?.userDetail?.groups || [] + ); + const userListResponse = useSelector((state) => state.bpmTasks.userList) || { + data: [], + }; const userList = userListResponse?.data || []; const assigneeOptions = useMemo(() => { - return userList.map(user => ({ + return userList.map((user) => ({ value: `${user.firstName} ${user.lastName}`, - label: `${user.firstName} ${user.lastName}` + label: `${user.firstName} ${user.lastName}`, })); }, [userList]); const candidateOptions = useMemo(() => { - return candidateGroups.map(group => ({ - value: group, - label: trimFirstSlash(group) - })); -}, [candidateGroups]); + return candidateGroups.map((group) => ({ + value: group, + label: trimFirstSlash(group), + })); + }, [candidateGroups]); - const handleAssignee = selectedOption => { + const handleAssignee = (selectedOption) => { setAssignee(selectedOption ? selectedOption.value : null); }; - const handleCandidate = selectedOption => { + const handleCandidate = (selectedOption) => { setCandidateGroup(selectedOption ? selectedOption.value : null); }; @@ -600,6 +594,7 @@ export default function CreateNewFilterDrawer({ + {userRoles.includes(FORMSFLOW_ADMIN) && ( <>