mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-20 17:06:01 +00:00
export grid command refactor
This commit is contained in:
@@ -1,12 +1,28 @@
|
||||
<script context="module" lang="ts">
|
||||
const getCurrentEditor = () => getActiveComponent('FreeTableGridCore');
|
||||
|
||||
registerCommand({
|
||||
id: 'freeTableGrid.export',
|
||||
category: 'Data grid',
|
||||
name: 'Export',
|
||||
keyText: 'Ctrl+E',
|
||||
testEnabled: () => getCurrentEditor() != null,
|
||||
onClick: () => getCurrentEditor().exportGrid(),
|
||||
});
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import { createGridCache, FreeTableGridDisplay } from 'dbgate-datalib';
|
||||
import { writable } from 'svelte/store';
|
||||
import uuidv1 from 'uuid/v1';
|
||||
import registerCommand from '../commands/registerCommand';
|
||||
|
||||
import DataGridCore from '../datagrid/DataGridCore.svelte';
|
||||
import ImportExportModal from '../modals/ImportExportModal.svelte';
|
||||
import { showModal } from '../modals/modalTools';
|
||||
import axiosInstance from '../utility/axiosInstance';
|
||||
import { registerMenu } from '../utility/contextMenu';
|
||||
import createActivator, { getActiveComponent } from '../utility/createActivator';
|
||||
import FreeTableGrider from './FreeTableGrider';
|
||||
import MacroPreviewGrider from './MacroPreviewGrider';
|
||||
|
||||
@@ -18,6 +34,8 @@
|
||||
export let setConfig;
|
||||
export let selectedCellsPublished;
|
||||
|
||||
export const activator = createActivator('FreeTableGridCore', false);
|
||||
|
||||
const cache = writable(createGridCache());
|
||||
|
||||
$: grider = macroPreview
|
||||
@@ -25,7 +43,7 @@
|
||||
: new FreeTableGrider(modelState, dispatchModel);
|
||||
$: display = new FreeTableGridDisplay(grider.model || modelState.value, config, setConfig, $cache, cache.update);
|
||||
|
||||
async function exportGrid() {
|
||||
export async function exportGrid() {
|
||||
const jslid = uuidv1();
|
||||
await axiosInstance.post('jsldata/save-free-table', { jslid, data: modelState.value });
|
||||
const initialValues: any = {};
|
||||
@@ -34,14 +52,8 @@
|
||||
initialValues.sourceList = ['editor-data'];
|
||||
showModal(ImportExportModal, { initialValues: initialValues });
|
||||
}
|
||||
|
||||
registerMenu({ command: 'freeTableGrid.export', tag: 'export' });
|
||||
</script>
|
||||
|
||||
<DataGridCore
|
||||
{...$$props}
|
||||
{grider}
|
||||
{display}
|
||||
frameSelection={!!macroPreview}
|
||||
{exportGrid}
|
||||
onExportGrid={exportGrid}
|
||||
bind:selectedCellsPublished
|
||||
/>
|
||||
<DataGridCore {...$$props} {grider} {display} frameSelection={!!macroPreview} bind:selectedCellsPublished />
|
||||
|
||||
Reference in New Issue
Block a user