diff --git a/forms-flow-web/src/components/CustomComponents/Button.js b/forms-flow-web/src/components/CustomComponents/Button.js
deleted file mode 100644
index 4478d4ca2b..0000000000
--- a/forms-flow-web/src/components/CustomComponents/Button.js
+++ /dev/null
@@ -1,115 +0,0 @@
-import React from "react";
-import { useRef, useEffect, useState } from "react";
-import Button from "react-bootstrap/Button";
-import ButtonGroup from "react-bootstrap/ButtonGroup";
-import Dropdown from "react-bootstrap/Dropdown";
-import { ChevronIcon } from "@formsflow/components";
-
-const CustomButton = ({
- variant,
- size,
- label,
- onClick,
- isDropdown,
- dropdownItems,
- disabled,
- icon,
- className,
- dataTestid,
- ariaLabel,
- buttonLoading,
-}) => {
- const buttonRef = useRef(null);
- const toggleRef = useRef(null);
- const [menuStyle, setMenuStyle] = useState({});
- const [dropdownOpen, setDropdownOpen] = useState(false);
-
- const updateMenuStyle = () => {
- if (buttonRef.current && toggleRef.current) {
- const buttonWidth = buttonRef.current.getBoundingClientRect().width;
- const toggleWidth = toggleRef.current.getBoundingClientRect().width;
- const totalWidth = buttonWidth + toggleWidth - 1;
- setMenuStyle({
- minWidth: `${totalWidth}px`,
- borderTop: "none",
- borderTopLeftRadius: "0",
- borderTopRightRadius: "0",
- padding: "0",
- });
- }
- };
-
- useEffect(() => {
- updateMenuStyle();
- window.addEventListener("resize", updateMenuStyle);
- return () => window.removeEventListener("resize", updateMenuStyle);
- }, []);
-
- if (isDropdown) {
- return (
- setDropdownOpen(isOpen)}
- >
-
-
-
-
-
-
-
- {dropdownItems.map((item, index) => (
-
- {item.label}
-
- ))}
-
-
- );
- }
-
- return (
-
- );
-};
-
-export default CustomButton;
diff --git a/forms-flow-web/src/components/CustomComponents/SortableHeader.js b/forms-flow-web/src/components/CustomComponents/SortableHeader.js
new file mode 100644
index 0000000000..9bf8710f45
--- /dev/null
+++ b/forms-flow-web/src/components/CustomComponents/SortableHeader.js
@@ -0,0 +1,59 @@
+import React from 'react';
+import PropTypes from 'prop-types';
+import { useTranslation } from "react-i18next";
+
+const SortableHeader = ({ columnKey, title, currentSort, handleSort,className }) => {
+ const { t } = useTranslation();
+ const isSorted = currentSort.sortBy === columnKey;
+ const sortedOrder = isSorted ? currentSort.sortOrder : "asc";
+ const handleKeyDown = (event)=>{
+ if (event.key === 'Enter') {
+ handleSort(columnKey);
+ }
+ };
+ return (
+
handleSort(columnKey)}
+ onKeyDown={handleKeyDown}
+ role="button"
+ tabIndex = "0"
+ aria-pressed={isSorted}
+ >
+ {t(title)}
+
+ {sortedOrder === "asc" ? (
+
+ ) : (
+
+ )}
+
+
+ );
+ };
+ SortableHeader.propTypes = {
+ columnKey: PropTypes.string.isRequired,
+ title: PropTypes.string.isRequired,
+ currentSort: PropTypes.shape({
+ sortBy: PropTypes.string,
+ sortOrder: PropTypes.string
+ }).isRequired,
+ handleSort: PropTypes.func.isRequired,
+ className: PropTypes.string
+ };
+
+ SortableHeader.defaultProps = {
+ className: '',
+ };
+
+ export default SortableHeader ;
\ No newline at end of file
diff --git a/forms-flow-web/src/components/Form/constants/FormTable.js b/forms-flow-web/src/components/Form/constants/FormTable.js
index cf04c8bff6..e79622ac3c 100644
--- a/forms-flow-web/src/components/Form/constants/FormTable.js
+++ b/forms-flow-web/src/components/Form/constants/FormTable.js
@@ -1,5 +1,4 @@
import React, { useEffect, useState } from "react";
-import PropTypes from 'prop-types';
import { Dropdown } from "react-bootstrap";
import { useDispatch, useSelector } from "react-redux";
import { push } from "connected-react-router";
@@ -22,6 +21,8 @@ import {
import { HelperServices } from "@formsflow/service";
import { CustomButton, DownArrowIcon } from "@formsflow/components";
import userRoles from "../../../constants/permissions";
+import SortableHeader from '../../CustomComponents/SortableHeader';
+
function FormTable() {
const tenantKey = useSelector((state) => state.tenants?.tenantId);
const dispatch = useDispatch();
@@ -119,52 +120,7 @@ function FormTable() {
);
};
- const SortableHeader = ({ columnKey, title, currentFormSort, handleSort,className }) => {
- const isSorted = currentFormSort.sortBy === columnKey;
- const sortedOrder = isSorted ? currentFormSort.sortOrder : "asc";
- const handleKeyDown = (event)=>{
- if (event.key === 'Enter') {
- handleSort(columnKey);
- }
- };
- return (
- handleSort(columnKey)}
- onKeyDown={handleKeyDown}
- role="button"
- >
- {t(title)}
-
- {sortedOrder === "asc" ? (
-
- ) : (
-
- )}
-
-
- );
- };
- SortableHeader.propTypes = {
- columnKey: PropTypes.string.isRequired,
- title: PropTypes.string.isRequired,
- currentFormSort: PropTypes.shape({
- sortBy: PropTypes.string,
- sortOrder: PropTypes.string
- }).isRequired,
- handleSort: PropTypes.func.isRequired,
- className: PropTypes.string
- };
+
return (
<>
@@ -177,7 +133,7 @@ function FormTable() {
@@ -187,7 +143,7 @@ function FormTable() {
@@ -195,14 +151,14 @@ function FormTable() {
|
|
diff --git a/forms-flow-web/src/components/Modeler/SubFlowTable.js b/forms-flow-web/src/components/Modeler/SubFlowTable.js
index 0fedcc60b8..ca80670d4b 100644
--- a/forms-flow-web/src/components/Modeler/SubFlowTable.js
+++ b/forms-flow-web/src/components/Modeler/SubFlowTable.js
@@ -17,13 +17,13 @@ import {
} from "../../actions/processActions";
import { push } from "connected-react-router";
import { MULTITENANCY_ENABLED } from "../../constants/constants";
+import SortableHeader from '../CustomComponents/SortableHeader';
const SubFlow = React.memo(() => {
const searchText = useSelector((state) => state.process.bpmnSearchText);
const tenantKey = useSelector((state) => state.tenants?.tenantId);
const redirectUrl = MULTITENANCY_ENABLED ? `/tenant/${tenantKey}/` : "/";
const [limit, setLimit] = useState(5);
- // const [totalProcess, setTotalProcess] = useState(0);
const dispatch = useDispatch();
const { t } = useTranslation();
const [activePage, setActivePage] = useState(1);
@@ -31,7 +31,7 @@ const SubFlow = React.memo(() => {
const process = useSelector((state) => state.process.processList);
const totalSubflowCount = useSelector((state) => state.process.totalCount);
const [search, setSearch] = useState(searchText || "");
- const [sort, setSort] = useState({ name: "asc" });
+ const [currentBPMNsort, setSort] = useState({ sortBy:"name",sortOrder: "asc" });
const [searchSubflowLoading, setSearchSubflowLoading] = useState(false);
useEffect(() => {
setIsLoading(true);
@@ -44,8 +44,8 @@ const SubFlow = React.memo(() => {
processType: "BPMN",
limit: limit,
searchKey: search,
- sortBy: Object.keys(sort),
- sortOrder: Object.values(sort),
+ sortBy: currentBPMNsort.sortBy,
+ sortOrder: currentBPMNsort.sortOrder,
},
() => {
setIsLoading(false);
@@ -53,10 +53,22 @@ const SubFlow = React.memo(() => {
}
)
);
- }, [dispatch, activePage, limit, searchText, sort]);
+ }, [dispatch, activePage, limit, searchText, currentBPMNsort]);
- // const handleSort = (key,value)=> setSort(prev => ({...prev,[key]:value}));
- const handleSort = (key, value) => setSort({ [key]: value });
+
+ const handleSort = (key) => {
+ setSort((prevSort) => {
+ let newSortOrder = "asc";
+
+ if (prevSort.sortBy === key) {
+ newSortOrder = prevSort.sortOrder === "asc" ? "desc" : "asc";
+ }
+ return {
+ sortBy: key,
+ sortOrder: newSortOrder,
+ };
+ });
+ };
const pageOptions = [
{
text: "5",
@@ -97,7 +109,6 @@ const SubFlow = React.memo(() => {
if (MULTITENANCY_ENABLED) {
dispatch(setIsPublicDiagram(data.tenantId ? true : false));
}
- // dispatch(push(`${redirectUrl}process/${data.parentProcessKey}`));
dispatch(
push(`${redirectUrl}processes/bpmn/${data.parentProcessKey}/edit`)
);
@@ -134,121 +145,37 @@ const SubFlow = React.memo(() => {
- {
- handleSort(
- "name",
- sort["name"] == "asc" ? "desc" : "asc"
- );
- }}
- >
- {t("Name")}
-
- {sort["name"] == "asc" ? (
-
- ) : (
-
- )}
-
- {" "}
+
+
|
- {
- handleSort("id", sort["id"] == "asc" ? "desc" : "asc");
- }}
- >
- {t("id")}
-
- {sort["id"] == "asc" ? (
-
- ) : (
-
- )}
-
-
+
|
- {
- handleSort(
- "modified",
- sort["modified"] == "asc" ? "desc" : "asc"
- );
- }}
- >
- {t("Last Edited")}
-
- {sort["modified"] == "asc" ? (
-
- ) : (
-
- )}
-
-
+
|
- {
- handleSort(
- "status",
- sort["status"] == "asc" ? "desc" : "asc"
- );
- }}
- >
- {t("Status")}
-
- {sort["status"] == "asc" ? (
-
- ) : (
-
- )}
-
-
+
|
|