Skip to content

Commit

Permalink
search filter issues (AOT-Technologies#1890)
Browse files Browse the repository at this point in the history
  • Loading branch information
fahad-aot authored and gbates101 committed Feb 9, 2024
1 parent 3bf448a commit b916028
Showing 1 changed file with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ const TaskFilterViewComponent = React.memo(
const dispatch = useDispatch();
const { t } = useTranslation();
const [assigneeOptions, setAssigneeOptions] = useState([]);
const [inputValuesPresent, setInputValuesPresent] = useState(false); // State to track any input value is present or not

const handleClick = (e) => {
if (createSearchNode?.current?.contains(e.target)) {
return;
Expand Down Expand Up @@ -144,6 +146,16 @@ const TaskFilterViewComponent = React.memo(
setDisplayFilter(false);
};

//To disable the show results & clear filter btn if there no input values
useEffect(() => {
setInputValuesPresent(
( assignee || candidateGroup || processVariables?.length || dueStartDate || dueEndDate ||
followStartDate || followEndDate || createdStartDate || createdEndDate ||
priority || Object.keys(filterParams)?.length)
);
}, [assignee, candidateGroup, processVariables, dueStartDate, dueEndDate,
followStartDate, followEndDate, createdStartDate, createdEndDate, priority]);

const clearAllFilters = () => {
setAssignee("");
setCandidateGroup("");
Expand Down Expand Up @@ -427,18 +439,19 @@ const TaskFilterViewComponent = React.memo(
<button
className="btn btn-link text-danger"
onClick={() => clearAllFilters()}
disabled={!inputValuesPresent}
>
{t("Clear All Filters")}
</button>
</Col>
<Col className="text-right">
<Col className="text-end">
<button
className="btn btn-light me-1 "
onClick={() => setDisplayFilter(false)}
>
{t("Cancel")}
</button>
<button className="btn btn-dark" onClick={() => applyFilters()}>
<button disabled={!inputValuesPresent} className="btn btn-dark" onClick={() => applyFilters()}>
{t("Show results")}
</button>
</Col>
Expand Down

0 comments on commit b916028

Please sign in to comment.