From eaa21309ff305feec57d7c82313e7cb45d94dd50 Mon Sep 17 00:00:00 2001 From: Ajay krishna Date: Wed, 20 Mar 2024 17:40:27 +0530 Subject: [PATCH 1/2] modal added for delete filter and truncate addd for lengthy filter name --- .../components/Form/constants/FormTable.js | 7 +- .../ServiceFlow/list/sort/CreateNewFilter.js | 88 +++++++++++++++++-- forms-flow-web/src/containers/TaskHead.js | 9 +- 3 files changed, 95 insertions(+), 9 deletions(-) diff --git a/forms-flow-web/src/components/Form/constants/FormTable.js b/forms-flow-web/src/components/Form/constants/FormTable.js index 9da3d37135..1dcacdcb35 100644 --- a/forms-flow-web/src/components/Form/constants/FormTable.js +++ b/forms-flow-web/src/components/Form/constants/FormTable.js @@ -300,12 +300,15 @@ function FormTable() { - + 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 6bb84faf84..625e83528e 100644 --- a/forms-flow-web/src/components/ServiceFlow/list/sort/CreateNewFilter.js +++ b/forms-flow-web/src/components/ServiceFlow/list/sort/CreateNewFilter.js @@ -33,7 +33,14 @@ import TaskAttributeComponent from "./TaskAttributeComponent"; import { toast } from "react-toastify"; import { getUserRoles } from "../../../../apiManager/services/authorizationService"; import { setUserGroups } from "../../../../actions/authorizationActions"; -import { Badge, ListGroup, OverlayTrigger, Popover } from "react-bootstrap"; +import { + Badge, + ListGroup, + OverlayTrigger, + Popover, + Modal, + Button, +} from "react-bootstrap"; import { trimFirstSlash } from "../../constants/taskConstants"; import { cloneDeep, omitBy } from "lodash"; import { @@ -112,6 +119,8 @@ export default function CreateNewFilterDrawer({ const { t } = useTranslation(); const [modalShow, setModalShow] = useState(false); const [checkboxes, setCheckboxes] = useState(initialValueOfTaskAttribute); + const [showDeleteModal, setShowDeleteModal] = useState(false); + const [showAlert, setShowAlert] = useState(false); const fetchTasks = (resData) => { const reqParamData = { @@ -543,6 +552,37 @@ export default function CreateNewFilterDrawer({ setShowUndefinedVariable(showUndefinedVariable); }; + + const hideDeleteConfirmation = () => { + setShowDeleteModal(false); + }; + + const showDeleteConfirmation = () => { + setShowDeleteModal(true); + toggleDrawer(); + }; + + const FilterDelete = () => { + hideDeleteConfirmation(); + handleFilterDelete(); + }; + + const textTruncate = (wordLength, targetLength, text) => { + return text?.length > wordLength + ? text.substring(0, targetLength) + "..." + : text; + }; + + const handleFilterName = (e) => { + const value = e.target.value; + setFilterName(value); + if (value.length >= 50) { + setShowAlert(true); + } else { + setShowAlert(false); + } + }; + const list = () => (
@@ -560,13 +600,19 @@ export default function CreateNewFilterDrawer({ setFilterName(e.target.value)} + onChange={handleFilterName} title={t("Add fliter name")} + /> + {showAlert && ( +

+ {t("Filter name should be less than 50 characters")} +

+ )}
@@ -835,8 +881,7 @@ export default function CreateNewFilterDrawer({ + + + ); } diff --git a/forms-flow-web/src/containers/TaskHead.js b/forms-flow-web/src/containers/TaskHead.js index a5cfad6b35..5e69ce1f62 100644 --- a/forms-flow-web/src/containers/TaskHead.js +++ b/forms-flow-web/src/containers/TaskHead.js @@ -45,6 +45,12 @@ function TaskHead() { const count = isTaskListLoading ? "" : `(${itemCount})`; + const textTruncate = (wordLength, targetLength, text) => { + return text?.length > wordLength + ? text.substring(0, targetLength) + "..." + : text; + }; + return (
@@ -55,7 +61,8 @@ function TaskHead() { {selectedFilter?.name ? - `${selectedFilter?.name} ${count}` : filterListLoading() } + textTruncate(25, 23, `${selectedFilter?.name} ${count}`) : + filterListLoading() } } onClick={goToTask} From 0bdfbb9b980ccb32b98abe2011c6589484a31655 Mon Sep 17 00:00:00 2001 From: Ajay krishna Date: Fri, 22 Mar 2024 14:15:25 +0530 Subject: [PATCH 2/2] toggle drawer added while canceling the delete filter modal --- .../src/components/ServiceFlow/list/sort/CreateNewFilter.js | 6 ++++++ 1 file changed, 6 insertions(+) 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 625e83528e..71b78c52a0 100644 --- a/forms-flow-web/src/components/ServiceFlow/list/sort/CreateNewFilter.js +++ b/forms-flow-web/src/components/ServiceFlow/list/sort/CreateNewFilter.js @@ -512,6 +512,11 @@ export default function CreateNewFilterDrawer({ setOpenFilterDrawer(!openFilterDrawer); }; + const deleteConfirmationModalToggleDrawer = () => { + setOpenFilterDrawer(!openFilterDrawer); + }; + + const candidateGroups = useSelector( (state) => state.user?.userDetail?.groups || [] ); @@ -555,6 +560,7 @@ export default function CreateNewFilterDrawer({ const hideDeleteConfirmation = () => { setShowDeleteModal(false); + deleteConfirmationModalToggleDrawer(); }; const showDeleteConfirmation = () => {