Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implemented logic to show total row count on tables #441 #466

Merged
merged 33 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
8a1ed82
implemented logic to show total row count on tables #441
MatteoGuarnaccia5 Mar 28, 2024
b761fbd
abstracted logic for total row counts #441
MatteoGuarnaccia5 Apr 2, 2024
068743b
updated snapshots #441
MatteoGuarnaccia5 Apr 2, 2024
b6a2ff2
Merge branch 'develop' into show-total-rows-on-tables-#441
MatteoGuarnaccia5 Apr 2, 2024
f339b06
fix snapshot
MatteoGuarnaccia5 Apr 2, 2024
610f98f
fixed snapshot attempt 2 #441
MatteoGuarnaccia5 Apr 2, 2024
c778847
changed logic to just display total rows and total filtered rows, and…
MatteoGuarnaccia5 Apr 2, 2024
c326636
updated snapshots #441
MatteoGuarnaccia5 Apr 2, 2024
3ac3171
removed comment from utils file #441
MatteoGuarnaccia5 Apr 3, 2024
91ffd52
fixed snapshot #441
MatteoGuarnaccia5 Apr 3, 2024
b29dfed
fix snapshot attempt 2 #441
MatteoGuarnaccia5 Apr 3, 2024
ad02997
potential fix for e2e test #441
MatteoGuarnaccia5 Apr 3, 2024
68ef388
adjusted padding #441
MatteoGuarnaccia5 Apr 15, 2024
3f07e7c
added total rows to subsystem and cat categories #441
MatteoGuarnaccia5 Apr 15, 2024
bbcc5d2
Merge branch 'develop' into show-total-rows-on-tables-#441
MatteoGuarnaccia5 Apr 15, 2024
f445f26
fixed linting #441
MatteoGuarnaccia5 Apr 15, 2024
ea49af2
updated snapshots #441
MatteoGuarnaccia5 Apr 15, 2024
88f2419
changed system table view to have pagination under total rows #441
MatteoGuarnaccia5 Apr 18, 2024
db41b80
fixed css/styling in catalogue categories card view #441
MatteoGuarnaccia5 Apr 23, 2024
18b58cf
refactored heights to remove scroll bar #441
MatteoGuarnaccia5 Apr 23, 2024
afe6698
Merge branch 'develop' into show-total-rows-on-tables-#441
MatteoGuarnaccia5 Apr 23, 2024
e3b15f4
updated snapshots #441
MatteoGuarnaccia5 Apr 23, 2024
ccaf2f3
Merge branch 'develop' into show-total-rows-on-tables-#441
MatteoGuarnaccia5 Apr 30, 2024
6bc27c3
update snapshot anf fixed warnings
MatteoGuarnaccia5 Apr 30, 2024
13ca1c9
undo last commit (was on wrong branch)
MatteoGuarnaccia5 Apr 30, 2024
dade980
fixed tests
MatteoGuarnaccia5 Apr 30, 2024
d840f8b
fixed row totals moving when descreasing screen width
MatteoGuarnaccia5 May 15, 2024
e551455
Merge branch 'develop' into show-total-rows-on-tables-#441
MatteoGuarnaccia5 May 15, 2024
78dd7ff
update snapshots
MatteoGuarnaccia5 May 15, 2024
5b59b63
update snapshot
MatteoGuarnaccia5 May 15, 2024
300e47c
update snapshots #441
MatteoGuarnaccia5 May 16, 2024
eb85ef9
fixed bottom wrapping when decreasing screen size #441
MatteoGuarnaccia5 May 16, 2024
b934dcd
Improve small screen behaviour for categories and systems #441
joelvdavies May 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cypress/e2e/with_mock_data/catalogueItems.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,7 @@ describe('Catalogue Items', () => {

cy.startSnoopingBrowserMockedRequest();
cy.findByText('Finish').click();
cy.findByRole('dialog').should('not.exist');

cy.findBrowserMockedRequests({
method: 'PATCH',
Expand Down Expand Up @@ -692,6 +693,7 @@ describe('Catalogue Items', () => {

cy.startSnoopingBrowserMockedRequest();
cy.findByText('Finish').click();
cy.findByRole('dialog').should('not.exist');

cy.findBrowserMockedRequests({
method: 'PATCH',
Expand Down
6 changes: 6 additions & 0 deletions src/catalogue/category/catalogueCardView.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ function CatalogueCardView(props: CatalogueCardViewProps) {
bottom={12}
right={0}
>
<Grid item position={'fixed'} left={8}>
MatteoGuarnaccia5 marked this conversation as resolved.
Show resolved Hide resolved
<Typography sx={{ paddingLeft: '8px' }}>
{`Total Categories: ${catalogueCategoryData.length}`}
</Typography>
</Grid>

<Grid item>
<FormControl
variant="standard"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,7 @@ exports[`Catalogue Items Table > renders the dense table correctly 1`] = `
class="MuiCollapse-wrapperInner MuiCollapse-vertical css-9l5vo-MuiCollapse-wrapperInner"
>
<div
class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-colorInfo MuiAlert-standardInfo MuiAlert-standard css-dxfizy-MuiPaper-root-MuiAlert-root"
class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-colorInfo MuiAlert-standardInfo MuiAlert-standard css-3fnbcm-MuiPaper-root-MuiAlert-root"
role="alert"
>
<div
Expand All @@ -863,9 +863,13 @@ exports[`Catalogue Items Table > renders the dense table correctly 1`] = `
<div
class="MuiBox-root css-1llu0od"
>
<span />
<p
class="MuiTypography-root MuiTypography-body1 css-13zw5gk-MuiTypography-root"
>
Total Catalogue Items: 4
</p>
<div
class="MuiBox-root css-qpxlqp"
class="MuiBox-root css-nokk8"
>
<div
class="MuiTablePagination-root MuiBox-root css-8k4lth"
Expand Down
8 changes: 8 additions & 0 deletions src/catalogue/items/catalogueItemsTable.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,14 @@ const CatalogueItemsTable = (props: CatalogueItemsTableProps) => {
</>
);
},
renderBottomToolbarCustomActions: ({ table }) => (
<Typography sx={{ paddingLeft: '8px' }}>
{table.getFilteredRowModel().rows.length == catalogueItemsData?.length
? `Total Catalogue Items: ${catalogueItemsData.length}`
: `Returned ${table.getFilteredRowModel().rows.length} out of ${catalogueItemsData?.length} Catalogue Items`}
MatteoGuarnaccia5 marked this conversation as resolved.
Show resolved Hide resolved
</Typography>
),

renderTopToolbarCustomActions: ({ table }) =>
dense && requestOrigin === 'move to' ? undefined : (
<Box sx={{ display: 'flex' }}>
Expand Down
30 changes: 21 additions & 9 deletions src/items/__snapshots__/itemsTable.component.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1293,7 +1293,7 @@ exports[`Items Table > renders correctly part 1 due column virtualisation 1`] =
class="MuiCollapse-wrapperInner MuiCollapse-vertical css-9l5vo-MuiCollapse-wrapperInner"
>
<div
class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-colorInfo MuiAlert-standardInfo MuiAlert-standard css-dxfizy-MuiPaper-root-MuiAlert-root"
class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-colorInfo MuiAlert-standardInfo MuiAlert-standard css-3fnbcm-MuiPaper-root-MuiAlert-root"
role="alert"
>
<div
Expand All @@ -1316,9 +1316,13 @@ exports[`Items Table > renders correctly part 1 due column virtualisation 1`] =
<div
class="MuiBox-root css-1llu0od"
>
<span />
<p
class="MuiTypography-root MuiTypography-body1 css-13zw5gk-MuiTypography-root"
>
Total Items: 4
</p>
<div
class="MuiBox-root css-qpxlqp"
class="MuiBox-root css-nokk8"
>
<div
class="MuiTablePagination-root MuiBox-root css-8k4lth"
Expand Down Expand Up @@ -2738,7 +2742,7 @@ exports[`Items Table > renders correctly part 2 due column virtualisation 1`] =
class="MuiCollapse-wrapperInner MuiCollapse-vertical css-9l5vo-MuiCollapse-wrapperInner"
>
<div
class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-colorInfo MuiAlert-standardInfo MuiAlert-standard css-dxfizy-MuiPaper-root-MuiAlert-root"
class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-colorInfo MuiAlert-standardInfo MuiAlert-standard css-3fnbcm-MuiPaper-root-MuiAlert-root"
role="alert"
>
<div
Expand All @@ -2761,9 +2765,13 @@ exports[`Items Table > renders correctly part 2 due column virtualisation 1`] =
<div
class="MuiBox-root css-1llu0od"
>
<span />
<p
class="MuiTypography-root MuiTypography-body1 css-13zw5gk-MuiTypography-root"
>
Total Items: 4
</p>
<div
class="MuiBox-root css-qpxlqp"
class="MuiBox-root css-nokk8"
>
<div
class="MuiTablePagination-root MuiBox-root css-8k4lth"
Expand Down Expand Up @@ -4225,7 +4233,7 @@ exports[`Items Table > renders the dense table correctly 1`] = `
class="MuiCollapse-wrapperInner MuiCollapse-vertical css-9l5vo-MuiCollapse-wrapperInner"
>
<div
class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-colorInfo MuiAlert-standardInfo MuiAlert-standard css-dxfizy-MuiPaper-root-MuiAlert-root"
class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-colorInfo MuiAlert-standardInfo MuiAlert-standard css-3fnbcm-MuiPaper-root-MuiAlert-root"
role="alert"
>
<div
Expand All @@ -4248,9 +4256,13 @@ exports[`Items Table > renders the dense table correctly 1`] = `
<div
class="MuiBox-root css-1llu0od"
>
<span />
<p
class="MuiTypography-root MuiTypography-body1 css-13zw5gk-MuiTypography-root"
>
Total Items: 4
</p>
<div
class="MuiBox-root css-qpxlqp"
class="MuiBox-root css-nokk8"
>
<div
class="MuiTablePagination-root MuiBox-root css-8k4lth"
Expand Down
8 changes: 8 additions & 0 deletions src/items/itemsTable.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,14 @@ export function ItemsTable(props: ItemTableProps) {
</MenuItem>,
];
},
renderBottomToolbarCustomActions: ({ table }) => (
<Typography sx={{ paddingLeft: '8px' }}>
{table.getFilteredRowModel().rows.length == data?.length
? `Total Items: ${data.length}`
: `Returned ${table.getFilteredRowModel().rows.length} out of ${data?.length} Items`}
</Typography>
),

renderDetailPanel: dense
? ({ row }) => (
<ItemsDetailsPanel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1854,7 +1854,7 @@ exports[`Manufacturer > renders table data correctly 1`] = `
class="MuiCollapse-wrapperInner MuiCollapse-vertical css-9l5vo-MuiCollapse-wrapperInner"
>
<div
class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-colorInfo MuiAlert-standardInfo MuiAlert-standard css-dxfizy-MuiPaper-root-MuiAlert-root"
class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-colorInfo MuiAlert-standardInfo MuiAlert-standard css-3fnbcm-MuiPaper-root-MuiAlert-root"
role="alert"
>
<div
Expand All @@ -1877,9 +1877,13 @@ exports[`Manufacturer > renders table data correctly 1`] = `
<div
class="MuiBox-root css-1llu0od"
>
<span />
<p
class="MuiTypography-root MuiTypography-body1 css-13zw5gk-MuiTypography-root"
>
Total Manufacturers: 4
</p>
<div
class="MuiBox-root css-qpxlqp"
class="MuiBox-root css-nokk8"
>
<div
class="MuiTablePagination-root MuiBox-root css-8k4lth"
Expand Down
2 changes: 1 addition & 1 deletion src/manufacturer/manufacturer.component.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('Manufacturer', () => {
await user.click(screen.getByRole('button', { name: 'Show/Hide columns' }));
await user.click(screen.getByText('Created'));
expect(view.asFragment()).toMatchSnapshot();
}, 10000);
});

it('manufacturer url has a href so therefore links to new webpage', async () => {
createView();
Expand Down
7 changes: 7 additions & 0 deletions src/manufacturer/manufacturer.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,13 @@ function ManufacturerComponent() {
</MenuItem>,
];
},
renderBottomToolbarCustomActions: ({ table }) => (
<Typography sx={{ paddingLeft: '8px' }}>
{table.getFilteredRowModel().rows.length == ManufacturerData?.length
? `Total Manufacturers: ${ManufacturerData.length}`
: `Returned ${table.getFilteredRowModel().rows.length} out of ${ManufacturerData?.length} Manufacturers`}
</Typography>
),
});

const navigate = useNavigate();
Expand Down
20 changes: 14 additions & 6 deletions src/systems/__snapshots__/systemItemsTable.component.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2102,7 +2102,7 @@ exports[`SystemItemsTable > SystemItemsTable (normal) > renders correctly 1`] =
class="MuiCollapse-wrapperInner MuiCollapse-vertical css-9l5vo-MuiCollapse-wrapperInner"
>
<div
class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-colorInfo MuiAlert-standardInfo MuiAlert-standard css-dxfizy-MuiPaper-root-MuiAlert-root"
class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-colorInfo MuiAlert-standardInfo MuiAlert-standard css-3fnbcm-MuiPaper-root-MuiAlert-root"
role="alert"
>
<div
Expand Down Expand Up @@ -2150,9 +2150,13 @@ exports[`SystemItemsTable > SystemItemsTable (normal) > renders correctly 1`] =
<div
class="MuiBox-root css-1llu0od"
>
<span />
<p
class="MuiTypography-root MuiTypography-body1 css-13zw5gk-MuiTypography-root"
>
Total Items: 3
</p>
<div
class="MuiBox-root css-qpxlqp"
class="MuiBox-root css-nokk8"
>
<div
class="MuiTablePagination-root MuiBox-root css-8k4lth"
Expand Down Expand Up @@ -3235,7 +3239,7 @@ exports[`SystemItemsTable > SystemItemsTable (usageStatus) > renders correctly 1
class="MuiCollapse-wrapperInner MuiCollapse-vertical css-9l5vo-MuiCollapse-wrapperInner"
>
<div
class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-colorInfo MuiAlert-standardInfo MuiAlert-standard css-dxfizy-MuiPaper-root-MuiAlert-root"
class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-colorInfo MuiAlert-standardInfo MuiAlert-standard css-3fnbcm-MuiPaper-root-MuiAlert-root"
role="alert"
>
<div
Expand Down Expand Up @@ -3283,9 +3287,13 @@ exports[`SystemItemsTable > SystemItemsTable (usageStatus) > renders correctly 1
<div
class="MuiBox-root css-1llu0od"
>
<span />
<p
class="MuiTypography-root MuiTypography-body1 css-13zw5gk-MuiTypography-root"
>
Returned 4 out of undefined Items
</p>
<div
class="MuiBox-root css-qpxlqp"
class="MuiBox-root css-nokk8"
>
<div
class="MuiTablePagination-root MuiBox-root css-8k4lth"
Expand Down
8 changes: 8 additions & 0 deletions src/systems/systemItemsTable.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,14 @@ export function SystemItemsTable(props: SystemItemsTableProps) {
)}
</Box>
),
renderBottomToolbarCustomActions: ({ table }) => (
<Typography sx={{ paddingLeft: '8px' }}>
{table.getFilteredRowModel().rows.length == itemsData?.length
? `Total Items: ${itemsData.length}`
: `Returned ${table.getFilteredRowModel().rows.length} out of ${itemsData?.length} Items`}
</Typography>
),

renderDetailPanel: ({ row }) =>
row.original.catalogueItem !== undefined ? (
<ItemsDetailsPanel
Expand Down
13 changes: 10 additions & 3 deletions src/systems/systems.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
// To resolve react/jsx-pascal-case
MRT_GlobalFilterTextField as MRTGlobalFilterTextField,
MRT_TableBodyCellValue as MRTTableBodyCellValue,
MRT_TablePagination as MRTTablePagination,
MRT_BottomToolbar,
MRT_ColumnDef,
MRT_RowSelectionState,
useMaterialReactTable,
Expand Down Expand Up @@ -164,7 +164,7 @@ const columns: MRT_ColumnDef<System>[] = [
},
];

const MIN_SUBSYSTEMS_WIDTH = '320px';
const MIN_SUBSYSTEMS_WIDTH = '480px';
MatteoGuarnaccia5 marked this conversation as resolved.
Show resolved Hide resolved

function Systems() {
// Navigation
Expand Down Expand Up @@ -297,6 +297,13 @@ function Systems() {
</MenuItem>,
];
},
renderBottomToolbarCustomActions: ({ table }) => (
<Typography sx={{ paddingLeft: '8px' }}>
{table.getFilteredRowModel().rows.length == subsystemsData?.length
? `Total Systems: ${subsystemsData.length}`
: `Returned ${table.getFilteredRowModel().rows.length} out of ${subsystemsData?.length} Systems`}
</Typography>
),
});

return (
Expand Down Expand Up @@ -454,7 +461,7 @@ function Systems() {
</TableBody>
</Table>
</TableContainer>
<MRTTablePagination table={subsystemsTable} />
<MRT_BottomToolbar table={subsystemsTable} />
</Stack>
</>
)}
Expand Down