Skip to content

Commit 46d24dc

Browse files
Merge pull request #2994 from rintumerin-aot/feature/FWF-5405-tab-designer-flow-history
Feature/fwf 5405 tab designer flow history
2 parents bc14077 + 2afc829 commit 46d24dc

File tree

3 files changed

+125
-18
lines changed

3 files changed

+125
-18
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,17 @@ Mark items as `Added`, `Changed`, `Fixed`, `Modified`, `Removed`, `Untested Fea
2828
* Fixed minor issues in Reviewer & Analyze Submissions page.
2929
* Fixed PDF generation issue with a generic custom theme.
3030

31+
`Modified`
32+
33+
**forms-flow-web**
34+
* Form.io token fetching logic has been moved to the service micro-frontend.
35+
36+
`Fixed`
37+
38+
* Sorting is now available for all columns on the review task listing page.
39+
* Fixed minor issues in Reviewer & Analyze Submissions page.
40+
* Fixed PDF generation issue with a generic custom theme.
41+
3142
*Upgrade notes:*
3243

3344
**forms-flow-bpm**

forms-flow-web/src/routes/Design/Forms/FlowEdit.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ const enableWorkflowChange = async () => {
480480
/>
481481
)}
482482

483-
{/* <HistoryModal
483+
{/* <HistoryPage
484484
show={showHistoryModal}
485485
onClose={handleToggleHistoryModal}
486486
title={t("History")}

forms-flow-web/src/routes/Design/Forms/FormEdit.js

Lines changed: 113 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,24 @@ const tabConfig = {
114114
},
115115
}
116116
},
117+
flow: {
118+
label: "Flow",
119+
query: "?tab=flow",
120+
secondary: {
121+
layout: {
122+
label: "Layout",
123+
query: "?tab=flow&sub=layout"
124+
},
125+
history: {
126+
label: "History",
127+
query: "?tab=flow&sub=history"
128+
},
129+
variables : {
130+
label: "Variables",
131+
query: "?tab=flow&sub=variables"
132+
},
133+
}
134+
},
117135
bpmn: {
118136
label: "BPMN",
119137
query: "?tab=bpmn",
@@ -168,7 +186,6 @@ const EditComponent = () => {
168186
/* ------------------------------- mapper data ------------------------------ */
169187
const { formProcessList: processListData, formPreviousData: previousData } =
170188
useSelector((state) => state.process);
171-
172189
/* -------------------------------- user data and form access data ------------------------------- */
173190
const {
174191
formAccess = [],
@@ -180,6 +197,8 @@ const EditComponent = () => {
180197
// created a copy for access and submissin access
181198
const [formAccessRoles, setFormAccessRoles] = useState(_cloneDeep(formAccess));
182199
const [submissionAccessRoles, setSubmissionAccessRoles] = useState(_cloneDeep(submissionAccess));
200+
const [formHistoryLoading, setFormHistoryLoading] = useState(false);
201+
const [flowHistoryLoading, setFlowHistoryLoading] = useState(false);
183202
const { path, display } = useSelector((state) => state.form.form);
184203

185204
const { authorizationDetails: formAuthorization } = useSelector(
@@ -437,7 +456,7 @@ const EditComponent = () => {
437456
}
438457
}
439458
);
440-
const [paginationModel] = useState({ page: 0, pageSize: 10 });
459+
const [paginationModel, setPaginationModel] = useState({ page: 0, pageSize: 10 });
441460

442461
const UploadActionType = {
443462
IMPORT: "import",
@@ -650,6 +669,7 @@ const EditComponent = () => {
650669
/* ------------------------- form history variables ------------------------- */
651670
const [isNewVersionLoading, setIsNewVersionLoading] = useState(false);
652671
const [restoreFormDataLoading, setRestoreFormDataLoading] = useState(false);
672+
653673
const {
654674
formHistoryData = {},
655675
restoredFormId,
@@ -739,9 +759,9 @@ useEffect(() => {
739759
if (activeTab.primary === "form" && activeTab.secondary === "history") {
740760
handleFormHistory();
741761
}
742-
if (activeTab.primary === "bpmn" && activeTab.secondary === "history") {
743-
handleBpmnHistory();
744-
}
762+
// if (activeTab.primary === "flow" && activeTab.secondary === "history") {
763+
// handleBpmnHistory();
764+
// }
745765
}, [activeTab.primary, activeTab.secondary, processListData?.parentFormId,
746766
paginationModel.pageSize]);
747767

@@ -766,7 +786,6 @@ useEffect(() => {
766786
}
767787

768788
const newTab = { primary, secondary, tertiary };
769-
console.log("newTab", newTab);
770789
setActiveTab(newTab);
771790

772791
// Update URL with new tab parameters
@@ -785,7 +804,6 @@ useEffect(() => {
785804
);
786805
} else {
787806
const newUrl = `${redirectUrl}formflow/${formId}/edit?${queryParams.toString()}`;
788-
console.log("newUrl", newUrl);
789807
dispatch(push(newUrl));
790808
}
791809
};
@@ -1218,20 +1236,22 @@ const saveFormWithWorkflow = async () => {
12181236
// setShowHistoryModal(false);
12191237
// };
12201238
const fetchFormHistory = (parentFormId, page, limit) => {
1239+
setFormHistoryLoading(true);
12211240
parentFormId = parentFormId && typeof parentFormId === 'string' ? parentFormId : processListData?.parentFormId;
12221241
page = page ? page : paginationModel.page + 1;
12231242
limit = limit ? limit : paginationModel.pageSize;
12241243
getFormHistory(parentFormId,page, limit)
12251244
.then((res) => {
12261245
dispatch(setFormHistories(res.data));
1246+
setFormHistoryLoading(false);
12271247
})
12281248
.catch(() => {
12291249
setFormHistories([]);
12301250
});
12311251
};
12321252

12331253
const handleFormHistory = () => {
1234-
console.log("handleFormHistory", processListData);
1254+
// setShowHistoryModal(true);
12351255
dispatch(setFormHistories({ formHistory: [], totalCount: 0 }));
12361256
if (processListData?.parentFormId) {
12371257
fetchFormHistory(processListData?.parentFormId, 1, paginationModel.pageSize);
@@ -1244,19 +1264,28 @@ const saveFormWithWorkflow = async () => {
12441264

12451265
/* ------------------------- BPMN history handlers ------------------------- */
12461266
const handleBpmnHistory = () => {
1247-
setBpmnHistoryData({ processHistory: [], totalCount: 0 });
1248-
if (processData?.parentProcessKey) {
1249-
fetchBpmnHistory(processData.parentProcessKey, 1, 4);
1267+
const parentKey = processData?.parentProcessKey;
1268+
if (!parentKey) {
1269+
setFlowHistoryLoading(false);
1270+
return;
12501271
}
1272+
setBpmnHistoryData({ processHistory: [], totalCount: 0 });
1273+
setFlowHistoryLoading(true);
1274+
fetchBpmnHistory(parentKey, paginationModel.page + 1, paginationModel.pageSize);
12511275
};
12521276

1253-
const fetchBpmnHistory = async (parentProcessKey, page = 1, limit = 4) => {
1277+
const fetchBpmnHistory = async (parentProcessKey, page, limit) => {
12541278
try {
12551279
const response = await getProcessHistory({ parentProcessKey, page, limit });
1256-
setBpmnHistoryData(response.data);
1280+
// setBpmnHistoryData(response.data);
1281+
// setFlowHistoryLoading(false);
1282+
const data = response?.data || { processHistory: [], totalCount: 0 };
1283+
setBpmnHistoryData(data);
12571284
} catch (error) {
12581285
console.error("Error fetching BPMN history:", error);
12591286
setBpmnHistoryData({ processHistory: [], totalCount: 0 });
1287+
} finally {
1288+
setFlowHistoryLoading(false);
12601289
}
12611290
};
12621291

@@ -1279,8 +1308,6 @@ const saveFormWithWorkflow = async () => {
12791308
}
12801309
};
12811310

1282-
1283-
12841311
const revertFormBtnAction = (cloneId) => {
12851312
dispatch(setRestoreFormId(cloneId));
12861313
fetchRestoredFormData(cloneId);
@@ -1860,6 +1887,28 @@ const saveFormWithWorkflow = async () => {
18601887
openConfirmModal(isPublished ? "unpublish" : "publish");
18611888
}
18621889
};
1890+
const handlePaginationModelChange = (newPaginationModel) => {
1891+
setPaginationModel(newPaginationModel);
1892+
if (activeTab.primary === 'form' && activeTab.secondary === 'history') {
1893+
if (processListData?.parentFormId) {
1894+
fetchFormHistory(
1895+
processListData.parentFormId,
1896+
newPaginationModel.page + 1,
1897+
newPaginationModel.pageSize
1898+
);
1899+
}
1900+
}
1901+
if (activeTab.primary === 'flow' && activeTab.secondary === 'history') {
1902+
if (processData?.parentProcessKey) {
1903+
setFlowHistoryLoading(true);
1904+
fetchBpmnHistory(
1905+
processData.parentProcessKey,
1906+
newPaginationModel.page + 1,
1907+
newPaginationModel.pageSize
1908+
);
1909+
}
1910+
}
1911+
};
18631912

18641913
// Render tab content based on active tab
18651914
const renderTabContent = () => {
@@ -1875,10 +1924,10 @@ const saveFormWithWorkflow = async () => {
18751924
revertBtnAction={revertFormBtnAction}
18761925
historyCount={formHistoryData.totalCount}
18771926
disableAllRevertButton={isPublished}
1878-
loading={false}
1927+
loading={formHistoryLoading}
18791928
refreshBtnAction={fetchFormHistory}
18801929
paginationModel={paginationModel}
1881-
handlePaginationModelChange={() => {}}
1930+
handlePaginationModelChange={handlePaginationModelChange}
18821931
/>
18831932
);
18841933
}
@@ -1927,6 +1976,48 @@ const saveFormWithWorkflow = async () => {
19271976
)}
19281977
</div>
19291978
);
1979+
1980+
case 'flow':
1981+
if (activeTab.secondary === 'history' && processData?.parentProcessKey) {
1982+
return (
1983+
<HistoryPage
1984+
revertBtnText={t("Revert")}
1985+
allHistory={bpmnHistoryData.processHistory}
1986+
categoryType={CategoryType.WORKFLOW}
1987+
revertBtnAction={(processId) => revertBpmnHistory(processId)}
1988+
historyCount={bpmnHistoryData.totalCount}
1989+
disableAllRevertButton={isPublished}
1990+
refreshBtnAction={handleBpmnHistory}
1991+
paginationModel={paginationModel}
1992+
handlePaginationModelChange={handlePaginationModelChange}
1993+
loading={flowHistoryLoading}
1994+
/>
1995+
);
1996+
}
1997+
return (
1998+
<FlowEdit
1999+
ref={flowRef}
2000+
setWorkflowIsChanged={setWorkflowIsChanged}
2001+
workflowIsChanged={workflowIsChanged}
2002+
CategoryType={CategoryType}
2003+
isPublished={isPublished}
2004+
migration={migration}
2005+
redirectUrl={redirectUrl}
2006+
setMigration={setMigration}
2007+
isMigrated={processListData.isMigrated}
2008+
mapperId={processListData.id}
2009+
layoutNotsaved={formChangeState.changed}
2010+
handleCurrentLayout={handleCurrentLayout}
2011+
isMigrationLoading={isMigrationLoading}
2012+
setIsMigrationLoading={setIsMigrationLoading}
2013+
handleUnpublishAndSaveChanges={handleUnpublishAndSaveChanges}
2014+
isCreateRoute={isCreateRoute}
2015+
currentBpmnXml={currentBpmnXml}
2016+
setCurrentBpmnXml={setCurrentBpmnXml}
2017+
activeTab={activeTab}
2018+
allHistory={bpmnHistoryData.processHistory}
2019+
/>
2020+
);
19302021
case 'bpmn': {
19312022
// Determine which content to show
19322023
let variableContent = null;
@@ -2088,6 +2179,11 @@ const saveFormWithWorkflow = async () => {
20882179
} else if (key === 'history') {
20892180
if (activeTab.primary === 'form') {
20902181
handleTabClick('form', 'history');
2182+
handleFormHistory();
2183+
} else if (activeTab.primary === 'flow') {
2184+
activeTab.secondary = 'history';
2185+
handleBpmnHistory();
2186+
// handleTabClick('flow', 'history');
20912187
} else if (activeTab.primary === 'bpmn') {
20922188
handleTabClick('bpmn', 'history');
20932189
}

0 commit comments

Comments
 (0)