This repository has been archived by the owner on Jan 9, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: work in progress paging and sorting
- Loading branch information
1 parent
b0097d1
commit 7f856c8
Showing
6 changed files
with
172 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export default interface Sort { | ||
field: string | ||
direction: 'asc' | 'desc' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
export default class Page<T> { | ||
/** the content for this page */ | ||
content: T[] | ||
|
||
/** the total number of elements that match the search */ | ||
totalElements: number | ||
|
||
/** the size of the current page */ | ||
size: number | ||
|
||
/** the current page number */ | ||
number: number | ||
|
||
getNextPage?: () => Promise<Page<T>> | ||
|
||
getPreviousPage?: () => Promise<Page<T>> | ||
|
||
constructor(content: T[], totalElements: number, size: number, number: number) { | ||
this.content = content | ||
this.totalElements = totalElements | ||
this.size = size | ||
this.number = number | ||
} | ||
|
||
getContent(): T[] { | ||
return this.content | ||
} | ||
|
||
getTotalElements(): number { | ||
return this.totalElements | ||
} | ||
|
||
getSize(): number { | ||
return this.size | ||
} | ||
|
||
getNumber(): number { | ||
return this.number | ||
} | ||
|
||
hasNext(): boolean { | ||
return this.getNextPage !== undefined | ||
} | ||
|
||
hasPrevious(): boolean { | ||
return this.getPreviousPage !== undefined | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export default interface PageRequest { | ||
/** the page number requested */ | ||
number: number | ||
/** the size of the pages */ | ||
size: number | ||
|
||
startKey?: string | ||
|
||
previousStartKeys?: string[] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import Sort from 'clients/Sort' | ||
|
||
export default interface SortRequest { | ||
sorts: Sort[] | ||
} | ||
|
||
export const Unsorted: SortRequest = { sorts: [] } |