diff --git a/forms-flow-web/src/components/Form/constants/ClientTable.js b/forms-flow-web/src/components/Form/constants/ClientTable.js index 0d13fb5165..9b873319d4 100644 --- a/forms-flow-web/src/components/Form/constants/ClientTable.js +++ b/forms-flow-web/src/components/Form/constants/ClientTable.js @@ -1,5 +1,9 @@ import React, { useState, useEffect } from "react"; -import { InputGroup, FormControl, Dropdown, Modal } from "react-bootstrap"; +import { + InputGroup, + FormControl, + Dropdown, +} from "react-bootstrap"; import { useDispatch, useSelector } from "react-redux"; import { push } from "connected-react-router"; import Pagination from "react-js-pagination"; @@ -38,8 +42,7 @@ function ClientTable() { const searchText = useSelector((state) => state.bpmForms.searchText); const [search, setSearch] = useState(searchText || ""); const redirectUrl = MULTITENANCY_ENABLED ? `/tenant/${tenantKey}/` : "/"; - const [selectedForExpand, setSelectedForExpand] = useState(null); - const [openDetailsModal, setOpenDetailsModal] = useState(false); + const [openIndex, setOpenIndex] = useState(null); const pageOptions = [ { text: "5", value: 5 }, @@ -50,6 +53,7 @@ function ClientTable() { ]; const updateSort = (updatedSort) => { + resetIndex(); dispatch(setBPMFormListSort(updatedSort)); dispatch(setBPMFormListPage(1)); }; @@ -65,21 +69,28 @@ function ClientTable() { }, [search]); const handleSearch = () => { + resetIndex(); dispatch(setBpmFormSearch(search)); dispatch(setBPMFormListPage(1)); }; const submitNewForm = (formId) => { - if(selectedForExpand) handleCloseModal(); + dispatch(push(`${redirectUrl}form/${formId}`)); }; + const resetIndex = () => { + if (openIndex !== null) setOpenIndex(null); + }; + const handleClearSearch = () => { + resetIndex(); setSearch(""); dispatch(setBpmFormSearch("")); }; const handlePageChange = (page) => { + resetIndex(); dispatch(setBPMFormListPage(page)); }; @@ -118,68 +129,17 @@ function ClientTable() { return textContent; }; - const handleCloseModal = () => { - setSelectedForExpand(null); - setOpenDetailsModal(false); - }; + - const handleModalOpen = (data) => { - setSelectedForExpand(data); - setOpenDetailsModal(true); - }; + + const handleToggle = (index) => { + setOpenIndex(openIndex === index ? null : index); + }; return ( <> - - -
-

{t("Form Details")}

-
- - - -
-
-
- -
-
-

- {t("Form Title")} -

-

{selectedForExpand?.title}

-
- -
-

- {t("Form Description")} -

- -
-
-
- - - -
+
@@ -257,6 +217,18 @@ function ClientTable() { + + {index === openIndex && + + + + } ))}
+ {!isDesigner && ( + + )} {e.title} - - {!isDesigner && e.description && ( - - )} +
+
+

+ {t("Form Description")} +

+ +
+
+