From 4eab3488cc567d67e7526318273aeba72ea7cfcc Mon Sep 17 00:00:00 2001 From: Alireza Heidari Date: Mon, 20 Jan 2025 19:20:02 +0100 Subject: [PATCH] Fix pagination state in FilesDialog Remember last page when navigating back --- client/src/components/DataDialog/utilities.js | 12 ++++-- .../components/FilesDialog/FilesDialog.vue | 41 ++++++++++++++----- .../SelectionDialog/SelectionDialog.vue | 35 ++++++++-------- 3 files changed, 56 insertions(+), 32 deletions(-) diff --git a/client/src/components/DataDialog/utilities.js b/client/src/components/DataDialog/utilities.js index becc62ffdf8..e6462a74bbb 100644 --- a/client/src/components/DataDialog/utilities.js +++ b/client/src/components/DataDialog/utilities.js @@ -6,11 +6,12 @@ export class UrlTracker { } /** Returns urls for data drilling **/ - getUrl(url) { + getUrl(url, returnWithPrevious = false) { + let previous = undefined; if (url) { this.navigation.push(url); } else { - this.navigation.pop(); + previous = this.navigation.pop(); const navigationLength = this.navigation.length; if (navigationLength > 0) { url = this.navigation[navigationLength - 1]; @@ -18,7 +19,12 @@ export class UrlTracker { url = this.root; } } - return url; + + if (returnWithPrevious) { + return { url, popped: previous }; + } else { + return url; + } } /** Returns true if the last data is at navigation root **/ diff --git a/client/src/components/FilesDialog/FilesDialog.vue b/client/src/components/FilesDialog/FilesDialog.vue index 5d17a7bc91d..2a2178c84a8 100644 --- a/client/src/components/FilesDialog/FilesDialog.vue +++ b/client/src/components/FilesDialog/FilesDialog.vue @@ -2,7 +2,7 @@ import { faPlus } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome"; import { BAlert } from "bootstrap-vue"; -import Vue, { computed, onMounted, ref } from "vue"; +import Vue, { computed, onMounted, ref, watch } from "vue"; import { browseRemoteFiles, @@ -70,6 +70,8 @@ const { config, isConfigLoaded } = useConfig(); const selectionModel = ref(new Model({ multiple: props.multiple })); +const query = ref(); +const selectionDialog = ref(); const allSelected = ref(false); const selectedDirectories = ref([]); const errorMessage = ref(); @@ -249,13 +251,14 @@ function checkIfAllSelected(): boolean { } function open(record: SelectionItem) { - load(record); + currentDirectory.value = urlTracker.value.getUrl({ ...record, parentPage: selectionDialog.value.currentPage }); + selectionDialog.value?.resetPagination(1); + load(); } /** Performs server request to retrieve data records **/ -function load(record?: SelectionItem) { - currentDirectory.value = urlTracker.value.getUrl(record); - showFTPHelper.value = record?.url === "gxftp://"; +function load() { + showFTPHelper.value = currentDirectory.value?.url === "gxftp://"; filter.value = undefined; optionsShow.value = false; undoShow.value = !urlTracker.value.atRoot(); @@ -353,8 +356,8 @@ async function provideItems(ctx: ItemsProviderContext, url?: string): Promise { + selectionDialog.value?.resetPagination(1); +}); + onMounted(() => { - load(props.selectedItem); + currentDirectory.value = urlTracker.value.getUrl(props.selectedItem); + load(); });