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

feat(react-grid): Ability to show all rows on a page via page size selector #150

Merged
merged 19 commits into from
Jun 21, 2017

Conversation

SergeyAlexeev
Copy link
Contributor

No description provided.

@@ -1,8 +1,16 @@
export const paginate = (rows, pageSize, page) =>
rows.slice(pageSize * page, pageSize * (page + 1));
const showAllPagesKey = 'all';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we export this const and use it other files (where we reference the 'all' value)?


export const ensurePageHeaders = (rows, pageSize) => {
const result = rows.slice();
if (pageSize === showAllPagesKey) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This expression is used four times in this file. May be create a helper function?

@@ -1,8 +1,16 @@
export const paginate = (rows, pageSize, page) =>
rows.slice(pageSize * page, pageSize * (page + 1));
const showAllPagesKey = 'all';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why have not you used upper case for this constant like we do in other cases (e.g. DEFAULT_HEIGHT or MINIMAL_COLUMN_WIDTH)?
I suggest renaming it in ALL_PAGES_KEY to make it look less alike a function.

};

export const pageSizeTitle = pageSize => (
pageSize === showAllPagesKey ? 'All' : pageSize
Copy link
Contributor

@gsobolev gsobolev Jun 16, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it OK to have an inlined string here?

@@ -16,7 +16,7 @@ totalCount | number | | Specifies the total rows count
currentPage | number | | Specifies the current page number
defaultCurrentPage | number | 0 | Specifies the initial current page for the uncontrolled mode
onCurrentPageChange | (currentPage: number) => void | | Handles current page changes
pageSize | number | | Specifies the page size
pageSize | number | | | Specifies the page size
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, remove redundant | symbol

@@ -1,8 +1,16 @@
export const paginate = (rows, pageSize, page) =>
rows.slice(pageSize * page, pageSize * (page + 1));
const ALL_PAGES_TITLE = 'All';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This const seems unused

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used here export const pageSizeTitle = pageSize => pageSize || ALL_PAGES_TITLE;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pageSizeTitle export is strange, isn't it? It has a localizable string that can't be configured by a user.


export const ensurePageHeaders = (rows, pageSize) => {
const result = rows.slice();
if (!pageSize) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why could we not escape earlier? Slicing seems redundant

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slicing is for array copying, isn't it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but this copy is needed only for processing listed below in this function. We can return original rows if processing is not needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, got it.

@@ -16,7 +16,7 @@ totalCount | number | | Specifies the total rows count
currentPage | number | | Specifies the current page number
defaultCurrentPage | number | 0 | Specifies the initial current page for the uncontrolled mode
onCurrentPageChange | (currentPage: number) => void | | Handles current page changes
pageSize | number | | | Specifies the page size
pageSize | number | | Specifies the page size
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should add info about 0 constant here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added it here packages/dx-react-grid/docs/guides/paging.md

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I saw it. I think that reference is a more suitable place for this. It is also good to have a note about 0 constant in guide and reference.

@@ -14,6 +14,7 @@ Name | Type | Default | Description
-----|------|---------|------------
pagerTemplate | (args: [PagerArgs](#pager-args)) => ReactElement | | A component that renders a pager based on the supplied parameters
allowedPageSizes | Array<number> | [] | Specifies the page sizes that can be selected at runtime
showAllText | string | | Specifies the text of the 'All' item of a page size selector
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add note about availability only BS3 and MUI plugin wrappers

@@ -31,6 +32,7 @@ onCurrentPageChange | (page: number) => void | Changes the current page
pageSize | number | Specifies the page size
onPageSizeChange | (size: number) => void | Changes the page size
allowedPageSizes | Array<number> | Specifies the page sizes that can be selected at runtime
showAllText | string | Specifies the text of the 'All' item of a page size selector
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

@viterobk viterobk requested a review from ElyaC June 21, 2017 08:21
@SergeyAlexeev SergeyAlexeev merged commit 8af3dde into DevExpress:master Jun 21, 2017
@SergeyAlexeev SergeyAlexeev deleted the select-all-pages branch June 21, 2017 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants