forked from AOT-Technologies/forms-flow-ai
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
History table (AOT-Technologies#1827)
* follow update uncheck fixed * react-bootstrap table changed for application history * file name change --------- Co-authored-by: AbijithS-aot <[email protected]>
- Loading branch information
1 parent
6b642c2
commit 5d151fc
Showing
2 changed files
with
89 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
160 changes: 84 additions & 76 deletions
160
forms-flow-web/src/components/Application/historyTable.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,85 +1,93 @@ | ||
import React from "react"; | ||
import { | ||
getFormUrl, | ||
} from "../../apiManager/services/formatterService"; | ||
import { useSelector } from "react-redux"; | ||
import { MULTITENANCY_ENABLED } from "../../constants/constants"; | ||
import { HelperServices } from "@formsflow/service"; | ||
import { Translation } from "react-i18next"; | ||
import { HelperServices} from "@formsflow/service"; | ||
import { useTranslation } from "react-i18next"; | ||
import { getFormUrl } from "../../apiManager/services/formatterService"; | ||
|
||
const HistoryTable = () => { | ||
const appHistory = useSelector((state) => state.taskAppHistory.appHistory); | ||
const { t } = useTranslation(); | ||
|
||
export const defaultSortedBy = [ | ||
{ | ||
dataField: "name", | ||
order: "asc", // or desc | ||
}, | ||
]; | ||
const tenantKey = useSelector((state) => state.tenants?.tenantId); | ||
const redirectUrl = MULTITENANCY_ENABLED ? `/tenant/${tenantKey}/` : "/"; | ||
|
||
const linkSubmision = (row, redirectUrl) => { | ||
const { formId, submissionId } = row; | ||
const url = getFormUrl(formId, submissionId, redirectUrl); | ||
return ( | ||
<div onClick={() => window.open(url, "_blank")}> | ||
<span className="btn btn-primary btn-sm form-btn" data-testid="submission-viewsubmission-button" > | ||
<span> | ||
<i className="fa fa-eye" aria-hidden="true"></i> | ||
</span> | ||
const viewSubmission = (data) => { | ||
const { formId, submissionId } = data; | ||
const url = getFormUrl(formId, submissionId, redirectUrl); | ||
return ( | ||
<button | ||
data-testid={`submission-details-button-${data.id}`} | ||
className="btn btn-primary" | ||
onClick={() => window.open(url, "_blank")} | ||
> | ||
<Translation>{(t) => t("View Submission")}</Translation> | ||
</span> | ||
</div> | ||
); | ||
}; | ||
|
||
function timeFormatter(cell) { | ||
const localDate = HelperServices?.getLocalDateAndTime(cell); | ||
return <label title={cell}>{localDate}</label>; | ||
} | ||
|
||
// History table columns | ||
export const columns_history = (redirectUrl) => [ | ||
{ | ||
dataField: "applicationStatus", | ||
text: <Translation>{(t) => t("Status")}</Translation>, | ||
sort: true, | ||
}, | ||
{ | ||
dataField: "created", | ||
text: <Translation>{(t) => t("Created")}</Translation>, | ||
sort: true, | ||
formatter: timeFormatter, | ||
}, | ||
{ | ||
dataField: "submittedBy", | ||
text: <Translation>{(t) => t("Submitted By")}</Translation>, | ||
sort: true, | ||
}, | ||
{ | ||
dataField: "formId", | ||
text: <Translation>{(t) => t("Submissions")}</Translation>, | ||
formatter: (cell, row) => linkSubmision(row, redirectUrl), | ||
}, | ||
]; | ||
const customTotal = (from, to, size) => ( | ||
<span className="react-bootstrap-table-pagination-total" role="main"> | ||
<Translation>{(t) => t("Showing")}</Translation> {from}{" "} | ||
<Translation>{(t) => t("to")}</Translation> {to}{" "} | ||
<Translation>{(t) => t("of")}</Translation> {size} <Translation>{(t) => t("results")}</Translation> | ||
</span> | ||
); | ||
</button> | ||
); | ||
}; | ||
|
||
export const getoptions = (count) => { | ||
return { | ||
expandRowBgColor: "rgb(173,216,230)", | ||
pageStartIndex: 1, | ||
alwaysShowAllBtns: true, // Always show next and previous button | ||
withFirstAndLast: false, // Hide the going to First and Last page button | ||
hideSizePerPage: true, // Hide the sizePerPage dropdown always | ||
// hidePageListOnlyOnePage: true, // Hide the pagination list when only one page | ||
paginationSize: 7, // the pagination bar size. | ||
prePageText: "<<", | ||
nextPageText: ">>", | ||
showTotal: true, | ||
Total: count, | ||
paginationTotalRenderer: customTotal, | ||
disablePageTitle: true, | ||
sizePerPage: 5, | ||
const getNoDataIndicationContent = () => { | ||
return ( | ||
<div className="div-no-application bg-transparent"> | ||
<label className="lbl-no-application"> | ||
{" "} | ||
<Translation>{(t) => t("No submissions found")}</Translation>{" "} | ||
</label> | ||
<br /> | ||
<label className="lbl-no-application-desc"> | ||
{" "} | ||
<Translation> | ||
{(t) => | ||
t("No History Found") | ||
} | ||
</Translation> | ||
</label> | ||
<br /> | ||
</div> | ||
); | ||
}; | ||
|
||
return ( | ||
<> | ||
<div className="main-header"> | ||
<h3 className="task-head"> | ||
<i className="fa fa-list me-2" aria-hidden="true" /> | ||
<Translation>{(t) => t("Submission History")}</Translation> | ||
</h3> | ||
</div> | ||
<table className="table"> | ||
<thead> | ||
<tr> | ||
<th>{t("Status")} </th> | ||
<th>{t("Created")}</th> | ||
<th>{t("Submitted By")}</th> | ||
<th>{t("Submissions")}</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{appHistory.length ? ( | ||
appHistory?.map((e) => { | ||
return ( | ||
<tr key={e.id}> | ||
<td>{e.applicationStatus}</td> | ||
<td> | ||
{HelperServices?.getLocalDateAndTime(e.created)} | ||
</td> | ||
<td>{e.submittedBy}</td> | ||
<td>{viewSubmission(e)}</td> | ||
</tr> | ||
); | ||
}) | ||
) : ( | ||
<td colSpan="6" className="text-center"> | ||
{getNoDataIndicationContent()} | ||
</td> | ||
)} | ||
</tbody> | ||
</table> | ||
</> | ||
); | ||
}; | ||
|
||
export default HistoryTable; |