mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-21 21:06:00 +00:00
run macro on jsl data
This commit is contained in:
@@ -214,7 +214,8 @@ export function runMacroOnChangeSet(
|
|||||||
macroArgs: {},
|
macroArgs: {},
|
||||||
selectedCells: MacroSelectedCell[],
|
selectedCells: MacroSelectedCell[],
|
||||||
changeSet: ChangeSet,
|
changeSet: ChangeSet,
|
||||||
display: GridDisplay
|
display: GridDisplay,
|
||||||
|
useRowIndexInsteaOfCondition: boolean
|
||||||
): ChangeSet {
|
): ChangeSet {
|
||||||
const errors = [];
|
const errors = [];
|
||||||
const compiledMacroFunc = compileMacroFunction(macro, errors);
|
const compiledMacroFunc = compileMacroFunction(macro, errors);
|
||||||
@@ -222,7 +223,13 @@ export function runMacroOnChangeSet(
|
|||||||
|
|
||||||
let res = changeSet;
|
let res = changeSet;
|
||||||
for (const cell of selectedCells) {
|
for (const cell of selectedCells) {
|
||||||
const definition = display.getChangeSetField(cell.rowData, cell.column, undefined);
|
const definition = display.getChangeSetField(
|
||||||
|
cell.rowData,
|
||||||
|
cell.column,
|
||||||
|
undefined,
|
||||||
|
useRowIndexInsteaOfCondition ? cell.row : undefined,
|
||||||
|
useRowIndexInsteaOfCondition
|
||||||
|
);
|
||||||
const macroResult = runMacroOnValue(
|
const macroResult = runMacroOnValue(
|
||||||
compiledMacroFunc,
|
compiledMacroFunc,
|
||||||
macroArgs,
|
macroArgs,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { createGridCache, createGridConfig, JslGridDisplay } from 'dbgate-datalib';
|
import { createGridCache, createGridConfig, JslGridDisplay, runMacro, runMacroOnChangeSet } from 'dbgate-datalib';
|
||||||
import { generateTablePairingId, processJsonDataUpdateCommands } from 'dbgate-tools';
|
import { generateTablePairingId, processJsonDataUpdateCommands } from 'dbgate-tools';
|
||||||
import { writable } from 'svelte/store';
|
import { writable } from 'svelte/store';
|
||||||
import JslFormView from '../formview/JslFormView.svelte';
|
import JslFormView from '../formview/JslFormView.svelte';
|
||||||
@@ -33,6 +33,13 @@
|
|||||||
infoCounter += 1;
|
infoCounter += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleRunMacro(macro, params, cells) {
|
||||||
|
const newChangeSet = runMacroOnChangeSet(macro, params, cells, changeSetState?.value, display, true);
|
||||||
|
if (newChangeSet) {
|
||||||
|
dispatchChangeSet({ type: 'set', value: newChangeSet });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$: effect = useEffect(() => onJslId(jslid));
|
$: effect = useEffect(() => onJslId(jslid));
|
||||||
function onJslId(jslidVal) {
|
function onJslId(jslidVal) {
|
||||||
if (jslidVal && listenInitializeFile) {
|
if (jslidVal && listenInitializeFile) {
|
||||||
@@ -77,6 +84,10 @@
|
|||||||
bind:loadedRows
|
bind:loadedRows
|
||||||
isDynamicStructure={!!infoUsed?.__isDynamicStructure}
|
isDynamicStructure={!!infoUsed?.__isDynamicStructure}
|
||||||
useEvalFilters
|
useEvalFilters
|
||||||
|
showMacros={!!dispatchChangeSet}
|
||||||
|
expandMacros={!!dispatchChangeSet}
|
||||||
|
onRunMacro={handleRunMacro}
|
||||||
|
macroCondition={infoUsed?.__isDynamicStructure ? null : macro => macro.type == 'transformValue'}
|
||||||
{changeSetState}
|
{changeSetState}
|
||||||
{changeSetStore}
|
{changeSetStore}
|
||||||
{dispatchChangeSet}
|
{dispatchChangeSet}
|
||||||
|
|||||||
@@ -67,6 +67,9 @@
|
|||||||
export let changeSetState;
|
export let changeSetState;
|
||||||
export let dispatchChangeSet;
|
export let dispatchChangeSet;
|
||||||
|
|
||||||
|
export let macroPreview;
|
||||||
|
export let macroValues;
|
||||||
|
export let selectedCellsPublished = () => [];
|
||||||
export const activator = createActivator('JslDataGridCore', false);
|
export const activator = createActivator('JslDataGridCore', false);
|
||||||
|
|
||||||
export let loadedRows = [];
|
export let loadedRows = [];
|
||||||
@@ -97,16 +100,37 @@
|
|||||||
}
|
}
|
||||||
$: $effect;
|
$: $effect;
|
||||||
|
|
||||||
$: grider = new ChangeSetGrider(
|
let grider;
|
||||||
loadedRows,
|
|
||||||
changeSetState,
|
$: {
|
||||||
dispatchChangeSet,
|
if (macroPreview) {
|
||||||
display,
|
grider = new ChangeSetGrider(
|
||||||
undefined,
|
loadedRows,
|
||||||
undefined,
|
changeSetState,
|
||||||
undefined,
|
dispatchChangeSet,
|
||||||
true
|
display,
|
||||||
);
|
macroPreview,
|
||||||
|
macroValues,
|
||||||
|
selectedCellsPublished(),
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$: {
|
||||||
|
if (!macroPreview) {
|
||||||
|
grider = new ChangeSetGrider(
|
||||||
|
loadedRows,
|
||||||
|
changeSetState,
|
||||||
|
dispatchChangeSet,
|
||||||
|
display,
|
||||||
|
undefined,
|
||||||
|
undefined,
|
||||||
|
undefined,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// $: grider = new RowsArrayGrider(loadedRows);
|
// $: grider = new RowsArrayGrider(loadedRows);
|
||||||
|
|
||||||
@@ -168,6 +192,7 @@
|
|||||||
bind:this={domGrid}
|
bind:this={domGrid}
|
||||||
{...$$props}
|
{...$$props}
|
||||||
bind:loadedRows
|
bind:loadedRows
|
||||||
|
bind:selectedCellsPublished
|
||||||
{loadDataPage}
|
{loadDataPage}
|
||||||
{dataPageAvailable}
|
{dataPageAvailable}
|
||||||
{loadRowCount}
|
{loadRowCount}
|
||||||
|
|||||||
@@ -140,7 +140,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
function handleRunMacro(macro, params, cells) {
|
function handleRunMacro(macro, params, cells) {
|
||||||
const newChangeSet = runMacroOnChangeSet(macro, params, cells, changeSetState?.value, display);
|
const newChangeSet = runMacroOnChangeSet(macro, params, cells, changeSetState?.value, display, false);
|
||||||
if (newChangeSet) {
|
if (newChangeSet) {
|
||||||
dispatchChangeSet({ type: 'set', value: newChangeSet });
|
dispatchChangeSet({ type: 'set', value: newChangeSet });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -154,7 +154,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handleRunMacro(macro, params, cells) {
|
function handleRunMacro(macro, params, cells) {
|
||||||
const newChangeSet = runMacroOnChangeSet(macro, params, cells, $changeSetStore?.value, display);
|
const newChangeSet = runMacroOnChangeSet(macro, params, cells, $changeSetStore?.value, display, false);
|
||||||
if (newChangeSet) {
|
if (newChangeSet) {
|
||||||
dispatchChangeSet({ type: 'set', value: newChangeSet });
|
dispatchChangeSet({ type: 'set', value: newChangeSet });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -155,7 +155,7 @@
|
|||||||
$selectedWidget = 'archive';
|
$selectedWidget = 'archive';
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<FontIcon icon="icon archive" />
|
<FontIcon icon="icon archive" padRight />
|
||||||
{$currentArchive}
|
{$currentArchive}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
Reference in New Issue
Block a user