fixed upload file

This commit is contained in:
Jan Prochazka 2024-09-16 17:16:54 +02:00
parent a9a5a3491e
commit 88d7e07bea
3 changed files with 56 additions and 36 deletions

View File

@ -68,8 +68,8 @@
import SourceTargetConfig from './SourceTargetConfig.svelte';
export let uploadedFile = undefined;
export let openedFile = undefined;
// export let uploadedFile = undefined;
// export let openedFile = undefined;
export let previewReaderStore;
const { values, setFieldValue } = getFormContext();
@ -98,7 +98,7 @@
}
};
const handleUpload = file => {
export function addUploadedFile(file) {
addFilesToSourceList(
$extensions,
[
@ -116,26 +116,26 @@
};
onMount(() => {
setUploadListener(handleUpload);
if (uploadedFile) {
handleUpload(uploadedFile);
}
if (openedFile) {
handleUpload(openedFile);
// addFilesToSourceList(
// $extensions,
// [
// {
// fileName: openedFile.filePath,
// shortName: openedFile.shortName,
// },
// ],
// $values,
// values,
// !sourceList || sourceList.length == 0 ? openedFile.storageType : null,
// previewSource.set
// );
}
setUploadListener(addUploadedFile);
// if (uploadedFile) {
// handleUpload(uploadedFile);
// }
// if (openedFile) {
// handleUpload(openedFile);
// // addFilesToSourceList(
// // $extensions,
// // [
// // {
// // fileName: openedFile.filePath,
// // shortName: openedFile.shortName,
// // },
// // ],
// // $values,
// // values,
// // !sourceList || sourceList.length == 0 ? openedFile.storageType : null,
// // previewSource.set
// // );
// }
return () => {
setUploadListener(null);

View File

@ -42,22 +42,42 @@
const refreshArchiveFolderRef = createRef(null);
const formValues = writable({
sourceStorageType: 'database',
targetStorageType: getDefaultFileFormat($extensions).storageType,
targetArchiveFolder: $currentArchive,
sourceArchiveFolder: $currentArchive,
...detectCurrentTarget(),
...initialValues,
});
const formValues = writable({});
let domConfigurator;
// const formValues = writable({
// sourceStorageType: 'database',
// targetStorageType: getDefaultFileFormat($extensions).storageType,
// targetArchiveFolder: $currentArchive,
// sourceArchiveFolder: $currentArchive,
// ...detectCurrentTarget(),
// ...initialValues,
// });
const { editorState, editorValue, setEditorData } = useEditorData({
tabid,
onInitialData: value => {
$formValues = value;
$formValues = {
sourceStorageType: 'database',
targetStorageType: getDefaultFileFormat($extensions).storageType,
targetArchiveFolder: $currentArchive,
sourceArchiveFolder: $currentArchive,
...detectCurrentTarget(),
...value,
};
if (uploadedFile) {
domConfigurator.addUploadedFile(uploadedFile);
}
if (openedFile) {
domConfigurator.addUploadedFile(openedFile);
}
},
});
// $: console.log('formValues', $formValues);
$: setEditorData($formValues);
function detectCurrentTarget() {
@ -111,7 +131,7 @@
};
const handleGenerateScript = async e => {
const values = $formValues;
const values = $formValues as any;
const code = await createImpExpScript($extensions, values, undefined, true);
openNewTab(
{
@ -125,7 +145,7 @@
const handleExecute = async e => {
if (busy) return;
const values = $formValues;
const values = $formValues as any;
busy = true;
const script = await createImpExpScript($extensions, values);
executeNumber += 1;
@ -152,7 +172,7 @@
<FormProviderCore values={formValues}>
<HorizontalSplitter initialValue="70%">
<div class="content" slot="1">
<ImportExportConfigurator {uploadedFile} {openedFile} {previewReaderStore} />
<ImportExportConfigurator bind:this={domConfigurator} {previewReaderStore} />
{#if busy}
<LoadingInfo wrapper message="Processing import/export ..." />

View File

@ -6,7 +6,7 @@ export function openImportExportTab(editorProps, additionalProps = {}) {
tabComponent: 'ImportExportTab',
title: 'Import/Export',
icon: 'img export',
...additionalProps,
props: additionalProps,
},
{
editor: editorProps,