Skip to content

Commit

Permalink
MWB-904: fix pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
SilverBerserk committed Dec 16, 2024
1 parent 5b6386c commit 773524f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
4 changes: 2 additions & 2 deletions mapping_workbench/frontend/src/hooks/use-items-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const useItemsSearch = (items, sectionApi, searchColumns, newFilters, sort) => {
column: "",
direction: "desc"
},
page: sectionApi.DEFAULT_PAGE + 1,
page: sectionApi.DEFAULT_PAGE,
rowsPerPage: sectionApi.DEFAULT_ROWS_PER_PAGE
});

Expand Down Expand Up @@ -58,7 +58,7 @@ const useItemsSearch = (items, sectionApi, searchColumns, newFilters, sort) => {
}

const pagedItems = sortedItems().filter((item, i) => {
const pageSize = (state.page - 1) * state.rowsPerPage
const pageSize = state.page * state.rowsPerPage
if ((pageSize <= i && pageSize + state.rowsPerPage > i) || state.rowsPerPage < 0)
return item
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const Page = () => {
spacing={{xs: 3, lg: 4}}
>
<Grid xs={12}>
<SourceAndTargetTabs/>
<SourceAndTargetTabs/>
</Grid>
<Grid xs={12}>
<Stack
Expand All @@ -101,11 +101,7 @@ const Page = () => {
<Button
id='import_button'
onClick={uploadDialog.handleOpen}
startIcon={(
<SvgIcon>
<UploadIcon/>
</SvgIcon>
)}
startIcon={<UploadIcon/>}
variant="text"
>
Add ontology file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {Scrollbar} from 'src/components/scrollbar';
import {TableNoData} from '../shacl-validation-report/utils';
import {ItemListCard} from './item-list-card';
import {ItemListRow} from './item-list-row';
import TablePagination from "../../components/table-pagination";
import TablePagination from "../../components/table-pagination-pages";

export const ItemList = (props) => {
const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const TablePagination = ({
rowsPerPageOptions,
onPageChange,
count,
page,
...otherProps
}) => {

Expand Down Expand Up @@ -58,7 +59,8 @@ const TablePagination = ({
</MenuItem>)}
</Popover>
<Pagination color='primary'
onChange={onPageChange}
page={page + 1}
onChange={(e,page) => onPageChange(e,page - 1)}
count={Math.ceil(count / (rowsPerPage > 0 ? rowsPerPage : count))}
{...otherProps}/>
</Stack>
Expand Down

0 comments on commit 773524f

Please sign in to comment.