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

Table Widget: core functionality #154

Merged
merged 20 commits into from
Jan 3, 2022
Merged

Conversation

edgarberm
Copy link
Contributor

@edgarberm edgarberm commented Jun 22, 2021

Screenshot from integration in carto-react-template sample app 3

Capture d’écran de 2021-12-21 18-20-43

This PR introduces TableWidgetUI as a new UI component and TableWidget as a new widget.

For now, supports sorting, pagination and click on row behavior.
Selection, search and export will be managed in further PRs.

TableWidgetUI behavior is fully controlled, so filtering, sorting and pagination has to be done by the parent component. This allows TableWidget to use the new getRawFeatures API from #225, to access and sort features in an efficient way.

@coveralls
Copy link
Collaborator

coveralls commented Jun 22, 2021

Pull Request Test Coverage Report for Build 1648975353

  • 26 of 29 (89.66%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.4%) to 70.303%

Changes Missing Coverage Covered Lines Changed/Added Lines %
packages/react-ui/src/widgets/TableWidgetUI/TableWidgetUI.js 21 24 87.5%
Totals Coverage Status
Change from base Build 1648762511: 0.4%
Covered Lines: 1142
Relevant Lines: 1529

💛 - Coveralls

packages/react-ui/package.json Outdated Show resolved Hide resolved
packages/react-ui/src/widgets/TableWidgetUI.js Outdated Show resolved Hide resolved
packages/react-ui/src/widgets/TableWidgetUI.js Outdated Show resolved Hide resolved
@bbecquet bbecquet force-pushed the feature/ch140040/table-widget-ui branch from 8285a99 to 0abfb59 Compare December 20, 2021 12:50
@bbecquet bbecquet marked this pull request as draft December 20, 2021 16:46
@bbecquet bbecquet force-pushed the feature/ch140040/table-widget-ui branch from b8b4015 to c86a159 Compare December 21, 2021 17:11
@bbecquet bbecquet changed the title Feature/ch140040/table widget UI Table Widget: core functionality Dec 21, 2021
@CartoDB CartoDB deleted a comment from shortcut-integration bot Dec 21, 2021
@bbecquet
Copy link
Contributor

@bbecquet bbecquet force-pushed the feature/ch140040/table-widget-ui branch 2 times, most recently from 037d57e to 503664b Compare December 28, 2021 15:16
@bbecquet bbecquet removed the blocked label Dec 28, 2021
@bbecquet bbecquet marked this pull request as ready for review December 28, 2021 16:14
component='div'
count={totalCount}
rowsPerPage={rowsPerPage}
page={page - 1}
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to make this adjustment because TablePagination from MUI is zero-based whereas our pagination API is 1-based (see https://github.com/CartoDB/carto-react/blob/master/packages/react-workers/src/workers/features.worker.js#L166)

Or maybe we could change our own implementation to start at page 0 too? Would it be possible @Clebal?

Copy link
Contributor

Choose a reason for hiding this comment

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

@bbecquet totally agree, it's a mistake that page is 1-based. Sorry for my late response, I didn't saw this. Can you open a PR with that change?

@bbecquet bbecquet force-pushed the feature/ch140040/table-widget-ui branch from 187e8bf to 913318c Compare December 30, 2021 08:10
Copy link
Contributor

@padawannn padawannn left a comment

Choose a reason for hiding this comment

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

The PR looks really web but I'm wondering about the behavior when we change the page and after that, the data changes because the viewport has changed or we've applied a filter. In that case, we could be consulting a page that no longer exists and the table would show no data.

@alasarr, @borja-munoz we need to talk about what to do in that case (because is a very common case). Probably, we would need to go back to the first page every time that the data changes.

packages/react-widgets/src/models/TableModel.js Outdated Show resolved Hide resolved
@bbecquet bbecquet force-pushed the feature/ch140040/table-widget-ui branch from 913318c to 1984724 Compare December 30, 2021 11:17
@alasarr
Copy link
Contributor

alasarr commented Dec 30, 2021

Looks good to me for a first version. Remember to update the changelog.

@bbecquet
Copy link
Contributor

@padawannn about your comment on pagination vs. viewport, I've added this piece of code 17454dd which resets the page to 1 when the features change.
It uses the fact that the ready state of the source goes through the cycle true -> false -> true when the viewport changes.
Do you think it's robust enough?

@bbecquet bbecquet requested a review from padawannn December 30, 2021 15:05
@padawannn
Copy link
Contributor

@padawannn about your comment on pagination vs. viewport, I've added this piece of code 17454dd which resets the page to 1 when the features change. It uses the fact that the ready state of the source goes through the cycle true -> false -> true when the viewport changes. Do you think it's robust enough?

@bbecquet we also need to reset the page to 1 if filters change. For example, in your branch template when you click hover a category in the category widget. We also should reset the page to 1 if the datasource change although this case is not common

Copy link
Contributor

@padawannn padawannn left a comment

Choose a reason for hiding this comment

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

@bbecquet bbecquet force-pushed the feature/ch140040/table-widget-ui branch from 6061fd3 to 9fac11e Compare December 30, 2021 16:26
@bbecquet
Copy link
Contributor

@padawannn Thanks for the explanation about filters. I've changed the reset callback.

@bbecquet bbecquet requested a review from padawannn December 30, 2021 16:27
Copy link
Contributor

@padawannn padawannn left a comment

Choose a reason for hiding this comment

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

@bbecquet you forgot to include the dataSource as a reset condition although it is not a common case.

On the other hand, it could be great if we add some tests about page reset

@bbecquet bbecquet force-pushed the feature/ch140040/table-widget-ui branch from 8365668 to 0b128b9 Compare January 3, 2022 10:53
@bbecquet bbecquet requested a review from padawannn January 3, 2022 10:55
@padawannn padawannn merged commit a9f3fd8 into master Jan 3, 2022
@padawannn padawannn deleted the feature/ch140040/table-widget-ui branch January 3, 2022 11:11
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.

8 participants