mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-17 22:36:01 +00:00
SYNC: Run macro context menu
This commit is contained in:
committed by
Diflow
parent
bc695f5af9
commit
a0b025cf59
@@ -45,7 +45,7 @@
|
||||
category: __t('command.datagrid', { defaultMessage: 'Data grid' }),
|
||||
name: __t('command.datagrid.toggleCellDataView', { defaultMessage: 'Toggle cell data view' }),
|
||||
toolbarName: __t('command.datagrid.toggleCellDataView.toolbar', { defaultMessage: 'Cell Data' }),
|
||||
menuName: __t('command.datagrid.toggleCellDataView.menu', { defaultMessage: 'Show Cell Data' }),
|
||||
menuName: __t('command.datagrid.toggleCellDataView.menu', { defaultMessage: 'Show cell data' }),
|
||||
icon: 'icon cell-data',
|
||||
testEnabled: () => !!getCurrentEditor(),
|
||||
onClick: () => getCurrentEditor().toggleCellDataView(),
|
||||
|
||||
@@ -354,7 +354,7 @@
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import { GridDisplay } from 'dbgate-datalib';
|
||||
import { GridDisplay, MacroDefinition } from 'dbgate-datalib';
|
||||
import {
|
||||
driverBase,
|
||||
parseCellValue,
|
||||
@@ -364,6 +364,7 @@
|
||||
base64ToHex,
|
||||
} from 'dbgate-tools';
|
||||
import { getContext, onDestroy } from 'svelte';
|
||||
import { type Writable } from 'svelte/store';
|
||||
import _, { map } from 'lodash';
|
||||
import registerCommand from '../commands/registerCommand';
|
||||
import ColumnHeaderControl from './ColumnHeaderControl.svelte';
|
||||
@@ -476,6 +477,7 @@
|
||||
export let overlayDefinition = null;
|
||||
export let onGetSelectionMenu = null;
|
||||
export let onOpenChart = null;
|
||||
export let macroCondition = null;
|
||||
|
||||
export const activator = createActivator('DataGridCore', false);
|
||||
|
||||
@@ -507,6 +509,7 @@
|
||||
let selectionMenu = null;
|
||||
|
||||
const tabid = getContext('tabid');
|
||||
const selectedMacro = getContext('selectedMacro') as Writable<MacroDefinition>;
|
||||
|
||||
let unsubscribeDbRefresh;
|
||||
|
||||
@@ -1919,11 +1922,15 @@
|
||||
{ command: 'dataGrid.loadCellFromFile', hideDisabled: true },
|
||||
{ command: 'dataGrid.toggleCellDataView', hideDisabled: true },
|
||||
isProApp() && {
|
||||
text: _t('datagrid.runMacro', { defaultMessage: 'Run macro' }),
|
||||
submenu: macros.map(macro => ({
|
||||
text: macro.name,
|
||||
onClick: () => {},
|
||||
})),
|
||||
text: _t('datagrid.useMacro', { defaultMessage: 'Use macro' }),
|
||||
submenu: macros
|
||||
.filter(macro => !macroCondition || macroCondition(macro))
|
||||
.map(macro => ({
|
||||
text: _tval(macro.title),
|
||||
onClick: () => {
|
||||
selectedMacro.set(macro);
|
||||
},
|
||||
})),
|
||||
},
|
||||
// { command: 'dataGrid.copyJsonDocument', hideDisabled: true },
|
||||
{ divider: true },
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import FormStringList from './FormStringList.svelte';
|
||||
import FormDropDownTextField from './FormDropDownTextField.svelte';
|
||||
import { getFormContext } from './FormProviderCore.svelte';
|
||||
import { _tval } from '../translations';
|
||||
|
||||
export let arg;
|
||||
export let namePrefix;
|
||||
@@ -18,7 +19,7 @@
|
||||
|
||||
{#if arg.type == 'text'}
|
||||
<FormTextField
|
||||
label={arg.label}
|
||||
label={_tval(arg.label)}
|
||||
{name}
|
||||
defaultValue={arg.default}
|
||||
focused={arg.focused}
|
||||
@@ -26,10 +27,15 @@
|
||||
disabled={arg.disabledFn ? arg.disabledFn($values) : arg.disabled}
|
||||
/>
|
||||
{:else if arg.type == 'stringlist'}
|
||||
<FormStringList label={arg.label} addButtonLabel={arg.addButtonLabel} {name} placeholder={arg.placeholder} />
|
||||
<FormStringList
|
||||
label={_tval(arg.label)}
|
||||
addButtonLabel={_tval(arg.addButtonLabel)}
|
||||
{name}
|
||||
placeholder={arg.placeholder}
|
||||
/>
|
||||
{:else if arg.type == 'number'}
|
||||
<FormTextField
|
||||
label={arg.label}
|
||||
label={_tval(arg.label)}
|
||||
type="number"
|
||||
{name}
|
||||
defaultValue={arg.default}
|
||||
@@ -39,14 +45,14 @@
|
||||
/>
|
||||
{:else if arg.type == 'checkbox'}
|
||||
<FormCheckboxField
|
||||
label={arg.label}
|
||||
label={_tval(arg.label)}
|
||||
{name}
|
||||
defaultValue={arg.default}
|
||||
disabled={arg.disabledFn ? arg.disabledFn($values) : arg.disabled}
|
||||
/>
|
||||
{:else if arg.type == 'select'}
|
||||
<FormSelectField
|
||||
label={arg.label}
|
||||
label={_tval(arg.label)}
|
||||
isNative
|
||||
{name}
|
||||
defaultValue={arg.default}
|
||||
@@ -57,7 +63,7 @@
|
||||
/>
|
||||
{:else if arg.type == 'dropdowntext'}
|
||||
<FormDropDownTextField
|
||||
label={arg.label}
|
||||
label={_tval(arg.label)}
|
||||
{name}
|
||||
defaultValue={arg.default}
|
||||
menu={() => {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import { getContext } from 'svelte';
|
||||
import FontIcon from '../icons/FontIcon.svelte';
|
||||
import ToolbarButton from '../buttons/ToolbarButton.svelte';
|
||||
import { _t } from '../translations';
|
||||
import { _t, _tval } from '../translations';
|
||||
|
||||
export let onExecute;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<div class="header">
|
||||
<FontIcon icon="img macro" />
|
||||
<div class="ml-2">
|
||||
{$selectedMacro?.title}
|
||||
{_tval($selectedMacro?.title)}
|
||||
</div>
|
||||
</div>
|
||||
<div class="buttons">
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import WidgetTitle from '../widgets/WidgetTitle.svelte';
|
||||
import MacroParameters from './MacroParameters.svelte';
|
||||
import { _t } from '../translations';
|
||||
import { _t, _tval } from '../translations';
|
||||
|
||||
const selectedMacro = getContext('selectedMacro') as any;
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
<div class="section">
|
||||
<WidgetTitle>{_t('common.description', { defaultMessage: 'Description' })}</WidgetTitle>
|
||||
<div class="m-1">{$selectedMacro?.description}</div>
|
||||
<div class="m-1">{_tval($selectedMacro?.description)}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user