Skip to content

Commit

Permalink
Fix updating of page and results
Browse files Browse the repository at this point in the history
RISDEV-2514
  • Loading branch information
leonie-koch committed Oct 9, 2023
1 parent 23923e7 commit 2d5eb79
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions frontend/src/components/DocumentUnitSearch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,18 @@ const currentPage = ref<Page<DocumentUnitListEntry>>()
const itemsPerPage = 30
const searchResponseError = ref()
const isLoading = ref(false)
const searchQuery = ref<Query<DocumentUnitSearchParameter>>()
const pageNumber = ref<number>(0)
async function search(page = 0, query?: Query<string>) {
async function search() {
isLoading.value = true
const response = await service.searchByDocumentUnitSearchInput({
...(page != undefined ? { pg: page.toString() } : {}),
...(pageNumber.value != undefined
? { pg: pageNumber.value.toString() }
: {}),
...(itemsPerPage != undefined ? { sz: itemsPerPage.toString() } : {}),
...query,
...searchQuery.value,
})
if (response.data) {
documentUnitListEntries.value = response.data.content
Expand All @@ -47,8 +51,15 @@ async function handleDelete(documentUnitListEntry: DocumentUnitListEntry) {
}
}
async function handleSearch(value: Query<DocumentUnitSearchParameter>) {
await search(0, value)
async function updatePage(page: number) {
pageNumber.value = page
search()
}
async function updateQuery(value: Query<DocumentUnitSearchParameter>) {
searchQuery.value = value
pageNumber.value = 0
search()
}
async function handleReset() {
Expand All @@ -62,13 +73,13 @@ async function handleReset() {
<DocumentUnitSearchEntryForm
:is-loading="isLoading"
@reset-search-results="handleReset"
@search="handleSearch"
@search="updateQuery"
/>
<Pagination
:is-loading="isLoading"
navigation-position="bottom"
:page="currentPage"
@update-page="search"
@update-page="updatePage"
>
<DocumentUnitList
class="grow"
Expand Down

0 comments on commit 2d5eb79

Please sign in to comment.