feat: pagination in the SPA for the Sites and Authors lists
This commit is contained in:
1 parent
500ad59458
commit
340a0ad461
34 files changed
+2833
-896
No files matched your search
@@ -0,0 +1,24 @@
|
||||
import type { LocationQuery } from 'vue-router'
|
||||
|
||||
export const PAGE_SIZES = [5, 25, 50, 100]
|
||||
export const DEFAULT_PAGE_SIZE = 25
|
||||
export const SEARCH_MAX_LENGTH = 200
|
||||
|
||||
const POSITIVE_INTEGER = /^[1-9]\d*$/
|
||||
|
||||
export function firstQueryValue(value: LocationQuery[string] | undefined) {
|
||||
const single = Array.isArray(value) ? value[0] : value
|
||||
return single ?? ''
|
||||
}
|
||||
|
||||
export function parsePositiveInteger(value: string) {
|
||||
return POSITIVE_INTEGER.test(value) ? Number(value) : null
|
||||
}
|
||||
|
||||
export function sameRouteQuery(left: LocationQuery, right: Record<string, string>) {
|
||||
const leftKeys = Object.keys(left)
|
||||
return (
|
||||
leftKeys.length === Object.keys(right).length &&
|
||||
leftKeys.every((key) => firstQueryValue(left[key]) === right[key])
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user