Skip to content

Commit

Permalink
fix(gv-table): pagination issue when number of items don't divide by …
Browse files Browse the repository at this point in the history
…the page size
  • Loading branch information
loriepisicchio committed Apr 5, 2023
1 parent a1f5aee commit 1e6e473
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/molecules/gv-table/gv-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -605,12 +605,13 @@ export class GvTable extends withResizeObserver(LitElement) {

_renderPagination() {
if (this.options && this.options.paging && this._itemsProvider) {
const nbPages = Math.ceil(this._itemsProvider.length / this.options.paging);
const paginationData = {
first: 1,
last: this._itemsProvider.length / this.options.paging,
last: nbPages,
total: this._itemsProvider.length,
current_page: this._page,
total_pages: this._itemsProvider.length / this.options.paging,
total_pages: nbPages,
};
return html`<gv-pagination .data="${paginationData}" widget="true"></gv-pagination>`;
}
Expand Down
4 changes: 4 additions & 0 deletions src/molecules/gv-table/gv-table.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ export const pagination = makeStory(conf, {
items: [{ items: [...apiItems, ...apiItems], options: { ...apiOptions, paging: 2 }, title: 'APIs', order: 'name' }],
});

export const paginationPartialPage = makeStory(conf, {
items: [{ items: [...apiItems, ...apiItems], options: { ...apiOptions, paging: 5 }, title: 'APIs', order: 'name' }],
});

export const components = makeStory(conf, {
items: [
{
Expand Down

0 comments on commit 1e6e473

Please sign in to comment.