22import { faPlus } from " @fortawesome/free-solid-svg-icons" ;
33import { FontAwesomeIcon } from " @fortawesome/vue-fontawesome" ;
44import { BAlert } from " bootstrap-vue" ;
5- import Vue , { computed , onMounted , ref } from " vue" ;
5+ import Vue , { computed , onMounted , ref , watch } from " vue" ;
66
77import {
88 browseRemoteFiles ,
@@ -70,6 +70,8 @@ const { config, isConfigLoaded } = useConfig();
7070
7171const selectionModel = ref <Model >(new Model ({ multiple: props .multiple }));
7272
73+ const query = ref <string >();
74+ const selectionDialog = ref ();
7375const allSelected = ref (false );
7476const selectedDirectories = ref <SelectionItem []>([]);
7577const errorMessage = ref <string >();
@@ -249,13 +251,14 @@ function checkIfAllSelected(): boolean {
249251}
250252
251253function open(record : SelectionItem ) {
252- load (record );
254+ currentDirectory .value = urlTracker .value .getUrl ({ ... record , parentPage: selectionDialog .value .currentPage });
255+ selectionDialog .value ?.resetPagination (1 );
256+ load ();
253257}
254258
255259/** Performs server request to retrieve data records **/
256- function load(record ? : SelectionItem ) {
257- currentDirectory .value = urlTracker .value .getUrl (record );
258- showFTPHelper .value = record ?.url === " gxftp://" ;
260+ function load() {
261+ showFTPHelper .value = currentDirectory .value ?.url === " gxftp://" ;
259262 filter .value = undefined ;
260263 optionsShow .value = false ;
261264 undoShow .value = ! urlTracker .value .atRoot ();
@@ -353,8 +356,8 @@ async function provideItems(ctx: ItemsProviderContext, url?: string): Promise<Se
353356 }
354357 const limit = ctx .perPage ;
355358 const offset = (ctx .currentPage ? ctx .currentPage - 1 : 0 ) * ctx .perPage ;
356- const query = ctx .filter ;
357- const response = await browseRemoteFiles (url , false , props .requireWritable , limit , offset , query );
359+ query . value = ctx .filter ;
360+ const response = await browseRemoteFiles (url , false , props .requireWritable , limit , offset , query . value );
358361 const result = response .entries .map (entryToRecord );
359362 totalItems .value = response .totalMatches ;
360363 items .value = result ;
@@ -437,21 +440,38 @@ function pushToPropRouter(route: string) {
437440 }
438441}
439442
443+ function onGoBack(record ? : SelectionItem ) {
444+ const res = urlTracker .value .getUrl (record , true );
445+
446+ currentDirectory .value = res .url ;
447+
448+ load ();
449+
450+ if (res ?.popped ) {
451+ selectionDialog .value ?.resetPagination (res ?.popped .parentPage );
452+ }
453+ }
454+
455+ watch (query , () => {
456+ selectionDialog .value ?.resetPagination (1 );
457+ });
458+
440459onMounted (() => {
441- load (props .selectedItem );
460+ currentDirectory .value = urlTracker .value .getUrl (props .selectedItem );
461+ load ();
442462});
443463 </script >
444464
445465<template >
446466 <SelectionDialog
467+ ref =" selectionDialog"
447468 :disable-ok =" okButtonDisabled"
448469 :error-message =" errorMessage"
449470 :file-mode =" fileMode"
450471 :fields =" fields"
451472 :is-busy =" isBusy"
452473 :items =" items"
453474 :items-provider =" itemsProvider"
454- :provider-url =" currentDirectory?.url"
455475 :total-items =" totalItems"
456476 :modal-show =" modalShow"
457477 :modal-static =" modalStatic"
@@ -460,12 +480,13 @@ onMounted(() => {
460480 :select-all-variant =" selectAllIcon"
461481 :show-select-icon =" undoShow && multiple"
462482 :undo-show =" undoShow"
483+ :watch-on-page-changes =" false"
463484 @onCancel =" () => (modalShow = false)"
464485 @onClick =" clicked"
465486 @onOk =" onOk"
466487 @onOpen =" open"
467488 @onSelectAll =" onSelectAll"
468- @onUndo =" load() " >
489+ @onUndo =" onGoBack " >
469490 <template v-slot :helper >
470491 <BAlert v-if =" showFTPHelper && isConfigLoaded" id =" helper" variant =" info" show >
471492 This Galaxy server allows you to upload files via FTP. To upload some files, log in to the FTP server at
0 commit comments