mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-20 21:46:00 +00:00
export from free table editor
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
import { createGridCache, FreeTableGridDisplay } from 'dbgate-datalib';
|
||||
import React from 'react';
|
||||
import DataGridCore from '../datagrid/DataGridCore';
|
||||
import useShowModal from '../modals/showModal';
|
||||
import axios from '../utility/axios';
|
||||
import keycodes from '../utility/keycodes';
|
||||
import FreeTableGrider from './FreeTableGrider';
|
||||
import MacroPreviewGrider from './MacroPreviewGrider';
|
||||
import uuidv1 from 'uuid/v1';
|
||||
import ImportExportModal from '../modals/ImportExportModal';
|
||||
|
||||
export default function FreeTableGridCore(props) {
|
||||
const {
|
||||
@@ -18,6 +22,7 @@ export default function FreeTableGridCore(props) {
|
||||
} = props;
|
||||
const [cache, setCache] = React.useState(createGridCache());
|
||||
const [selectedCells, setSelectedCells] = React.useState([]);
|
||||
const showModal = useShowModal();
|
||||
const grider = React.useMemo(
|
||||
() =>
|
||||
macroPreview
|
||||
@@ -30,12 +35,20 @@ export default function FreeTableGridCore(props) {
|
||||
macroPreview ? selectedCells : null,
|
||||
]
|
||||
);
|
||||
const display = React.useMemo(() => new FreeTableGridDisplay(grider.model || modelState.value, config, setConfig, cache, setCache), [
|
||||
modelState.value,
|
||||
config,
|
||||
cache,
|
||||
grider,
|
||||
]);
|
||||
const display = React.useMemo(
|
||||
() => new FreeTableGridDisplay(grider.model || modelState.value, config, setConfig, cache, setCache),
|
||||
[modelState.value, config, cache, grider]
|
||||
);
|
||||
|
||||
async function exportGrid() {
|
||||
const jslid = uuidv1();
|
||||
await axios.post('jsldata/save-free-table', { jslid, data: modelState.value });
|
||||
const initialValues = {};
|
||||
initialValues.sourceStorageType = 'jsldata';
|
||||
initialValues.sourceJslId = jslid;
|
||||
initialValues.sourceList = ['editor-data'];
|
||||
showModal((modalState) => <ImportExportModal modalState={modalState} initialValues={initialValues} />);
|
||||
}
|
||||
|
||||
const handleSelectionChanged = React.useCallback(
|
||||
(cells) => {
|
||||
@@ -58,6 +71,7 @@ export default function FreeTableGridCore(props) {
|
||||
display={display}
|
||||
onSelectionChanged={macroPreview ? handleSelectionChanged : null}
|
||||
frameSelection={!!macroPreview}
|
||||
exportGrid={exportGrid}
|
||||
onKeyDown={handleKeyDown}
|
||||
/>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user