Skip to content

Commit

Permalink
set default value true to includeAssingnedTask (#1957)
Browse files Browse the repository at this point in the history
  • Loading branch information
shuhaib-aot authored Mar 19, 2024
1 parent 61e0cbb commit 2e67643
Showing 1 changed file with 82 additions and 101 deletions.
183 changes: 82 additions & 101 deletions forms-flow-web/src/components/ServiceFlow/list/sort/CreateNewFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -49,7 +47,6 @@ import {
} from "../../../../apiManager/services/processServices";
import { fetchUserList } from "../../../../apiManager/services/bpmTaskServices";


const initialValueOfTaskAttribute = {
applicationId: true,
assignee: true,
Expand All @@ -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,
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -176,19 +171,18 @@ export default function CreateNewFilterDrawer({
}
setCandidateGroup(candidateGroupName);
setAssignee(selectedFilterData?.criteria?.assignee);
setIncludeAssignedTasks(
selectedFilterData?.criteria?.includeAssignedTasks
);
setShowUndefinedVariable(
selectedFilterData?.properties?.showUndefinedVariable
);

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);
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -338,7 +334,6 @@ export default function CreateNewFilterDrawer({
setDefinitionKeyId("");
setCandidateGroup("");
setAssignee("");
setIncludeAssignedTasks("");
setPermissions(PRIVATE_ONLY_YOU);
setIdentifierId("");
setSelectUserGroupIcon("");
Expand Down Expand Up @@ -390,7 +385,8 @@ export default function CreateNewFilterDrawer({
? tenantKey + "-" + candidateGroup
: candidateGroup,
assignee: assignee,
includeAssignedTasks: includeAssignedTasks,
includeAssignedTasks:
isTasksForCurrentUserGroupsEnabled || candidateGroup ? true : null,
},
properties: {
showUndefinedVariable: showUndefinedVariable,
Expand All @@ -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;

Expand Down Expand Up @@ -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") {
Expand Down Expand Up @@ -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);
};

Expand Down Expand Up @@ -600,6 +594,7 @@ export default function CreateNewFilterDrawer({
</Translation>
</h5>
</div>

{userRoles.includes(FORMSFLOW_ADMIN) && (
<>
<div className="d-flex align-items-center mt-1">
Expand Down Expand Up @@ -629,75 +624,59 @@ export default function CreateNewFilterDrawer({
</>
)}

<h5 className="mt-2 fs-18 fw-bold">
<Translation>{(t) => t("Workflow")}</Translation>
</h5>
<Select
className="mb-3"
options={processList}
placeholder={t("Select Workflow")}
isClearable
value={
processList?.find(
(list) => list.label === definitionKeyId
)
}
onChange={(selectedOption) => {
setDefinitionKeyId(selectedOption?.label);
}
}
inputId="select-workflow"
getOptionLabel={(option) => (
<span data-testid={`form-workflow-option-${option.value}`}>{option.label}</span>
)}
/>

<div className="my-2">
<h5 className="mt-2 fs-18 fw-bold">
<Translation>{(t) => t("Workflow")}</Translation>
</h5>
<Select
className="mb-3"
options={processList}
placeholder={t("Select Workflow")}
isClearable
value={processList?.find((list) => list.label === definitionKeyId)}
onChange={(selectedOption) => {
setDefinitionKeyId(selectedOption?.label);
}}
inputId="select-workflow"
getOptionLabel={(option) => (
<span data-testid={`form-workflow-option-${option.value}`}>
{option.label}
</span>
)}
/>
</div>

<List>
<div className="my-2">
<h5 className="fw-bold">
<Translation>{(t) => t("Candidate Group")}</Translation>
</h5>
</List>
<Select
onChange={handleCandidate}
value={candidateGroup ? { value: candidateGroup, label: candidateGroup } : null}
isClearable={true}
placeholder={t("Select Candidate Group")}
options={candidateOptions}
/>



<Select
onChange={handleCandidate}
value={
candidateGroup
? { value: candidateGroup, label: candidateGroup }
: null
}
isClearable={true}
placeholder={t("Select Candidate Group")}
options={candidateOptions}
/>
</div>

<List>
<div className="my-2">
<h5 className="pt-2 fw-bold">
<Translation>{(t) => t("Assignee")}</Translation>
</h5>
</List>


<Select
onChange={handleAssignee}
value={assignee ? { value: assignee, label: assignee } : null}
isClearable={true}
placeholder={t("Select Assignee")}
options={assigneeOptions}
/>

{candidateGroup?.length ? (
<div className="d-flex align-items-center input-container mt-2">
<input
className="mr-6"
type="checkbox"
id="assignedTask-checkbox"
checked={includeAssignedTasks}
onChange={includeAssignedTasksCheckboxChange}
/>
<h5 className="assigned-user">
<Translation>{(t) => t("Include Assigned Task")}</Translation>
</h5>
</div>
) : null}

<Select
onChange={handleAssignee}
value={assignee ? { value: assignee, label: assignee } : null}
isClearable={true}
placeholder={t("Select Assignee")}
options={assigneeOptions}
/>
</div>

<div className="my-3">
<Divider />
Expand Down Expand Up @@ -782,7 +761,7 @@ export default function CreateNewFilterDrawer({
</label>{" "}
<br />
{permissions === SPECIFIC_USER_OR_GROUP &&
specificUserGroup === SPECIFIC_USER_OR_GROUP ? (
specificUserGroup === SPECIFIC_USER_OR_GROUP ? (
<div className="d-flex">
<OverlayTrigger
placement="right"
Expand Down Expand Up @@ -819,8 +798,9 @@ export default function CreateNewFilterDrawer({
</div>
<div className="text-center text-bottom">
<i
className={`fa fa-users ${selectUserGroupIcon === "group" ? "highlight" : ""
} cursor-pointer group-icon`}
className={`fa fa-users ${
selectUserGroupIcon === "group" ? "highlight" : ""
} cursor-pointer group-icon`}
/>
</div>
</div>
Expand Down Expand Up @@ -880,7 +860,8 @@ export default function CreateNewFilterDrawer({
>
<Translation>
{(t) =>
`${selectedFilterData ? t("Save Filter") : t("Create Filter")
`${
selectedFilterData ? t("Save Filter") : t("Create Filter")
} `
}
</Translation>
Expand Down

0 comments on commit 2e67643

Please sign in to comment.