hedyorg / hedy

Hedy is a gradual programming language to teach children programming. Gradual languages use different language levels, where each level adds new concepts and syntactic complexity. At the end of the Hedy level sequence, kids master a subset of syntactically valid Python.
https://www.hedy.org
European Union Public License 1.2
1.27k stars 282 forks source link

💻 Add "previous page" buttons #5523

Closed rix0rrr closed 1 month ago

rix0rrr commented 1 month ago

This adds the feature to also go backwards in the result set to DynamoDB queries.

The same way there was a results.next_page_token before that you could pass in to get the next page of results, this adds a results.prev_page_token. If the prev_page_token is set, pass the token into the exact same query operation to return the previous page of results.

I've added a demonstration to the Admin "all users" page; I don't know where else "previous page" buttons should be added.

In addition, this adds a get_page() function which can be used for paginated result pages that need additional filtering. Filtering can be done on the server side (passing a server_side_filter) and on the client side (passing a client_side_filter). The get_page() function will repeatedly do server queries until it has filled up a page of the requested limit items (or until a timeout is hit), and make sure the next_page_token and prev_page_token values are set correctly. get_page should probably replace QueryIterator-based solutions -- get_page is easier to use.

@jpelay @Annelein @hasan-sh I could use some help with rolling this new feature out wherever it makes sense.

How to test

Go to the Admin page, click on "User overview", click "Next page". A "Previous page" button appears at the bottom of the screen, clicking it gets you back to the first page.

hasan-sh commented 1 month ago

@jpelay @Annelein @hasan-sh I could use some help with rolling this new feature out wherever it makes sense.

Will review and push more support for previous buttons

rix0rrr commented 1 month ago

@hasan-sh I think this one is good to go!

mergify[bot] commented 1 month ago

Thank you for contributing! Your pull request is now going on the merge train (choo choo! Do not click update from main anymore, and be sure to allow changes to be pushed to your fork).

mergify[bot] commented 1 month ago

Thank you for contributing! Your pull request is now going on the merge train (choo choo! Do not click update from main anymore, and be sure to allow changes to be pushed to your fork).