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

ELEMENTS-1747: Make nuxeo-pagination-controls efficient with 50000+ pages #925

Merged
Changes from all commits
Commits
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
29 changes: 27 additions & 2 deletions ui/nuxeo-pagination-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ import { html } from '@polymer/polymer/lib/utils/html-tag.js';

.total {
margin-inline-start: 2rem;
font-size: 1rem;
width: 5rem;
text-align: center;
}

.currentPage {
font-size: 1rem;
width: 4rem;
text-align: center;
Expand Down Expand Up @@ -114,8 +120,11 @@ import { html } from '@polymer/polymer/lib/utils/html-tag.js';
>
</paper-icon-button>
<div class="controls">
<nuxeo-select options="[[_computePageOptions(numberOfPages)]]" selected="{{page}}" vertical-align>
</nuxeo-select>
<template is="dom-if" if="[[_computeLimitForOptions(numberOfPages)]]">
<nuxeo-select options="[[_computePageOptions(numberOfPages)]]" selected="{{page}}" vertical-align>
</nuxeo-select>
</template>
<span class="currentPage" hidden$="[[_computeLimitForOptions(numberOfPages)]]">[[page]]</span>
<span class="total">/ [[numberOfPages]]</span>
</div>
<paper-icon-button
Expand Down Expand Up @@ -187,6 +196,22 @@ import { html } from '@polymer/polymer/lib/utils/html-tag.js';
_computePageOptions(numberOfPages) {
return Array.from({ length: numberOfPages }, (x, i) => i + 1);
}

_computeLimitForOptions(numberOfPages) {
const maxItemsForNuxeoSelectPagination =
Nuxeo &&
Nuxeo.UI &&
Nuxeo.UI.config &&
Nuxeo.UI.config.pagination &&
Nuxeo.UI.config.pagination.nuxeoSelectOptions &&
Nuxeo.UI.config.pagination.nuxeoSelectOptions.listingMaxItems
? Nuxeo.UI.config.pagination.nuxeoSelectOptions.listingMaxItems
: 1000;
if (numberOfPages > maxItemsForNuxeoSelectPagination) {
return false;
}
return true;
}
}

customElements.define(PaginationControls.is, PaginationControls);
Expand Down
Loading