Преглед изворни кода

CR023 - show record count in application and proof search with gazette issue

CR023
Jason Chuang пре 1 месец
родитељ
комит
b6091ac9d2
1 измењених фајлова са 30 додато и 20 уклоњено
  1. +30
    -20
      src/components/FiDataGrid.js

+ 30
- 20
src/components/FiDataGrid.js Прегледај датотеку

@@ -73,7 +73,9 @@ export function FiDataGrid({ rows, columns, sx, autoHeight = true,


useEffect(() => { useEffect(() => {
if (doLoad !== undefined && Object.keys(doLoad).length>0 ){ if (doLoad !== undefined && Object.keys(doLoad).length>0 ){
if(applySearch!=undefined){
if (disablePagingOnGazetteIssue && hasGazetteIssueFilter(doLoad.params)) {
setPage(0);
} else if(applySearch!=undefined){
if (Object.keys(getSearchCriteria(window.location.pathname)).length>0){ if (Object.keys(getSearchCriteria(window.location.pathname)).length>0){
const localStorageSearchCriteria = getSearchCriteria(window.location.pathname) const localStorageSearchCriteria = getSearchCriteria(window.location.pathname)
// console.log(localStorageSearchCriteria) // console.log(localStorageSearchCriteria)
@@ -117,6 +119,7 @@ export function FiDataGrid({ rows, columns, sx, autoHeight = true,
if (!pagination || (disablePagingOnGazetteIssue && hasGazetteIssueFilter(params))) { if (!pagination || (disablePagingOnGazetteIssue && hasGazetteIssueFilter(params))) {
delete params.start; delete params.start;
delete params.limit; delete params.limit;
setPage(0);
} else { } else {
params.start = 0; params.start = 0;
params.limit = pageSize; params.limit = pageSize;
@@ -130,8 +133,9 @@ export function FiDataGrid({ rows, columns, sx, autoHeight = true,
} }
}; };


const ignorePaging = !pagination || (disablePagingOnGazetteIssue && hasGazetteIssueFilter(_doLoad?.params));
const effectivePagination = pagination && !ignorePaging;
const loadAllOnGazetteIssue = disablePagingOnGazetteIssue && hasGazetteIssueFilter(_doLoad?.params);
const ignorePagingParams = !pagination || loadAllOnGazetteIssue;
const showPaginationBar = pagination;


useEffect(() => { useEffect(() => {
getDataList(); getDataList();
@@ -216,7 +220,7 @@ export function FiDataGrid({ rows, columns, sx, autoHeight = true,
if (_doLoad.params == undefined) return; if (_doLoad.params == undefined) return;
if (_doLoad.params.searchCriteria !== undefined) return; if (_doLoad.params.searchCriteria !== undefined) return;
if (_doLoad.params == null) _doLoad.params = {}; if (_doLoad.params == null) _doLoad.params = {};
if (!pagination || (disablePagingOnGazetteIssue && hasGazetteIssueFilter(_doLoad.params))) {
if (ignorePagingParams) {
delete _doLoad.params.start; delete _doLoad.params.start;
delete _doLoad.params.limit; delete _doLoad.params.limit;
} else { } else {
@@ -314,13 +318,13 @@ export function FiDataGrid({ rows, columns, sx, autoHeight = true,
disableColumnMenu disableColumnMenu
shrinkWrap shrinkWrap
rowModesModel={_rowModesModel} rowModesModel={_rowModesModel}
pageSizeOptions={effectivePagination ? _pageSizeOptions : []}
pageSizeOptions={showPaginationBar ? _pageSizeOptions : []}
editMode={_editMode} editMode={_editMode}
autoHeight={effectiveAutoHeight} autoHeight={effectiveAutoHeight}
hideFooterSelectedRowCount={myHideFooterSelectedRowCount} hideFooterSelectedRowCount={myHideFooterSelectedRowCount}
filterModel={{ items: _filterItems }} filterModel={{ items: _filterItems }}
loading={loading} loading={loading}
paginationMode={effectivePagination ? "server" : undefined}
paginationMode={showPaginationBar ? "server" : undefined}
sortingMode={serverSorting ? "server" : undefined} sortingMode={serverSorting ? "server" : undefined}
sortModel={serverSorting ? sortModel : undefined} sortModel={serverSorting ? sortModel : undefined}
onSortModelChange={serverSorting ? handleSortModelChange : undefined} onSortModelChange={serverSorting ? handleSortModelChange : undefined}
@@ -334,8 +338,8 @@ export function FiDataGrid({ rows, columns, sx, autoHeight = true,
'& .MuiDataGrid-overlay': { '& .MuiDataGrid-overlay': {
backgroundColor: 'rgba(255, 255, 255, 0.55)', backgroundColor: 'rgba(255, 255, 255, 0.55)',
}, },
// 👇 completely hide the footer when pagination is off
...(!effectivePagination && {
// Hide the footer only when pagination is disabled for the grid
...(!showPaginationBar && {
'& .MuiDataGrid-footerContainer': { '& .MuiDataGrid-footerContainer': {
display: 'none', display: 'none',
}, },
@@ -343,22 +347,27 @@ export function FiDataGrid({ rows, columns, sx, autoHeight = true,
}} }}
components={{ components={{
NoRowsOverlay: CustomNoRowsOverlay, NoRowsOverlay: CustomNoRowsOverlay,
...(effectivePagination
...(showPaginationBar
? { ? {
Pagination: () => (
Pagination: () => {
const total = rowCount || 0;
const pagerPage = loadAllOnGazetteIssue ? 0 : page;
const pagerPageSize = loadAllOnGazetteIssue ? Math.max(total, 1) : pageSize;
return (
<TablePagination <TablePagination
component="div" component="div"
count={rowCount || 0}
page={page}
rowsPerPage={pageSize}
rowsPerPageOptions={_pageSizeOptions}
count={total}
page={pagerPage}
rowsPerPage={pagerPageSize}
rowsPerPageOptions={loadAllOnGazetteIssue ? [] : _pageSizeOptions}
labelDisplayedRows={() => { labelDisplayedRows={() => {
const total = rowCount || 0;
if (!_rows?.length || total === 0) { if (!_rows?.length || total === 0) {
return `0-0 ${intl.formatMessage({ id: "of" })} ${total}`; return `0-0 ${intl.formatMessage({ id: "of" })} ${total}`;
} }
const from = page * pageSize + 1;
const to = Math.min(page * pageSize + _rows.length, total);
const from = loadAllOnGazetteIssue ? 1 : page * pageSize + 1;
const to = loadAllOnGazetteIssue
? _rows.length
: Math.min(page * pageSize + _rows.length, total);
return `${from}-${to} ${intl.formatMessage({ id: "of" })} ${total}`; return `${from}-${to} ${intl.formatMessage({ id: "of" })} ${total}`;
}} }}
labelRowsPerPage={intl.formatMessage({ id: "rowsPerPage" }) + ":"} labelRowsPerPage={intl.formatMessage({ id: "rowsPerPage" }) + ":"}
@@ -371,10 +380,11 @@ export function FiDataGrid({ rows, columns, sx, autoHeight = true,
} }
return ''; return '';
}} }}
onPageChange={handleChangePage}
onRowsPerPageChange={handleChangePageSize}
onPageChange={loadAllOnGazetteIssue ? () => {} : handleChangePage}
onRowsPerPageChange={loadAllOnGazetteIssue ? () => {} : handleChangePageSize}
/> />
),
);
},
} }
: {}), : {}),
}} }}


Loading…
Откажи
Сачувај