Skip to content

Commit

Permalink
change pagination data on button click
Browse files Browse the repository at this point in the history
  • Loading branch information
OvidijusParsiunas committed Feb 18, 2024
1 parent e91942b commit a993917
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class PageNumberButtonEvents {
if (this._pagination.activePageNumber === buttonNumber) {
PageButtonStyle.mouseEnter(buttonElement, pageButtons, false);
} else {
PaginationUtils.displayRowsForDifferentButton(this, buttonNumber);
PaginationUtils.getAndApplyDataOnButtonClick(this, buttonNumber, buttonNumber);
// for the case when mouse clicks on a number button and no new buttons are created
PageButtonStyle.mouseEnter(buttonElement, pageButtons, false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class RowsPerPageDropdownItemUtil {
// when the only pagination button is disabled - changing the rows per page should not set it to active
if (PageButtonContainerElement.shouldButtonsBeActive(at)) {
PageButtonContainerElement.repopulateButtons(at);
PaginationUtils.displayRowsForDifferentButton(at, 1);
PaginationUtils.getAndApplyDataOnButtonClick(at, 1, newRowsPerPage);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {PaginationVisibleButtonsUtils} from './paginationVisibleButtonsUtils';
import {PaginationUpdatePageButtons} from './paginationUpdatePageButtons';
import {FilterInternalUtils} from '../filter/rows/filterInternalUtils';
import {PaginationInternal} from '../../../types/paginationInternal';
import {PaginationAsyncUtils} from './async/paginationAsyncUtils';
import {CustomRowProperties} from '../../rows/customRowProperties';
import {PaginationInternalUtils} from './paginationInternalUtils';
import {ExtractElements} from '../../elements/extractElements';
Expand All @@ -16,7 +17,6 @@ import {ActiveTable} from '../../../activeTable';
export class PaginationUtils {
private static readonly HIDDEN_ROW_CLASS = 'hidden-row';

// prettier-ignore
public static getLastPossiblePageNumber(at: ActiveTable, isBeforeInsert = false) {
const {_pagination, dataStartsAtHeader} = at;
if (_pagination.isAllRowsOptionSelected) return 1;
Expand Down Expand Up @@ -195,4 +195,12 @@ export class PaginationUtils {
public static getFirstVisibleRow(visibleRows: HTMLElement[]) {
return visibleRows.find((row) => !row.classList.contains(FilterInternalUtils.HIDDEN_ROW_CLASS));
}

public static async getAndApplyDataOnButtonClick(at: ActiveTable, buttonNumber: number, id: unknown) {
if (at._pagination._async) {
PaginationAsyncUtils.getAndApplyNewData(at, at._pagination._async, buttonNumber, id);
} else {
PaginationUtils.displayRowsForDifferentButton(at, buttonNumber);
}
}
}

0 comments on commit a993917

Please sign in to comment.