From 2d5eb79ece7944ab19e14daf8c85726e583c11b4 Mon Sep 17 00:00:00 2001 From: Leonie Koch Date: Mon, 9 Oct 2023 17:42:38 +0200 Subject: [PATCH] Fix updating of page and results RISDEV-2514 --- .../src/components/DocumentUnitSearch.vue | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/frontend/src/components/DocumentUnitSearch.vue b/frontend/src/components/DocumentUnitSearch.vue index a4dc25c6b4..8f9e3438f7 100644 --- a/frontend/src/components/DocumentUnitSearch.vue +++ b/frontend/src/components/DocumentUnitSearch.vue @@ -15,14 +15,18 @@ const currentPage = ref>() const itemsPerPage = 30 const searchResponseError = ref() const isLoading = ref(false) +const searchQuery = ref>() +const pageNumber = ref(0) -async function search(page = 0, query?: Query) { +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 @@ -47,8 +51,15 @@ async function handleDelete(documentUnitListEntry: DocumentUnitListEntry) { } } -async function handleSearch(value: Query) { - await search(0, value) +async function updatePage(page: number) { + pageNumber.value = page + search() +} + +async function updateQuery(value: Query) { + searchQuery.value = value + pageNumber.value = 0 + search() } async function handleReset() { @@ -62,13 +73,13 @@ async function handleReset() {