Skip to content

Commit 885d849

Browse files
Merge pull request #2997 from fahad-aot/feature/fwf-5453-actions-dmn-bpmn
feature/fwf-5453:added action page form bpmn and dmn
2 parents 1e946a0 + e9982a7 commit 885d849

File tree

5 files changed

+391
-44
lines changed

5 files changed

+391
-44
lines changed

forms-flow-web/src/components/Form/constants/FormTable.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,11 @@ const viewOrEditForm = (formId, path) => {
133133
dispatch(resetFormProcessData());
134134
dispatch(push(`${redirectUrl}formflow/${formId}/${path}`));
135135
};
136-
const handlePageChange = (page) => {
136+
137+
const handlePageChange = (page) => {
137138
dispatch(setBPMFormListPage(page));
138139
};
140+
139141

140142
const handleSortChange = (modelArray) => {
141143
const model = Array.isArray(modelArray) ? modelArray[0] : modelArray;
@@ -145,8 +147,8 @@ const viewOrEditForm = (formId, path) => {
145147
return acc;
146148
}, {});
147149
dispatch(setBpmFormSort({ ...resetSort, activeKey: "formName" }));
148-
dispatch(setBPMFormListPage(1));
149-
return;
150+
dispatch(setBPMFormListPage(1));
151+
return;
150152
}
151153

152154
const mappedKey = gridFieldToSortKey[model.field] || model.field;
@@ -160,11 +162,6 @@ const viewOrEditForm = (formId, path) => {
160162
};
161163

162164

163-
const handleLimitChange = (limitVal) => {
164-
dispatch(setBPMFormLimit(limitVal));
165-
dispatch(setBPMFormListPage(1));
166-
};
167-
168165
const handleRefresh = () => {
169166
let filters = {pageNo, limit, formSort: formsort, formName: searchText};
170167
dispatch(setFormSearchLoading(true));
@@ -174,10 +171,19 @@ const viewOrEditForm = (formId, path) => {
174171
const activeKey = bpmForms.sort?.activeKey || "formName";
175172
const activeField = sortKeyToGridField[activeKey] || activeKey;
176173
const activeOrder = bpmForms.sort?.[activeKey]?.sortOrder || "asc";
174+
175+
176+
const handleLimitChange = (limitVal) => {
177+
dispatch(setBPMFormLimit(limitVal));
178+
dispatch(setBPMFormListPage(1));
179+
};
180+
181+
// DataGrid's onPaginationModelChange - handles both page and pageSize changes
177182
const onPaginationModelChange = ({ page, pageSize }) => {
178183
if (limit !== pageSize) handleLimitChange(pageSize);
179184
else if ((pageNo - 1) !== page) handlePageChange(page + 1);
180185
};
186+
181187
const rows = React.useMemo(() => {
182188
return (formData || []).map((f) => ({
183189
...f,
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
import React, { useState } from "react";
2+
import PropTypes from "prop-types";
3+
import { useTranslation } from "react-i18next";
4+
import {
5+
CustomProgressBar,
6+
SelectDropdown,
7+
V8CustomButton,
8+
} from "@formsflow/components";
9+
// import { StyleServices } from "@formsflow/service";
10+
11+
// A lightweight, inline Actions panel rendered as a tab instead of a modal.
12+
const ProcessActionsTab = ({
13+
newActionModal,
14+
renderUpload,
15+
onExport,
16+
diagramType,
17+
}) => {
18+
const { t } = useTranslation();
19+
// const primaryColor = StyleServices.getCSSVariable("--ff-primary");
20+
21+
// Get diagram-specific labels
22+
const diagramLabel = diagramType || "Process";
23+
24+
// State for export functionality
25+
const [selectedValue, setSelectedValue] = useState("XML");
26+
const [progress, setProgress] = useState(0);
27+
const [isError, setIsError] = useState(false);
28+
const [isExporting, setIsExporting] = useState(false);
29+
30+
// Export format options based on diagram type
31+
const formExportOptions = [{ label: diagramLabel, value: "XML" }];
32+
33+
if (!newActionModal) return null;
34+
35+
const handleSelectChange = (value) => {
36+
setSelectedValue(value);
37+
};
38+
39+
const handleExportClick = async () => {
40+
if (!onExport) return;
41+
42+
setIsExporting(true);
43+
setProgress(0);
44+
setIsError(false);
45+
46+
try {
47+
// Simulate progress
48+
const progressInterval = setInterval(() => {
49+
setProgress((prev) => {
50+
if (prev >= 90) {
51+
clearInterval(progressInterval);
52+
return 90;
53+
}
54+
return prev + 10;
55+
});
56+
}, 200);
57+
58+
// Call the actual export function
59+
await onExport(selectedValue);
60+
61+
// Complete progress
62+
clearInterval(progressInterval);
63+
setProgress(100);
64+
65+
// Reset after success
66+
setTimeout(() => {
67+
setProgress(0);
68+
setIsExporting(false);
69+
}, 1000);
70+
} catch (error) {
71+
setIsError(true);
72+
setProgress(0);
73+
setIsExporting(false);
74+
}
75+
};
76+
77+
return (
78+
<div className="process-actions-tab" data-testid="process-actions-tab">
79+
<div className="grid-section">
80+
<div className="actions-header">{t(`Import ${diagramLabel}`)}</div>
81+
<div className="upload-action-content">
82+
{renderUpload && renderUpload()}
83+
</div>
84+
</div>
85+
<div className="grid-section">
86+
<div className="actions-header">{t(`Export ${diagramLabel}`)}</div>
87+
<div className="actions-contents">
88+
<div className="export-section">
89+
<div className="export-dropdown-section">
90+
<SelectDropdown
91+
options={formExportOptions}
92+
value={selectedValue}
93+
onChange={handleSelectChange}
94+
searchDropdown={false}
95+
ariaLabel={t("Select export format")}
96+
dataTestId="form-export-dropdown"
97+
variant="primary"
98+
/>
99+
<V8CustomButton
100+
variant="primary"
101+
onClick={handleExportClick}
102+
data-testid="form-export-btn"
103+
aria-label={t(`Export ${diagramLabel}`)}
104+
label={t("Export")}
105+
disabled={isExporting}
106+
loading={isExporting}
107+
/>
108+
</div>
109+
{isExporting && (
110+
<div className="export-progress-section">
111+
<div>
112+
{t("Export process as")} {selectedValue}
113+
</div>
114+
<div className="export-progress">
115+
<CustomProgressBar
116+
progress={progress}
117+
color={isError ? "error" : undefined}
118+
/>
119+
</div>
120+
</div>
121+
)}
122+
</div>
123+
</div>
124+
</div>
125+
</div>
126+
);
127+
};
128+
129+
ProcessActionsTab.propTypes = {
130+
newActionModal: PropTypes.bool.isRequired,
131+
diagramType: PropTypes.string,
132+
renderUpload: PropTypes.func,
133+
onExport: PropTypes.func,
134+
};
135+
136+
export default ProcessActionsTab;

0 commit comments

Comments
 (0)