1- import { useFileDialog } from '@vueuse/core' ;
21import { readFileContentToStringRef } from '@/utility/readFileContent' ;
32import type { Ref } from 'vue' ;
43import { getDataForMode , getSchemaForMode } from '@/data/useDataLink' ;
@@ -18,27 +17,18 @@ import type {JsonSchemaType} from '@/schema/jsonSchemaType';
1817import { identifyArraysInJson } from '@/utility/arrayPathUtils' ;
1918import { stringToIdentifier } from '@/utility/stringToIdentifier' ;
2019import { useErrorService } from '@/utility/errorServiceInstance' ;
20+ import { createLazySingleFileDialog } from '@/utility/fileDialogUtils' ;
2121
22- export function requestUploadFileToRef ( resultString : Ref < string > , resultTableName : Ref < string > ) {
23- const { open, onChange, reset} = useFileDialog ( {
24- // accept only json, schema.json, yaml, yml, xml and xsd files
25- accept : '.csv' ,
26- multiple : false ,
27- } ) ;
22+ const csvFileDialog = createLazySingleFileDialog ( '.csv' ) ;
2823
29- onChange ( ( files : FileList | null ) => {
24+ export function requestUploadFileToRef ( resultString : Ref < string > , resultTableName : Ref < string > ) {
25+ csvFileDialog . openForSelection ( files => {
3026 const firstFile = files ?. [ 0 ] ;
3127 if ( firstFile ) {
3228 resultTableName . value = stringToIdentifier ( firstFile . name , true ) ; // Get the name of the first file
3329 readFileContentToStringRef ( files , resultString ) ;
3430 }
35- reset ( ) ; // Reset the file dialog after selection
3631 } ) ;
37-
38- // opening it with a small delay might fix the issue of the dialog opening but onChange never triggering
39- setTimeout ( ( ) => {
40- open ( ) ;
41- } , 3 ) ;
4232}
4333
4434export function inferSchemaForNewDataAndMergeIntoCurrentSchema (
0 commit comments