mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-20 15:56:00 +00:00
quick export from free table editor
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
import { createGridCache, FreeTableGridDisplay } from 'dbgate-datalib';
|
||||
import { writable } from 'svelte/store';
|
||||
import uuidv1 from 'uuid/v1';
|
||||
import { registerQuickExportHandler } from '../buttons/ToolStripExportButton.svelte';
|
||||
import registerCommand from '../commands/registerCommand';
|
||||
|
||||
import DataGridCore from '../datagrid/DataGridCore.svelte';
|
||||
@@ -24,6 +25,8 @@
|
||||
import { apiCall } from '../utility/api';
|
||||
import { registerMenu } from '../utility/contextMenu';
|
||||
import createActivator, { getActiveComponent } from '../utility/createActivator';
|
||||
import createQuickExportMenu from '../utility/createQuickExportMenu';
|
||||
import { exportQuickExportFile } from '../utility/exportFileTools';
|
||||
import FreeTableGrider from './FreeTableGrider';
|
||||
import MacroPreviewGrider from './MacroPreviewGrider';
|
||||
|
||||
@@ -51,10 +54,31 @@
|
||||
initialValues.sourceStorageType = 'jsldata';
|
||||
initialValues.sourceJslId = jslid;
|
||||
initialValues.sourceList = ['editor-data'];
|
||||
initialValues[`columns_editor-data`] = display.getExportColumnMap();
|
||||
showModal(ImportExportModal, { initialValues: initialValues });
|
||||
}
|
||||
|
||||
registerMenu({ command: 'freeTableGrid.export', tag: 'export' });
|
||||
const quickExportHandler = fmt => async () => {
|
||||
const jslid = uuidv1();
|
||||
await apiCall('jsldata/save-free-table', { jslid, data: modelState.value });
|
||||
exportQuickExportFile(
|
||||
'editor-data',
|
||||
{
|
||||
functionName: 'jslDataReader',
|
||||
props: {
|
||||
jslid,
|
||||
},
|
||||
},
|
||||
fmt,
|
||||
display.getExportColumnMap()
|
||||
);
|
||||
};
|
||||
registerQuickExportHandler(quickExportHandler);
|
||||
|
||||
registerMenu(() => ({
|
||||
...createQuickExportMenu(quickExportHandler, { command: 'freeTableGrid.export' }),
|
||||
tag: 'export',
|
||||
}));
|
||||
</script>
|
||||
|
||||
<DataGridCore {...$$props} {grider} {display} frameSelection={!!macroPreview} bind:selectedCellsPublished />
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
import { writable } from 'svelte/store';
|
||||
import ToolStripCommandButton from '../buttons/ToolStripCommandButton.svelte';
|
||||
import ToolStripContainer from '../buttons/ToolStripContainer.svelte';
|
||||
import ToolStripExportButton from '../buttons/ToolStripExportButton.svelte';
|
||||
import ToolStripExportButton, { createQuickExportHandlerRef } from '../buttons/ToolStripExportButton.svelte';
|
||||
import registerCommand from '../commands/registerCommand';
|
||||
import DataGrid from '../datagrid/DataGrid.svelte';
|
||||
import ErrorInfo from '../elements/ErrorInfo.svelte';
|
||||
@@ -137,6 +137,8 @@ import ToolStripExportButton from '../buttons/ToolStripExportButton.svelte';
|
||||
|
||||
// display is overridden in FreeTableGridCore, this is because of column manager
|
||||
$: display = new FreeTableGridDisplay($modelState.value, $config, config.update, null, null);
|
||||
|
||||
const quickExportHandlerRef = createQuickExportHandlerRef();
|
||||
</script>
|
||||
|
||||
{#if isLoading}
|
||||
@@ -161,7 +163,7 @@ import ToolStripExportButton from '../buttons/ToolStripExportButton.svelte';
|
||||
/>
|
||||
<svelte:fragment slot="toolstrip">
|
||||
<ToolStripCommandButton command="freeTable.save" />
|
||||
<ToolStripExportButton command="freeTableGrid.export" />
|
||||
<ToolStripExportButton command="freeTableGrid.export" {quickExportHandlerRef} />
|
||||
</svelte:fragment>
|
||||
</ToolStripContainer>
|
||||
{/if}
|
||||
|
||||
Reference in New Issue
Block a user