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