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

Features/822 pagination #1127

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sadiqkhoja
Copy link
Contributor

@sadiqkhoja sadiqkhoja commented Jan 24, 2025

Closes getodk/central#822

What has been done to verify that this works as intended?

Wrote some component tests and manually verified it. I am thinking to pass this to QA team even before we review/merge this PR.

Why is this the best possible solution? Were any other approaches considered?

We talked about what to do when a row is deleted, should we just remove the row from the UI or we fetch the next available row and update the count/page size. We decided that it is better to just remove the row.

Transition Group

I have used Vue's Transition Group (TG) component in our table-freeze component. I think this has simplified our code because model and view are alway in sync; and we no longer keep deleted row in the DOM hidden.

I am not using css class provided by TG component and kept our transition logic in markRowChanged and markRowDeleted. Because TG doesn't help with row modified, so thought might as well keep both change/delete consistent. The only magic of TG is that it waits for transitionend event before removing row from the table, that event is raised when transition started by css property is completed.

Snapshot Filters

I am passing filters to odata endpoint to fetch the data for a single point in time so that submission/entity created or deleted after fetching first page don't effect our total count and number of pages.

For alive records, those filters are records created before now and not deleted or deleted after now.
For deleted records, the filter is to fetch records that are deleted before now.

I am keeping a set of removed rows (instanceId or UUID), so I don't add those rows in resource store when page is changed.

Only weird case is where a user is looking at alive records and some other user undeletes a record, then next odata request will have different count and number of pages can change. But I think it's not super problematic.

How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?

No

Does this change require updates to user documentation? If so, please file an issue here and include the link below.

Before submitting this PR, please make sure you have:

  • run npm run test and npm run lint and confirmed all checks still pass OR confirm CircleCI build passes
  • verified that any code or assets from external sources are properly credited in comments or that everything is internally sourced

@sadiqkhoja sadiqkhoja force-pushed the features/822-pagination branch from 7843704 to 86b4b23 Compare January 30, 2025 20:29
@sadiqkhoja sadiqkhoja force-pushed the features/822-pagination branch from 86b4b23 to 6e26342 Compare January 30, 2025 21:58
@@ -68,7 +68,7 @@ export const markRowsChanged = (trs) => {
// transition: see app.scss. The CSS specifies the duration of the transition.
setTimeout(() => {
for (const tr of trs) tr.dataset.markRowsChanged = 'false';
});
}, 6000);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

instead of delay in css transition, delaying it here. Without this change TransitionGroup component keeps the modified row in the table until transition is finished if you quickly request next/previous page.

@@ -41,7 +41,7 @@
"@vue/cli-service": "^5.0.8",
"@vue/compiler-sfc": "~3",
"@vue/eslint-config-airbnb": "^7.0.0",
"@vue/test-utils": "^2.4.1",
"@vue/test-utils": "^2.4.6",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

transition-group stub in testing doesn't work with the older version

Comment on lines +474 to +475
#entity-list table:has(tbody:empty) {
display: none;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this help us to hide the table when all rows are gone after transition.

@sadiqkhoja sadiqkhoja marked this pull request as ready for review January 30, 2025 22:26
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.

Replace infinite scroll with pagination
1 participant