mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-20 20:35:59 +00:00
free table editor - working macros
This commit is contained in:
@@ -190,6 +190,7 @@
|
||||
export let allRowCount = undefined;
|
||||
export let onReferenceSourceChanged = undefined;
|
||||
export let onReferenceClick = undefined;
|
||||
export let onSelectionChanged = undefined;
|
||||
export let onSave;
|
||||
export let focusOnVisible = false;
|
||||
export let onExportGrid = null;
|
||||
@@ -417,6 +418,30 @@
|
||||
domFocusField.focus();
|
||||
}
|
||||
|
||||
const lastPublishledRef = { current: '' };
|
||||
$: if (onSelectionChanged) {
|
||||
const published = getCellsPublished(selectedCells);
|
||||
const stringified = stableStringify(published);
|
||||
if (lastPublishledRef.current != stringified) {
|
||||
// console.log('PUBLISH', published);
|
||||
// console.log('lastPublishledRef.current', lastPublishledRef.current);
|
||||
// console.log('stringified', stringified);
|
||||
lastPublishledRef.current = stringified;
|
||||
onSelectionChanged(published);
|
||||
}
|
||||
}
|
||||
|
||||
function getCellsPublished(cells) {
|
||||
const regular = cellsToRegularCells(cells);
|
||||
// @ts-ignore
|
||||
return regular
|
||||
.map(cell => ({
|
||||
row: cell[0],
|
||||
column: realColumnUniqueNames[cell[1]],
|
||||
}))
|
||||
.filter(x => x.column);
|
||||
}
|
||||
|
||||
function scrollIntoView(cell) {
|
||||
const [row, col] = cell;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<script lang="ts" context="module">
|
||||
function extractMacroValuesForMacro(macroValues, macro) {
|
||||
// return {};
|
||||
if (!macro) return {};
|
||||
return {
|
||||
..._.fromPairs((macro.args || []).filter(x => x.default != null).map(x => [x.name, x.default])),
|
||||
@@ -28,6 +29,7 @@
|
||||
export let dispatchModel;
|
||||
|
||||
let managerSize;
|
||||
let selectedCellsPublished = [];
|
||||
|
||||
const selectedMacro = writable(null);
|
||||
setContext('selectedMacro', selectedMacro);
|
||||
@@ -37,10 +39,10 @@
|
||||
const handleExecuteMacro = () => {
|
||||
const newModel = runMacro(
|
||||
$selectedMacro,
|
||||
extractMacroValuesForMacro(macroValues, selectedMacro),
|
||||
extractMacroValuesForMacro($macroValues, $selectedMacro),
|
||||
modelState.value,
|
||||
false,
|
||||
[] // selectedCells
|
||||
selectedCellsPublished
|
||||
);
|
||||
dispatchModel({ type: 'set', value: newModel });
|
||||
$selectedMacro = null;
|
||||
@@ -62,7 +64,13 @@
|
||||
<div class="grid" slot="2">
|
||||
<VerticalSplitter initialValue="70%" isSplitter={!!$selectedMacro}>
|
||||
<svelte:fragment slot="1">
|
||||
<FreeTableGridCore {...$$props} />
|
||||
<FreeTableGridCore
|
||||
{...$$props}
|
||||
onSelectionChanged={value => (selectedCellsPublished = value)}
|
||||
macroValues={extractMacroValuesForMacro($macroValues, $selectedMacro)}
|
||||
{selectedCellsPublished}
|
||||
macroPreview={$selectedMacro}
|
||||
/>
|
||||
</svelte:fragment>
|
||||
|
||||
<!-- macroPreview={selectedMacro}
|
||||
|
||||
@@ -16,12 +16,12 @@
|
||||
export let macroValues;
|
||||
export let config;
|
||||
export let setConfig;
|
||||
export let selectedCellsPublished;
|
||||
|
||||
let selectedCells = [];
|
||||
const cache = writable(createGridCache());
|
||||
|
||||
$: grider = macroPreview
|
||||
? new MacroPreviewGrider(modelState.value, macroPreview, macroValues, selectedCells)
|
||||
? new MacroPreviewGrider(modelState.value, macroPreview, macroValues, selectedCellsPublished)
|
||||
: new FreeTableGrider(modelState, dispatchModel);
|
||||
$: display = new FreeTableGridDisplay(grider.model || modelState.value, config, setConfig, $cache, cache.update);
|
||||
|
||||
|
||||
@@ -19,6 +19,9 @@
|
||||
{
|
||||
label: 'Macro detail',
|
||||
component: MacroInfoTab,
|
||||
props: {
|
||||
onExecute,
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'JavaScript',
|
||||
|
||||
Reference in New Issue
Block a user