-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[Assistants] Add pagination #772
Conversation
fec5d55
to
d5ee312
Compare
d5ee312
to
cc012bb
Compare
@@ -3,20 +3,36 @@ import { ENABLE_ASSISTANTS } from "$env/static/private"; | |||
import { collections } from "$lib/server/database.js"; | |||
import type { Assistant } from "$lib/types/Assistant"; | |||
import { redirect } from "@sveltejs/kit"; | |||
import type { Filter } from "mongodb"; | |||
|
|||
const NUM_PER_PAGE = 10; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gary149 change this number to what's appropriate
export let isDisabled = false; | ||
</script> | ||
|
||
<button |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a link <a>
to prev/next page (vs button with click event)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
handled in 53ed09b
src/lib/components/Pagination.svelte
Outdated
|
||
const numTotalPages = Math.ceil(numTotalItems / numItemsPerPage); | ||
|
||
$: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems a bit complex 👀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copied from hub. I will see what should be done for simplification
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
handled in 914dbd9
src/lib/components/Pagination.svelte
Outdated
<PaginationArrow | ||
direction="previous" | ||
isDisabled={pageIndex - 1 < 0} | ||
onClick={handleClickDirection} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for javascript, next/before should be links
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
handled in 53ed09b
src/routes/assistants/+page.svelte
Outdated
const onPaginationChange = (newPageIndex: number) => { | ||
pageIndex = newPageIndex; | ||
const newUrl = new URL($page.url); | ||
newUrl.searchParams.set("p", newPageIndex.toString()); | ||
goto(newUrl); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can remove that too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
handled in 53ed09b
Co-authored-by: Victor Muštar <victor.mustar@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok!
* [Assistants] Add pagination * Update src/lib/components/PaginationArrow.svelte Co-authored-by: Victor Muštar <victor.mustar@gmail.com> * format * Simplify by using a href * this statement needs to be reactive * simplify pagination * update disabled * Update src/routes/assistants/+page.server.ts --------- Co-authored-by: Victor Muštar <victor.mustar@gmail.com>
Add pagination to assistants page