mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-20 13:36:02 +00:00
translation-clipboard, exportMenu, macros, datagrid commands
This commit is contained in:
@@ -40,7 +40,16 @@
|
||||
|
||||
$: dataLabeled = _.compact(
|
||||
(list || []).map(data => {
|
||||
const matchResult = matcher ? matcher(data) : true;
|
||||
const dataCopy = { ...data };
|
||||
if (dataCopy?.group && _.isFunction(dataCopy.group)) dataCopy.group = dataCopy.group();
|
||||
if (dataCopy?.title && _.isFunction(dataCopy.title)) dataCopy.title = dataCopy.title();
|
||||
if (dataCopy?.description && _.isFunction(dataCopy.description)) dataCopy.description = dataCopy.description();
|
||||
(dataCopy?.args || []).map(x => {
|
||||
if(x?.label && _.isFunction(x.label)) x.label = x.label();
|
||||
})
|
||||
|
||||
|
||||
const matchResult = matcher ? matcher(dataCopy) : true;
|
||||
|
||||
let isMatched = true;
|
||||
let isMainMatched = true;
|
||||
@@ -62,8 +71,8 @@
|
||||
isChildMatched = !module.disableShowChildrenWithParentMatch;
|
||||
}
|
||||
|
||||
const group = groupFunc ? groupFunc(data) : undefined;
|
||||
return { group, data, isMatched, isChildMatched, isMainMatched };
|
||||
const group = groupFunc ? groupFunc(dataCopy) : undefined;
|
||||
return { group, data: dataCopy, isMatched, isChildMatched, isMainMatched };
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script context="module">
|
||||
function getCommandTitle(command) {
|
||||
let res = command.text;
|
||||
let res = _.isFunction(command.text) ? command.text() : command.text;
|
||||
if (command.keyText || command.keyTextFromGroup) {
|
||||
res += ` (${formatKeyText(command.keyText || command.keyTextFromGroup)})`;
|
||||
}
|
||||
@@ -12,6 +12,7 @@
|
||||
import { commandsCustomized } from '../stores';
|
||||
import { formatKeyText } from '../utility/common';
|
||||
import ToolStripButton from './ToolStripButton.svelte';
|
||||
import _ from 'lodash';
|
||||
|
||||
export let command;
|
||||
export let component = ToolStripButton;
|
||||
@@ -32,6 +33,6 @@
|
||||
{iconAfter}
|
||||
{...$$restProps}
|
||||
>
|
||||
{buttonLabel || cmd.toolbarName || cmd.name}
|
||||
{(_.isFunction(buttonLabel) ? buttonLabel() : buttonLabel) || (_.isFunction(cmd?.toolbarName) ? cmd.toolbarName() : cmd.toolbarName) || (_.isFunction(cmd?.name) ? cmd.name() : cmd.name)}
|
||||
</svelte:component>
|
||||
{/if}
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
import hasPermission from '../utility/hasPermission';
|
||||
import ToolStripCommandButton from './ToolStripCommandButton.svelte';
|
||||
import ToolStripDropDownButton from './ToolStripDropDownButton.svelte';
|
||||
|
||||
import _ from 'lodash';
|
||||
export let quickExportHandlerRef = null;
|
||||
export let command = 'sqlDataGrid.export';
|
||||
export let label = 'Export';
|
||||
@@ -39,7 +39,7 @@
|
||||
|
||||
{#if hasPermission('dbops/export')}
|
||||
{#if quickExportHandlerRef}
|
||||
<ToolStripDropDownButton menu={getExportMenu} {label} icon="icon export" />
|
||||
<ToolStripDropDownButton menu={getExportMenu} label={_.isFunction(label) ? label() : label} icon="icon export" />
|
||||
{:else}
|
||||
<ToolStripCommandButton {command} />
|
||||
{/if}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { commands } from '../stores';
|
||||
import { invalidateCommandDefinitions } from './invalidateCommands';
|
||||
import _ from 'lodash';
|
||||
|
||||
export interface SubCommand {
|
||||
text: string;
|
||||
@@ -8,7 +9,7 @@ export interface SubCommand {
|
||||
|
||||
export interface GlobalCommand {
|
||||
id: string;
|
||||
category: string; // null for group commands
|
||||
category: string | (() => string); // null for group commands
|
||||
isGroupCommand?: boolean;
|
||||
name: string | (() => string);
|
||||
text?: string | (() => string);
|
||||
@@ -23,7 +24,7 @@ export interface GlobalCommand {
|
||||
toolbar?: boolean;
|
||||
enabled?: boolean;
|
||||
showDisabled?: boolean;
|
||||
toolbarName?: string;
|
||||
toolbarName?: string | (() => string);
|
||||
menuName?: string;
|
||||
toolbarOrder?: number;
|
||||
disableHandleKeyText?: string;
|
||||
@@ -41,7 +42,13 @@ export default function registerCommand(command: GlobalCommand) {
|
||||
return {
|
||||
...x,
|
||||
[command.id]: {
|
||||
text: `${command.category}: ${command.name}`,
|
||||
text:
|
||||
_.isFunction(command.category) || _.isFunction(command.name)
|
||||
? () =>
|
||||
`${_.isFunction(command.category) ? command.category() : command.category}: ${
|
||||
_.isFunction(command.name) ? command.name() : command.name
|
||||
}`
|
||||
: `${command.category}: ${command.name}`,
|
||||
...command,
|
||||
enabled: !testEnabled,
|
||||
},
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
registerCommand({
|
||||
id: 'dataGrid.switchToForm',
|
||||
category: 'Data grid',
|
||||
name: 'Switch to form',
|
||||
category: __t('command.datagrid', { defaultMessage: 'Data grid' }),
|
||||
name: __t('command.datagrid.switchToform', { defaultMessage: 'Switch to form' }),
|
||||
icon: 'icon form',
|
||||
keyText: 'F4',
|
||||
testEnabled: () => getCurrentEditor()?.switchViewEnabled('form'),
|
||||
@@ -13,8 +13,8 @@
|
||||
|
||||
registerCommand({
|
||||
id: 'dataGrid.switchToJson',
|
||||
category: 'Data grid',
|
||||
name: 'Switch to JSON',
|
||||
category: __t('command.datagrid', { defaultMessage: 'Data grid' }),
|
||||
name: __t('command.datagrid.switchToJSON', { defaultMessage: 'Switch to JSON' }),
|
||||
icon: 'icon json',
|
||||
keyText: 'F4',
|
||||
testEnabled: () => getCurrentEditor()?.switchViewEnabled('json'),
|
||||
@@ -23,8 +23,8 @@
|
||||
|
||||
registerCommand({
|
||||
id: 'dataGrid.switchToTable',
|
||||
category: 'Data grid',
|
||||
name: 'Switch to table',
|
||||
category: __t('command.datagrid', { defaultMessage: 'Data grid' }),
|
||||
name: __t('command.datagrid.witchToTable', { defaultMessage: 'Switch to table'}),
|
||||
icon: 'icon table',
|
||||
keyText: 'F4',
|
||||
testEnabled: () => getCurrentEditor()?.switchViewEnabled('table'),
|
||||
@@ -33,8 +33,8 @@
|
||||
|
||||
registerCommand({
|
||||
id: 'dataGrid.toggleLeftPanel',
|
||||
category: 'Data grid',
|
||||
name: 'Toggle left panel',
|
||||
category: __t('command.datagrid', { defaultMessage: 'Data grid' }),
|
||||
name: __t('command.datagrid.toggleLeftPanel', { defaultMessage: 'Toggle left panel' }),
|
||||
keyText: 'CtrlOrCommand+L',
|
||||
testEnabled: () => getCurrentEditor()?.canShowLeftPanel(),
|
||||
onClick: () => getCurrentEditor().toggleLeftPanel(),
|
||||
@@ -68,7 +68,7 @@
|
||||
import registerCommand from '../commands/registerCommand';
|
||||
import { registerMenu } from '../utility/contextMenu';
|
||||
import { getLocalStorage, setLocalStorage } from '../utility/storageCache';
|
||||
import { _t } from '../translations';
|
||||
import { __t, _t } from '../translations';
|
||||
|
||||
export let config;
|
||||
export let setConfig;
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
registerCommand({
|
||||
id: 'dataGrid.refresh',
|
||||
category: 'Data grid',
|
||||
name: _t('common.refresh', { defaultMessage: 'Refresh' }),
|
||||
category: __t('command.datagrid', { defaultMessage: 'Data grid' }),
|
||||
name: __t('common.refresh', { defaultMessage: 'Refresh' }),
|
||||
keyText: 'F5 | CtrlOrCommand+R',
|
||||
toolbar: true,
|
||||
isRelatedToTab: true,
|
||||
@@ -15,8 +15,8 @@
|
||||
|
||||
registerCommand({
|
||||
id: 'dataGrid.deepRefresh',
|
||||
category: 'Data grid',
|
||||
name: 'Refresh with structure',
|
||||
category: __t('command.datagrid', { defaultMessage: 'Data grid' }),
|
||||
name: __t('common.datagrid.deepRefresh', { defaultMessage: 'Refresh with structure' }),
|
||||
keyText: 'Ctrl+F5',
|
||||
toolbar: true,
|
||||
isRelatedToTab: true,
|
||||
@@ -27,8 +27,8 @@
|
||||
|
||||
registerCommand({
|
||||
id: 'dataGrid.revertRowChanges',
|
||||
category: 'Data grid',
|
||||
name: _t('command.datagrid.revertRowChanges', { defaultMessage: 'Revert row changes' }),
|
||||
category: __t('command.datagrid', { defaultMessage: 'Data grid' }),
|
||||
name: __t('command.datagrid.revertRowChanges', { defaultMessage: 'Revert row changes' }),
|
||||
keyText: 'CtrlOrCommand+U',
|
||||
testEnabled: () => getCurrentDataGrid()?.getGrider()?.containsChanges,
|
||||
onClick: () => getCurrentDataGrid().revertRowChanges(),
|
||||
@@ -36,9 +36,9 @@
|
||||
|
||||
registerCommand({
|
||||
id: 'dataGrid.revertAllChanges',
|
||||
category: 'Data grid',
|
||||
name: _t('command.datagrid.revertAllChanges', { defaultMessage: 'Revert all changes' }),
|
||||
toolbarName: _t('command.datagrid.revertAllChanges.toolbar', { defaultMessage: 'Revert all' }),
|
||||
category: __t('command.datagrid', { defaultMessage: 'Data grid' }),
|
||||
name: __t('command.datagrid.revertAllChanges', { defaultMessage: 'Revert all changes' }),
|
||||
toolbarName: __t('command.datagrid.revertAllChanges.toolbar', { defaultMessage: 'Revert all' }),
|
||||
icon: 'icon undo',
|
||||
testEnabled: () => getCurrentDataGrid()?.getGrider()?.containsChanges,
|
||||
onClick: () => getCurrentDataGrid().revertAllChanges(),
|
||||
@@ -46,9 +46,9 @@
|
||||
|
||||
registerCommand({
|
||||
id: 'dataGrid.deleteSelectedRows',
|
||||
category: 'Data grid',
|
||||
name: _t('command.datagrid.deleteSelectedRows', { defaultMessage: 'Delete selected rows' }),
|
||||
toolbarName: _t('command.datagrid.deleteSelectedRows.toolbar', { defaultMessage: 'Delete row(s)' }),
|
||||
category: __t('command.datagrid', { defaultMessage: 'Data grid' }),
|
||||
name: __t('command.datagrid.deleteSelectedRows', { defaultMessage: 'Delete selected rows' }),
|
||||
toolbarName: __t('command.datagrid.deleteSelectedRows.toolbar', { defaultMessage: 'Delete row(s)' }),
|
||||
keyText: isMac() ? 'Command+Backspace' : 'CtrlOrCommand+Delete',
|
||||
icon: 'icon minus',
|
||||
testEnabled: () => getCurrentDataGrid()?.getGrider()?.editable,
|
||||
@@ -57,9 +57,9 @@
|
||||
|
||||
registerCommand({
|
||||
id: 'dataGrid.insertNewRow',
|
||||
category: 'Data grid',
|
||||
name: _t('command.datagrid.insertNewRow', { defaultMessage: 'Insert new row' }),
|
||||
toolbarName: _t('command.datagrid.insertNewRow.toolbar', { defaultMessage: 'New row' }),
|
||||
category: __t('command.datagrid', { defaultMessage: 'Data grid' }),
|
||||
name: __t('command.datagrid.insertNewRow', { defaultMessage: 'Insert new row' }),
|
||||
toolbarName: __t('command.datagrid.insertNewRow.toolbar', { defaultMessage: 'New row' }),
|
||||
icon: 'icon add',
|
||||
keyText: isMac() ? 'Command+I' : 'Insert',
|
||||
testEnabled: () => getCurrentDataGrid()?.getGrider()?.editable,
|
||||
@@ -68,9 +68,9 @@
|
||||
|
||||
registerCommand({
|
||||
id: 'dataGrid.addNewColumn',
|
||||
category: 'Data grid',
|
||||
name: _t('command.datagrid.addNewColumn', { defaultMessage: 'Add new column' }),
|
||||
toolbarName: _t('command.datagrid.addNewColumn.toolbar', { defaultMessage: 'New column' }),
|
||||
category: __t('command.datagrid', { defaultMessage: 'Data grid' }),
|
||||
name: __t('command.datagrid.addNewColumn', { defaultMessage: 'Add new column' }),
|
||||
toolbarName: __t('command.datagrid.addNewColumn.toolbar', { defaultMessage: 'New column' }),
|
||||
icon: 'icon add-column',
|
||||
testEnabled: () => getCurrentDataGrid()?.addNewColumnEnabled(),
|
||||
onClick: () => getCurrentDataGrid().addNewColumn(),
|
||||
@@ -78,9 +78,9 @@
|
||||
|
||||
registerCommand({
|
||||
id: 'dataGrid.cloneRows',
|
||||
category: 'Data grid',
|
||||
name: _t('command.datagrid.cloneRows', { defaultMessage: 'Clone rows' }),
|
||||
toolbarName: _t('command.datagrid.cloneRows.toolbar', { defaultMessage: 'Clone row(s)' }),
|
||||
category: __t('command.datagrid', { defaultMessage: 'Data grid' }),
|
||||
name: __t('command.datagrid.cloneRows', { defaultMessage: 'Clone rows' }),
|
||||
toolbarName: __t('command.datagrid.cloneRows.toolbar', { defaultMessage: 'Clone row(s)' }),
|
||||
keyText: 'CtrlOrCommand+Shift+C',
|
||||
testEnabled: () => getCurrentDataGrid()?.getGrider()?.editable,
|
||||
onClick: () => getCurrentDataGrid().cloneRows(),
|
||||
@@ -88,8 +88,8 @@
|
||||
|
||||
registerCommand({
|
||||
id: 'dataGrid.setNull',
|
||||
category: 'Data grid',
|
||||
name: _t('command.datagrid.setNull', { defaultMessage: 'Set NULL' }),
|
||||
category: __t('command.datagrid', { defaultMessage: 'Data grid' }),
|
||||
name: __t('command.datagrid.setNull', { defaultMessage: 'Set NULL' }),
|
||||
keyText: 'CtrlOrCommand+0',
|
||||
testEnabled: () =>
|
||||
getCurrentDataGrid()?.getGrider()?.editable && !getCurrentDataGrid()?.getEditorTypes()?.supportFieldRemoval,
|
||||
@@ -98,8 +98,8 @@
|
||||
|
||||
registerCommand({
|
||||
id: 'dataGrid.removeField',
|
||||
category: 'Data grid',
|
||||
name: _t('command.datagrid.removeField', { defaultMessage: 'Remove field' }),
|
||||
category: __t('command.datagrid', { defaultMessage: 'Data grid' }),
|
||||
name: __t('command.datagrid.removeField', { defaultMessage: 'Remove field' }),
|
||||
keyText: 'CtrlOrCommand+0',
|
||||
testEnabled: () =>
|
||||
getCurrentDataGrid()?.getGrider()?.editable && getCurrentDataGrid()?.getEditorTypes()?.supportFieldRemoval,
|
||||
@@ -108,8 +108,8 @@
|
||||
|
||||
registerCommand({
|
||||
id: 'dataGrid.undo',
|
||||
category: 'Data grid',
|
||||
name: _t('command.datagrid.undo', { defaultMessage: 'Undo' }),
|
||||
category: __t('command.datagrid', { defaultMessage: 'Data grid' }),
|
||||
name: __t('command.datagrid.undo', { defaultMessage: 'Undo' }),
|
||||
group: 'undo',
|
||||
icon: 'icon undo',
|
||||
toolbar: true,
|
||||
@@ -120,8 +120,8 @@
|
||||
|
||||
registerCommand({
|
||||
id: 'dataGrid.redo',
|
||||
category: 'Data grid',
|
||||
name: _t('command.datagrid.redo', { defaultMessage: 'Redo' }),
|
||||
category: __t('command.datagrid', { defaultMessage: 'Data grid' }),
|
||||
name: __t('command.datagrid.redo', { defaultMessage: 'Redo' }),
|
||||
group: 'redo',
|
||||
icon: 'icon redo',
|
||||
toolbar: true,
|
||||
@@ -132,16 +132,16 @@
|
||||
|
||||
registerCommand({
|
||||
id: 'dataGrid.reconnect',
|
||||
category: 'Data grid',
|
||||
name: _t('command.datagrid.reconnect', { defaultMessage: 'Reconnect' }),
|
||||
category: __t('command.datagrid', { defaultMessage: 'Data grid' }),
|
||||
name: __t('command.datagrid.reconnect', { defaultMessage: 'Reconnect' }),
|
||||
testEnabled: () => getCurrentDataGrid() != null,
|
||||
onClick: () => getCurrentDataGrid().reconnect(),
|
||||
});
|
||||
|
||||
registerCommand({
|
||||
id: 'dataGrid.copyToClipboard',
|
||||
category: 'Data grid',
|
||||
name: _t('command.datagrid.copyToClipboard', { defaultMessage: 'Copy to clipboard' }),
|
||||
category: __t('command.datagrid', { defaultMessage: 'Data grid' }),
|
||||
name: __t('command.datagrid.copyToClipboard', { defaultMessage: 'Copy to clipboard' }),
|
||||
keyText: 'CtrlOrCommand+C',
|
||||
disableHandleKeyText: 'CtrlOrCommand+C',
|
||||
testEnabled: () => getCurrentDataGrid() != null,
|
||||
@@ -150,7 +150,7 @@
|
||||
|
||||
registerCommand({
|
||||
id: 'dataGrid.editJsonDocument',
|
||||
category: 'Data grid',
|
||||
category: __t('command.datagrid', { defaultMessage: 'Data grid' }),
|
||||
keyText: 'CtrlOrCommand+J',
|
||||
name: __t('command.datagrid.editJsonDocument', { defaultMessage: 'Edit row as JSON document' }),
|
||||
testEnabled: () => getCurrentDataGrid()?.editJsonEnabled(),
|
||||
@@ -159,48 +159,48 @@
|
||||
|
||||
registerCommand({
|
||||
id: 'dataGrid.openSelectionInMap',
|
||||
category: 'Data grid',
|
||||
name: _t('command.datagrid.openSelectionInMap', { defaultMessage: 'Open selection in map' }),
|
||||
category: __t('command.datagrid', { defaultMessage: 'Data grid' }),
|
||||
name: __t('command.datagrid.openSelectionInMap', { defaultMessage: 'Open selection in map' }),
|
||||
testEnabled: () => getCurrentDataGrid() != null,
|
||||
onClick: () => getCurrentDataGrid().openSelectionInMap(),
|
||||
});
|
||||
|
||||
registerCommand({
|
||||
id: 'dataGrid.viewJsonDocument',
|
||||
category: 'Data grid',
|
||||
name: _t('command.datagrid.viewJsonDocument', { defaultMessage: 'View row as JSON document' }),
|
||||
category: __t('command.datagrid', { defaultMessage: 'Data grid' }),
|
||||
name: __t('command.datagrid.viewJsonDocument', { defaultMessage: 'View row as JSON document' }),
|
||||
testEnabled: () => getCurrentDataGrid()?.viewJsonDocumentEnabled(),
|
||||
onClick: () => getCurrentDataGrid().viewJsonDocument(),
|
||||
});
|
||||
|
||||
registerCommand({
|
||||
id: 'dataGrid.viewJsonValue',
|
||||
category: 'Data grid',
|
||||
name: _t('command.datagrid.viewJsonValue', { defaultMessage: 'View cell as JSON document' }),
|
||||
category: __t('command.datagrid', { defaultMessage: 'Data grid' }),
|
||||
name: __t('command.datagrid.viewJsonValue', { defaultMessage: 'View cell as JSON document' }),
|
||||
testEnabled: () => getCurrentDataGrid()?.viewJsonValueEnabled(),
|
||||
onClick: () => getCurrentDataGrid().viewJsonValue(),
|
||||
});
|
||||
|
||||
registerCommand({
|
||||
id: 'dataGrid.openJsonArrayInSheet',
|
||||
category: 'Data grid',
|
||||
name: _t('command.datagrid.openJsonArrayInSheet', { defaultMessage: 'Open array as table' }),
|
||||
category: __t('command.datagrid', { defaultMessage: 'Data grid' }),
|
||||
name: __t('command.datagrid.openJsonArrayInSheet', { defaultMessage: 'Open array as table' }),
|
||||
testEnabled: () => getCurrentDataGrid()?.openJsonArrayInSheetEnabled(),
|
||||
onClick: () => getCurrentDataGrid().openJsonArrayInSheet(),
|
||||
});
|
||||
|
||||
registerCommand({
|
||||
id: 'dataGrid.saveCellToFile',
|
||||
category: 'Data grid',
|
||||
name: _t('command.datagrid.saveCellToFile', { defaultMessage: 'Save cell to file' }),
|
||||
category: __t('command.datagrid', { defaultMessage: 'Data grid' }),
|
||||
name: __t('command.datagrid.saveCellToFile', { defaultMessage: 'Save cell to file' }),
|
||||
testEnabled: () => getCurrentDataGrid()?.saveCellToFileEnabled(),
|
||||
onClick: () => getCurrentDataGrid().saveCellToFile(),
|
||||
});
|
||||
|
||||
registerCommand({
|
||||
id: 'dataGrid.loadCellFromFile',
|
||||
category: 'Data grid',
|
||||
name: _t('command.datagrid.loadCellFromFile', { defaultMessage: 'Load cell from file' }),
|
||||
category: __t('command.datagrid', { defaultMessage: 'Data grid' }),
|
||||
name: __t('command.datagrid.loadCellFromFile', { defaultMessage: 'Load cell from file' }),
|
||||
testEnabled: () => getCurrentDataGrid()?.loadCellFromFileEnabled(),
|
||||
onClick: () => getCurrentDataGrid().loadCellFromFile(),
|
||||
});
|
||||
@@ -216,62 +216,62 @@
|
||||
//
|
||||
registerCommand({
|
||||
id: 'dataGrid.filterSelected',
|
||||
category: 'Data grid',
|
||||
name: 'Filter selected value',
|
||||
category: __t('command.datagrid', { defaultMessage: 'Data grid' }),
|
||||
name: __t('command.datagrid.filterSelected', { defaultMessage : 'Filter selected value'}),
|
||||
keyText: 'CtrlOrCommand+Shift+F',
|
||||
testEnabled: () => getCurrentDataGrid()?.getDisplay().filterable,
|
||||
onClick: () => getCurrentDataGrid().filterSelectedValue(),
|
||||
});
|
||||
registerCommand({
|
||||
id: 'dataGrid.findColumn',
|
||||
category: 'Data grid',
|
||||
name: 'Find column',
|
||||
category: __t('command.datagrid', { defaultMessage: 'Data grid' }),
|
||||
name: __t('command.datagrid.findColumn', { defaultMessage: 'Find column'}),
|
||||
keyText: 'CtrlOrCommand+F',
|
||||
testEnabled: () => getCurrentDataGrid() != null,
|
||||
getSubCommands: () => getCurrentDataGrid().buildFindMenu(),
|
||||
});
|
||||
registerCommand({
|
||||
id: 'dataGrid.hideColumn',
|
||||
category: 'Data grid',
|
||||
name: 'Hide column',
|
||||
category: __t('command.datagrid', { defaultMessage: 'Data grid' }),
|
||||
name: __t('command.datgrid.hideColumn', { defaultMessage: 'Hide column' }),
|
||||
keyText: isMac() ? 'Alt+Command+F' : 'CtrlOrCommand+H',
|
||||
testEnabled: () => getCurrentDataGrid()?.canShowLeftPanel(),
|
||||
onClick: () => getCurrentDataGrid().hideColumn(),
|
||||
});
|
||||
registerCommand({
|
||||
id: 'dataGrid.clearFilter',
|
||||
category: 'Data grid',
|
||||
name: 'Clear filter',
|
||||
category: __t('command.datagrid', { defaultMessage: 'Data grid' }),
|
||||
name: __t('command.datagrid.clearFilter', { defaultMessage : 'Clear filter'}),
|
||||
keyText: 'CtrlOrCommand+Shift+E',
|
||||
testEnabled: () => getCurrentDataGrid()?.clearFilterEnabled(),
|
||||
onClick: () => getCurrentDataGrid().clearFilter(),
|
||||
});
|
||||
registerCommand({
|
||||
id: 'dataGrid.generateSqlFromData',
|
||||
category: 'Data grid',
|
||||
name: 'Generate SQL',
|
||||
category: __t('command.datagrid', { defaultMessage: 'Data grid' }),
|
||||
name: __t('command.datagrid.generateSql', { defaultMessage: 'Generate SQL'}),
|
||||
keyText: 'CtrlOrCommand+G',
|
||||
testEnabled: () => getCurrentDataGrid()?.generateSqlFromDataEnabled(),
|
||||
onClick: () => getCurrentDataGrid().generateSqlFromData(),
|
||||
});
|
||||
registerCommand({
|
||||
id: 'dataGrid.openFreeTable',
|
||||
category: 'Data grid',
|
||||
name: 'Edit selection as table',
|
||||
category: __t('command.datagrid', { defaultMessage: 'Data grid' }),
|
||||
name: __t('command.datagrid.editSelection', { defaultMessage: 'Edit selection as table'}),
|
||||
testEnabled: () => getCurrentDataGrid() != null,
|
||||
onClick: () => getCurrentDataGrid().openFreeTable(),
|
||||
});
|
||||
registerCommand({
|
||||
id: 'dataGrid.newJson',
|
||||
category: 'Data grid',
|
||||
name: 'Add JSON document',
|
||||
category: __t('command.datagrid', { defaultMessage: 'Data grid' }),
|
||||
name: __t('command.datagrid.addJsonDocument', { defaultMessage: 'Add JSON document'}),
|
||||
testEnabled: () => getCurrentDataGrid()?.addJsonDocumentEnabled(),
|
||||
onClick: () => getCurrentDataGrid().addJsonDocument(),
|
||||
});
|
||||
registerCommand({
|
||||
id: 'dataGrid.editCellValue',
|
||||
category: 'Data grid',
|
||||
name: 'Edit cell value',
|
||||
category: __t('command.datagrid', { defaultMessage: 'Data grid' }),
|
||||
name: __t('command.datagrid.editCell', { defaultMessage: 'Edit cell value' }),
|
||||
testEnabled: () => getCurrentDataGrid()?.editCellValueEnabled(),
|
||||
onClick: () => getCurrentDataGrid().editCellValue(),
|
||||
});
|
||||
@@ -279,8 +279,8 @@
|
||||
if (isProApp()) {
|
||||
registerCommand({
|
||||
id: 'dataGrid.sendToDataDeploy',
|
||||
category: 'Data grid',
|
||||
name: 'Send to data deployer',
|
||||
category: __t('command.datagrid', { defaultMessage: 'Data grid' }),
|
||||
name: __t('command.datagrid.sendToDataDeployer', { defaultMessage: 'Send to data deployer' }),
|
||||
testEnabled: () => getCurrentDataGrid()?.sendToDataDeployEnabled(),
|
||||
onClick: () => getCurrentDataGrid().sendToDataDeploy(),
|
||||
});
|
||||
@@ -1788,15 +1788,15 @@
|
||||
{ command: 'dataGrid.refresh' },
|
||||
{ placeTag: 'copy' },
|
||||
{
|
||||
text: 'Copy advanced',
|
||||
text: _t('datagrid.copyAdvanced', { defaultMessage: 'Copy advanced'}),
|
||||
submenu: [
|
||||
_.keys(copyRowsFormatDefs).map(format => ({
|
||||
text: copyRowsFormatDefs[format].label,
|
||||
text: _.isFunction(copyRowsFormatDefs[format].label) ? copyRowsFormatDefs[format].label() : copyRowsFormatDefs[format].label,
|
||||
onClick: () => copyToClipboardCore(format),
|
||||
})),
|
||||
{ divider: true },
|
||||
_.keys(copyRowsFormatDefs).map(format => ({
|
||||
text: `Set format: ${copyRowsFormatDefs[format].name}`,
|
||||
text: _t('datagrid.setFormat', { defaultMessage: 'Set format: ' }) + (_.isFunction(copyRowsFormatDefs[format].name) ? copyRowsFormatDefs[format].name() : copyRowsFormatDefs[format].name),
|
||||
onClick: () => ($copyRowsFormat = format),
|
||||
})),
|
||||
|
||||
@@ -1866,7 +1866,7 @@
|
||||
return [
|
||||
menu,
|
||||
{
|
||||
text: copyRowsFormatDefs[$copyRowsFormat].label,
|
||||
text: _.isFunction(copyRowsFormatDefs[$copyRowsFormat].label) ? copyRowsFormatDefs[$copyRowsFormat].label() : copyRowsFormatDefs[$copyRowsFormat].label,
|
||||
onClick: () => copyToClipboardCore($copyRowsFormat),
|
||||
keyText: 'CtrlOrCommand+C',
|
||||
tag: 'copy',
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
<script context="module" lang="ts">
|
||||
import { __t } from '../translations'
|
||||
const getCurrentEditor = () => getActiveComponent('SqlDataGridCore');
|
||||
|
||||
registerCommand({
|
||||
id: 'sqlDataGrid.openQuery',
|
||||
category: 'Data grid',
|
||||
name: 'Open query',
|
||||
category: __t('command.datagrid', { defaultMessage: 'Data grid' }),
|
||||
name: __t('command.openQuery', { defaultMessage : 'Open query' }),
|
||||
testEnabled: () => getCurrentEditor() != null && hasPermission('dbops/query'),
|
||||
onClick: () => getCurrentEditor().openQuery(),
|
||||
});
|
||||
|
||||
registerCommand({
|
||||
id: 'sqlDataGrid.export',
|
||||
category: 'Data grid',
|
||||
name: 'Export',
|
||||
category: __t('command.datagrid', { defaultMessage: 'Data grid' }),
|
||||
name: __t('common.export', { defaultMessage : 'Export' }),
|
||||
icon: 'icon export',
|
||||
keyText: 'CtrlOrCommand+E',
|
||||
testEnabled: () => getCurrentEditor() != null && hasPermission('dbops/export'),
|
||||
|
||||
@@ -368,7 +368,7 @@
|
||||
{/if}
|
||||
{/key}
|
||||
{:else}
|
||||
{row[col.fieldName] || ''}
|
||||
{ _.isFunction(row[col.fieldName]) ? row[col.fieldName]() : row[col.fieldName] || ''}
|
||||
{/if}
|
||||
</td>
|
||||
{/each}
|
||||
|
||||
@@ -1,39 +1,39 @@
|
||||
import { _t } from '../translations';
|
||||
import { __t } from '../translations';
|
||||
|
||||
const macros = [
|
||||
{
|
||||
title: _t('datagrid.macros.removeDiacritics', { defaultMessage: 'Remove diacritics' }),
|
||||
title: __t('datagrid.macros.removeDiacritics', { defaultMessage: 'Remove diacritics' }),
|
||||
name: 'removeDiacritics',
|
||||
group: 'Text',
|
||||
description: _t('datagrid.macros.removeDiacriticsDescription', { defaultMessage: 'Removes diacritics from selected cells' }),
|
||||
group: __t('datagrid.macros.textGroup', { defaultMessage: 'Text' }),
|
||||
description: __t('datagrid.macros.removeDiacriticsDescription', { defaultMessage: 'Removes diacritics from selected cells' }),
|
||||
type: 'transformValue',
|
||||
code: `return modules.lodash.deburr(value)`,
|
||||
},
|
||||
{
|
||||
title: _t('datagrid.macros.searchReplaceText', { defaultMessage: 'Search & replace text' }),
|
||||
title: __t('datagrid.macros.searchReplaceText', { defaultMessage: 'Search & replace text' }),
|
||||
name: 'stringReplace',
|
||||
group: 'Text',
|
||||
description: _t('datagrid.macros.searchReplaceTextDescription', { defaultMessage: 'Search & replace text or regular expression' }),
|
||||
group: __t('datagrid.macros.textGroup', { defaultMessage: 'Text' }),
|
||||
description: __t('datagrid.macros.searchReplaceTextDescription', { defaultMessage: 'Search & replace text or regular expression' }),
|
||||
type: 'transformValue',
|
||||
args: [
|
||||
{
|
||||
type: 'text',
|
||||
label: _t('datagrid.macros.searchReplaceTextFind', { defaultMessage: 'Find' }),
|
||||
label: __t('datagrid.macros.searchReplaceTextFind', { defaultMessage: 'Find' }),
|
||||
name: 'find',
|
||||
},
|
||||
{
|
||||
type: 'text',
|
||||
label: _t('datagrid.macros.searchReplaceTextReplaceWith', { defaultMessage: 'Replace with' }),
|
||||
label: __t('datagrid.macros.searchReplaceTextReplaceWith', { defaultMessage: 'Replace with' }),
|
||||
name: 'replace',
|
||||
},
|
||||
{
|
||||
type: 'checkbox',
|
||||
label: _t('datagrid.macros.searchReplaceTextCaseSensitive', { defaultMessage: 'Case sensitive' }),
|
||||
label: __t('datagrid.macros.searchReplaceTextCaseSensitive', { defaultMessage: 'Case sensitive' }),
|
||||
name: 'caseSensitive',
|
||||
},
|
||||
{
|
||||
type: 'checkbox',
|
||||
label: _t('datagrid.macros.searchReplaceTextIsRegex', { defaultMessage: 'Regular expression' }),
|
||||
label: __t('datagrid.macros.searchReplaceTextIsRegex', { defaultMessage: 'Regular expression' }),
|
||||
name: 'isRegex',
|
||||
},
|
||||
],
|
||||
@@ -44,16 +44,16 @@ return value ? value.toString().replace(new RegExp(rtext, rflags), args.replace
|
||||
`,
|
||||
},
|
||||
{
|
||||
title: _t('datagrid.macros.changeTextCase', { defaultMessage: 'Change text case' }),
|
||||
title: __t('datagrid.macros.changeTextCase', { defaultMessage: 'Change text case' }),
|
||||
name: 'changeTextCase',
|
||||
group: 'Text',
|
||||
description: _t('datagrid.macros.changeTextCaseDescription', { defaultMessage: 'Uppercase, lowercase and other case functions' }),
|
||||
group: __t('datagrid.macros.textGroup', { defaultMessage: 'Text' }),
|
||||
description: __t('datagrid.macros.changeTextCaseDescription', { defaultMessage: 'Uppercase, lowercase and other case functions' }),
|
||||
type: 'transformValue',
|
||||
args: [
|
||||
{
|
||||
type: 'select',
|
||||
options: ['toUpper', 'toLower', 'lowerCase', 'upperCase', 'kebabCase', 'snakeCase', 'camelCase', 'startCase'],
|
||||
label: _t('datagrid.macros.changeTextCaseType', { defaultMessage: 'Type' }),
|
||||
label: __t('datagrid.macros.changeTextCaseType', { defaultMessage: 'Type' }),
|
||||
name: 'type',
|
||||
default: 'toUpper',
|
||||
},
|
||||
@@ -61,81 +61,81 @@ return value ? value.toString().replace(new RegExp(rtext, rflags), args.replace
|
||||
code: `return modules.lodash[args.type](value)`,
|
||||
},
|
||||
{
|
||||
title: _t('datagrid.macros.padLeft', { defaultMessage: 'Pad left' }),
|
||||
title: __t('datagrid.macros.padLeft', { defaultMessage: 'Pad left' }),
|
||||
name: 'padLeft',
|
||||
group: 'Text',
|
||||
group: __t('datagrid.macros.textGroup', { defaultMessage: 'Text' }),
|
||||
args: [
|
||||
{
|
||||
type: 'text',
|
||||
label: _t('datagrid.macros.padCharacter', { defaultMessage: 'Character' }),
|
||||
label: __t('datagrid.macros.padCharacter', { defaultMessage: 'Character' }),
|
||||
name: 'character',
|
||||
default: '0',
|
||||
},
|
||||
{
|
||||
type: 'text',
|
||||
label: _t('datagrid.macros.padLength', { defaultMessage: 'Length' }),
|
||||
label: __t('datagrid.macros.padLength', { defaultMessage: 'Length' }),
|
||||
name: 'length',
|
||||
default: '3',
|
||||
},
|
||||
],
|
||||
description:
|
||||
_t('datagrid.macros.padLeftDescription', { defaultMessage: 'Returns string of a specified length in which the beginning of the current string is padded with spaces or other character' }),
|
||||
__t('datagrid.macros.padLeftDescription', { defaultMessage: 'Returns string of a specified length in which the beginning of the current string is padded with spaces or other character' }),
|
||||
type: 'transformValue',
|
||||
code: `return modules.lodash.padStart(value, +args.length, args.character)`,
|
||||
},
|
||||
{
|
||||
title: _t('datagrid.macros.padRight', { defaultMessage: 'Pad right' }),
|
||||
title: __t('datagrid.macros.padRight', { defaultMessage: 'Pad right' }),
|
||||
name: 'padRight',
|
||||
group: 'Text',
|
||||
group: __t('datagrid.macros.textGroup', { defaultMessage: 'Text' }),
|
||||
args: [
|
||||
{
|
||||
type: 'text',
|
||||
label: _t('datagrid.macros.padCharacter', { defaultMessage: 'Character' }),
|
||||
label: __t('datagrid.macros.padCharacter', { defaultMessage: 'Character' }),
|
||||
name: 'character',
|
||||
default: '0',
|
||||
},
|
||||
{
|
||||
type: 'text',
|
||||
label: _t('datagrid.macros.padLength', { defaultMessage: 'Length' }),
|
||||
label: __t('datagrid.macros.padLength', { defaultMessage: 'Length' }),
|
||||
name: 'length',
|
||||
default: '3',
|
||||
},
|
||||
],
|
||||
description:
|
||||
_t('datagrid.macros.padRightDescription', { defaultMessage: 'Returns string of a specified length in which the end of the current string is padded with spaces or other character' }),
|
||||
__t('datagrid.macros.padRightDescription', { defaultMessage: 'Returns string of a specified length in which the end of the current string is padded with spaces or other character' }),
|
||||
type: 'transformValue',
|
||||
code: `return modules.lodash.padEnd(value, +args.length, args.character)`,
|
||||
},
|
||||
{
|
||||
title: _t('datagrid.macros.trim', { defaultMessage: 'Trim' }),
|
||||
title: __t('datagrid.macros.trim', { defaultMessage: 'Trim' }),
|
||||
name: 'trim',
|
||||
group: 'Text',
|
||||
description: _t('datagrid.macros.trimDescription', { defaultMessage: 'Removes leading and trailing whitespace' }),
|
||||
group: __t('datagrid.macros.textGroup', { defaultMessage: 'Text' }),
|
||||
description: __t('datagrid.macros.trimDescription', { defaultMessage: 'Removes leading and trailing whitespace' }),
|
||||
type: 'transformValue',
|
||||
code: `return modules.lodash.trim(value)`,
|
||||
},
|
||||
{
|
||||
title: _t('datagrid.macros.rowIndex', { defaultMessage: 'Row index' }),
|
||||
title: __t('datagrid.macros.rowIndex', { defaultMessage: 'Row index' }),
|
||||
name: 'rowIndex',
|
||||
group: 'Tools',
|
||||
description: _t('datagrid.macros.rowIndexDescription', { defaultMessage: 'Index of row from 1 (autoincrement)' }),
|
||||
group: __t('datagrid.macros.toolsGroup', { defaultMessage: 'Tools' }),
|
||||
description: __t('datagrid.macros.rowIndexDescription', { defaultMessage: 'Index of row from 1 (autoincrement)' }),
|
||||
type: 'transformValue',
|
||||
code: `return rowIndex + 1`,
|
||||
},
|
||||
{
|
||||
title: _t('datagrid.macros.generateUUID', { defaultMessage: 'Generate UUID' }),
|
||||
title: __t('datagrid.macros.generateUUID', { defaultMessage: 'Generate UUID' }),
|
||||
name: 'uuidv1',
|
||||
group: 'Tools',
|
||||
description: _t('datagrid.macros.generateUUIDDescription', { defaultMessage: 'Generate unique identifier' }),
|
||||
group: __t('datagrid.macros.toolsGroup', { defaultMessage: 'Tools' }),
|
||||
description: __t('datagrid.macros.generateUUIDDescription', { defaultMessage: 'Generate unique identifier' }),
|
||||
type: 'transformValue',
|
||||
args: [
|
||||
{
|
||||
type: 'select',
|
||||
options: [
|
||||
{ value: 'uuidv1', name: _t('datagrid.macros.uuidv1', { defaultMessage: 'V1 - from timestamp' }) },
|
||||
{ value: 'uuidv4', name: _t('datagrid.macros.uuidv4', { defaultMessage: 'V4 - random generated' }) },
|
||||
{ value: 'uuidv1', name: 'V1 - from timestamp' },
|
||||
{ value: 'uuidv4', name: 'V4 - random generated'},
|
||||
],
|
||||
label: _t('datagrid.macros.version', { defaultMessage: 'Version' }),
|
||||
label: __t('datagrid.macros.version', { defaultMessage: 'Version' }),
|
||||
name: 'version',
|
||||
default: 'uuidv1',
|
||||
},
|
||||
@@ -143,26 +143,26 @@ return value ? value.toString().replace(new RegExp(rtext, rflags), args.replace
|
||||
code: `return modules[args.version]()`,
|
||||
},
|
||||
{
|
||||
title: _t('datagrid.macros.toInt', { defaultMessage: 'Convert to integer' }),
|
||||
title: __t('datagrid.macros.toInt', { defaultMessage: 'Convert to integer' }),
|
||||
name: 'toInt',
|
||||
group: 'Tools',
|
||||
description: _t('datagrid.macros.toIntDescription', { defaultMessage: 'Converts to integral number' }),
|
||||
group: __t('datagrid.macros.toolsGroup', { defaultMessage: 'Tools' }),
|
||||
description: __t('datagrid.macros.toIntDescription', { defaultMessage: 'Converts to integral number' }),
|
||||
type: 'transformValue',
|
||||
code: `return modules.lodash.isNaN(parseInt(value)) ? null : parseInt(value)`,
|
||||
},
|
||||
{
|
||||
title: _t('datagrid.macros.toNumber', { defaultMessage: 'Convert to number' }),
|
||||
title: __t('datagrid.macros.toNumber', { defaultMessage: 'Convert to number' }),
|
||||
name: 'toNumber',
|
||||
group: 'Tools',
|
||||
description: _t('datagrid.macros.toNumberDescription', { defaultMessage: 'Converts to number' }),
|
||||
group: __t('datagrid.macros.toolsGroup', { defaultMessage: 'Tools' }),
|
||||
description: __t('datagrid.macros.toNumberDescription', { defaultMessage: 'Converts to number' }),
|
||||
type: 'transformValue',
|
||||
code: `return modules.lodash.isNaN(parseFloat(value)) ? null : parseFloat(value)`,
|
||||
},
|
||||
{
|
||||
title: _t('datagrid.macros.toBoolean', { defaultMessage: 'Convert to boolean' }),
|
||||
title: __t('datagrid.macros.toBoolean', { defaultMessage: 'Convert to boolean' }),
|
||||
name: 'toBoolean',
|
||||
group: 'Tools',
|
||||
description: _t('datagrid.macros.toBooleanDescription', { defaultMessage: 'Converts to boolean' }),
|
||||
group: __t('datagrid.macros.toolsGroup', { defaultMessage: 'Tools' }),
|
||||
description: __t('datagrid.macros.toBooleanDescription', { defaultMessage: 'Converts to boolean' }),
|
||||
type: 'transformValue',
|
||||
code: `
|
||||
if (modules.lodash.isString(value)) {
|
||||
@@ -178,10 +178,10 @@ return !!value;
|
||||
`,
|
||||
},
|
||||
{
|
||||
title: _t('datagrid.macros.toString', { defaultMessage: 'Convert to string' }),
|
||||
title: __t('datagrid.macros.toString', { defaultMessage: 'Convert to string' }),
|
||||
name: 'toString',
|
||||
group: 'Tools',
|
||||
description: _t('datagrid.macros.toStringDescription', { defaultMessage: 'Converts to string' }),
|
||||
group: __t('datagrid.macros.toolsGroup', { defaultMessage: 'Tools' }),
|
||||
description: __t('datagrid.macros.toStringDescription', { defaultMessage: 'Converts to string' }),
|
||||
type: 'transformValue',
|
||||
code: `
|
||||
if (value==null) return null;
|
||||
@@ -190,15 +190,15 @@ return !!value;
|
||||
`,
|
||||
},
|
||||
{
|
||||
title: _t('datagrid.macros.currentDate', { defaultMessage: 'Current date' }),
|
||||
title: __t('datagrid.macros.currentDate', { defaultMessage: 'Current date' }),
|
||||
name: 'currentDate',
|
||||
group: 'Tools',
|
||||
description: _t('datagrid.macros.currentDateDescription', { defaultMessage: 'Gets current date' }),
|
||||
group: __t('datagrid.macros.toolsGroup', { defaultMessage: 'Tools' }),
|
||||
description: __t('datagrid.macros.currentDateDescription', { defaultMessage: 'Gets current date' }),
|
||||
type: 'transformValue',
|
||||
args: [
|
||||
{
|
||||
type: 'text',
|
||||
label: _t('datagrid.macros.format', { defaultMessage: 'Format' }),
|
||||
label: __t('datagrid.macros.format', { defaultMessage: 'Format' }),
|
||||
name: 'format',
|
||||
default: 'YYYY-MM-DD HH:mm:ss',
|
||||
},
|
||||
@@ -206,10 +206,10 @@ return !!value;
|
||||
code: `return modules.moment().format(args.format)`,
|
||||
},
|
||||
{
|
||||
title: _t('datagrid.macros.duplicateColumns', { defaultMessage: 'Duplicate columns' }),
|
||||
title: __t('datagrid.macros.duplicateColumns', { defaultMessage: 'Duplicate columns' }),
|
||||
name: 'duplicateColumns',
|
||||
group: 'Tools',
|
||||
description: _t('datagrid.macros.duplicateColumnsDescription', { defaultMessage: 'Duplicate selected columns' }),
|
||||
group: __t('datagrid.macros.toolsGroup', { defaultMessage: 'Tools' }),
|
||||
description: __t('datagrid.macros.duplicateColumnsDescription', { defaultMessage: 'Duplicate selected columns' }),
|
||||
type: 'transformRow',
|
||||
code: `
|
||||
return {
|
||||
@@ -220,22 +220,22 @@ return !!value;
|
||||
args: [
|
||||
{
|
||||
type: 'text',
|
||||
label: _t('datagrid.macros.prefix', { defaultMessage: 'Prefix' }),
|
||||
label: __t('datagrid.macros.prefix', { defaultMessage: 'Prefix' }),
|
||||
name: 'prefix',
|
||||
},
|
||||
{
|
||||
type: 'text',
|
||||
label: _t('datagrid.macros.postfix', { defaultMessage: 'Postfix' }),
|
||||
label: __t('datagrid.macros.postfix', { defaultMessage: 'Postfix' }),
|
||||
name: 'postfix',
|
||||
default: '_copy',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
title: _t('datagrid.macros.splitColumns', { defaultMessage: 'Split columns' }),
|
||||
title: __t('datagrid.macros.splitColumns', { defaultMessage: 'Split columns' }),
|
||||
name: 'splitColumns',
|
||||
group: 'Tools',
|
||||
description: _t('datagrid.macros.splitColumnsDescription', { defaultMessage: 'Split selected columns' }),
|
||||
group: __t('datagrid.macros.toolsGroup', { defaultMessage: 'Tools' }),
|
||||
description: __t('datagrid.macros.splitColumnsDescription', { defaultMessage: 'Split selected columns' }),
|
||||
type: 'transformRow',
|
||||
code: `
|
||||
const res = {...row};
|
||||
@@ -254,22 +254,22 @@ return !!value;
|
||||
args: [
|
||||
{
|
||||
type: 'text',
|
||||
label: _t('datagrid.macros.delimiter', { defaultMessage: 'Delimiter' }),
|
||||
label: __t('datagrid.macros.delimiter', { defaultMessage: 'Delimiter' }),
|
||||
name: 'delimiter',
|
||||
default: ',',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
title: _t('datagrid.macros.calculation', { defaultMessage: 'Calculation' }),
|
||||
title: __t('datagrid.macros.calculation', { defaultMessage: 'Calculation' }),
|
||||
name: 'calculation',
|
||||
group: 'Tools',
|
||||
description: _t('datagrid.macros.calculationDescription', { defaultMessage: 'Custom expression. Use row.column_name for accessing column values, value for original value' }),
|
||||
group: __t('datagrid.macros.toolsGroup', { defaultMessage: 'Tools' }),
|
||||
description: __t('datagrid.macros.calculationDescription', { defaultMessage: 'Custom expression. Use row.column_name for accessing column values, value for original value' }),
|
||||
type: 'transformValue',
|
||||
args: [
|
||||
{
|
||||
type: 'text',
|
||||
label: _t('datagrid.macros.expression', { defaultMessage: 'Expression' }),
|
||||
label: __t('datagrid.macros.expression', { defaultMessage: 'Expression' }),
|
||||
name: 'expression',
|
||||
default: 'value',
|
||||
},
|
||||
@@ -277,10 +277,10 @@ return !!value;
|
||||
code: `return eval(args.expression);`,
|
||||
},
|
||||
{
|
||||
title: _t('datagrid.macros.extractDateFields', { defaultMessage: 'Extract date fields' }),
|
||||
title: __t('datagrid.macros.extractDateFields', { defaultMessage: 'Extract date fields' }),
|
||||
name: 'extractDateFields',
|
||||
group: 'Tools',
|
||||
description: _t('datagrid.macros.extractDateFieldsDescription', { defaultMessage: 'Extract year, month, day and other date/time fields from selection and adds it as new columns' }),
|
||||
group: __t('datagrid.macros.toolsGroup', { defaultMessage: 'Tools' }),
|
||||
description: __t('datagrid.macros.extractDateFieldsDescription', { defaultMessage: 'Extract year, month, day and other date/time fields from selection and adds it as new columns' }),
|
||||
type: 'transformRow',
|
||||
code: `
|
||||
let mom = null;
|
||||
@@ -313,37 +313,37 @@ return !!value;
|
||||
args: [
|
||||
{
|
||||
type: 'text',
|
||||
label: _t('datagrid.macros.yearName', { defaultMessage: 'Year name' }),
|
||||
label: __t('datagrid.macros.yearName', { defaultMessage: 'Year name' }),
|
||||
name: 'year',
|
||||
default: 'year',
|
||||
},
|
||||
{
|
||||
type: 'text',
|
||||
label: _t('datagrid.macros.monthName', { defaultMessage: 'Month name' }) ,
|
||||
label: __t('datagrid.macros.monthName', { defaultMessage: 'Month name' }) ,
|
||||
name: 'month',
|
||||
default: 'month',
|
||||
},
|
||||
{
|
||||
type: 'text',
|
||||
label: _t('datagrid.macros.dayName', { defaultMessage: 'Day name' }),
|
||||
label: __t('datagrid.macros.dayName', { defaultMessage: 'Day name' }),
|
||||
name: 'day',
|
||||
default: 'day',
|
||||
},
|
||||
{
|
||||
type: 'text',
|
||||
label: _t('datagrid.macros.hourName', { defaultMessage: 'Hour name' }),
|
||||
label: __t('datagrid.macros.hourName', { defaultMessage: 'Hour name' }),
|
||||
name: 'hour',
|
||||
default: 'hour',
|
||||
},
|
||||
{
|
||||
type: 'text',
|
||||
label: _t('datagrid.macros.minuteName', { defaultMessage: 'Minute name' }),
|
||||
label: __t('datagrid.macros.minuteName', { defaultMessage: 'Minute name' }),
|
||||
name: 'minute',
|
||||
default: 'minute',
|
||||
},
|
||||
{
|
||||
type: 'text',
|
||||
label: _t('datagrid.macros.secondName', { defaultMessage: 'Second name' }),
|
||||
label: __t('datagrid.macros.secondName', { defaultMessage: 'Second name' }),
|
||||
name: 'second',
|
||||
default: 'second',
|
||||
},
|
||||
|
||||
@@ -1,12 +1,35 @@
|
||||
<script lang="ts" context="module">
|
||||
const getCurrentEditor = () => getActiveComponent('TableDataTab');
|
||||
const INTERVALS = [5, 10, 15, 13, 60];
|
||||
const INTERVALS = [5, 10, 15, 30, 60];
|
||||
|
||||
const INTERVAL_COMMANDS = [
|
||||
{
|
||||
time: 5,
|
||||
name: __t('command.datagrid.setAutoRefresh.5', { defaultMessage: 'Refresh every 5 seconds' }),
|
||||
},
|
||||
{
|
||||
time: 10,
|
||||
name: __t('command.datagrid.setAutoRefresh.10', { defaultMessage: 'Refresh every 10 seconds' }),
|
||||
},
|
||||
{
|
||||
time: 15,
|
||||
name: __t('command.datagrid.setAutoRefresh.15', { defaultMessage: 'Refresh every 15 seconds' }),
|
||||
},
|
||||
{
|
||||
time: 30,
|
||||
name: __t('command.datagrid.setAutoRefresh.30', { defaultMessage: 'Refresh every 30 seconds' }),
|
||||
},
|
||||
{
|
||||
time: 60,
|
||||
name: __t('command.datagrid.setAutoRefresh.60', { defaultMessage: 'Refresh every 60 seconds' }),
|
||||
},
|
||||
]
|
||||
|
||||
registerCommand({
|
||||
id: 'tableData.save',
|
||||
group: 'save',
|
||||
category: 'Table data',
|
||||
name: 'Save',
|
||||
category: __t('command.tableData', { defaultMessage: 'Table data' }),
|
||||
name: __t('command.tableData.save', { defaultMessage: 'Save' }),
|
||||
// keyText: 'CtrlOrCommand+S',
|
||||
toolbar: true,
|
||||
isRelatedToTab: true,
|
||||
@@ -17,28 +40,28 @@
|
||||
|
||||
registerCommand({
|
||||
id: 'tableData.setAutoRefresh.1',
|
||||
category: 'Data grid',
|
||||
name: 'Refresh every 1 second',
|
||||
category: __t('command.datagrid', { defaultMessage: 'Data grid' }),
|
||||
name: __t('command.datagrid.setAutoRefresh.1', { defaultMessage: 'Refresh every 1 second' }),
|
||||
isRelatedToTab: true,
|
||||
testEnabled: () => !!getCurrentEditor(),
|
||||
onClick: () => getCurrentEditor().setAutoRefresh(1),
|
||||
});
|
||||
|
||||
for (const seconds of INTERVALS) {
|
||||
for (const { time, name } of INTERVAL_COMMANDS) {
|
||||
registerCommand({
|
||||
id: `tableData.setAutoRefresh.${seconds}`,
|
||||
category: 'Data grid',
|
||||
name: `Refresh every ${seconds} seconds`,
|
||||
id: `tableData.setAutoRefresh.${time}`,
|
||||
category: __t('command.datagrid', { defaultMessage: 'Data grid' }),
|
||||
name,
|
||||
isRelatedToTab: true,
|
||||
testEnabled: () => !!getCurrentEditor(),
|
||||
onClick: () => getCurrentEditor().setAutoRefresh(seconds),
|
||||
onClick: () => getCurrentEditor().setAutoRefresh(time),
|
||||
});
|
||||
}
|
||||
|
||||
registerCommand({
|
||||
id: 'tableData.stopAutoRefresh',
|
||||
category: 'Data grid',
|
||||
name: 'Stop auto refresh',
|
||||
category: __t('command.datagrid', { defaultMessage: 'Data grid' }),
|
||||
name: __t('command.datagrid.stopAutoRefresh', { defaultMessage: 'Stop auto refresh' }),
|
||||
isRelatedToTab: true,
|
||||
keyText: 'CtrlOrCommand+Shift+R',
|
||||
testEnabled: () => getCurrentEditor()?.isAutoRefresh() === true,
|
||||
@@ -47,8 +70,8 @@
|
||||
|
||||
registerCommand({
|
||||
id: 'tableData.startAutoRefresh',
|
||||
category: 'Data grid',
|
||||
name: 'Start auto refresh',
|
||||
category: __t('command.datagrid', { defaultMessage: 'Data grid' }),
|
||||
name: __t('command.datagrid.startAutoRefresh', { defaultMessage: 'Start auto refresh' }),
|
||||
isRelatedToTab: true,
|
||||
keyText: 'CtrlOrCommand+Shift+R',
|
||||
testEnabled: () => getCurrentEditor()?.isAutoRefresh() === false,
|
||||
@@ -101,6 +124,7 @@
|
||||
import { markTabSaved, markTabUnsaved } from '../utility/common';
|
||||
import ToolStripButton from '../buttons/ToolStripButton.svelte';
|
||||
import { getNumberIcon } from '../icons/FontIcon.svelte';
|
||||
import { __t, _t } from '../translations';
|
||||
|
||||
export let tabid;
|
||||
export let conid;
|
||||
@@ -260,7 +284,7 @@
|
||||
{ command: 'tableData.stopAutoRefresh', hideDisabled: true },
|
||||
{ command: 'tableData.startAutoRefresh', hideDisabled: true },
|
||||
'tableData.setAutoRefresh.1',
|
||||
...INTERVALS.map(seconds => ({ command: `tableData.setAutoRefresh.${seconds}`, text: `...${seconds} seconds` })),
|
||||
...INTERVALS.map(seconds => ({ command: `tableData.setAutoRefresh.${seconds}`, text: `...${seconds}` + ' ' + _t('command.datagrid.autoRefresh.seconds', { defaultMessage: 'seconds' }) })),
|
||||
];
|
||||
}
|
||||
</script>
|
||||
@@ -304,7 +328,7 @@
|
||||
defaultActionId: 'openStructure',
|
||||
},
|
||||
});
|
||||
}}>Structure</ToolStripButton
|
||||
}}>{_t('datagrid.structure', { defaultMessage: 'Structure' })}</ToolStripButton
|
||||
>
|
||||
|
||||
<ToolStripButton
|
||||
@@ -378,7 +402,7 @@
|
||||
|
||||
<ToolStripButton
|
||||
icon={$collapsedLeftColumnStore ? 'icon columns-outline' : 'icon columns'}
|
||||
on:click={() => collapsedLeftColumnStore.update(x => !x)}>View columns</ToolStripButton
|
||||
on:click={() => collapsedLeftColumnStore.update(x => !x)}>{_t('tableData.viewColumns', { defaultMessage: 'View columns' })}</ToolStripButton
|
||||
>
|
||||
</svelte:fragment>
|
||||
</ToolStripContainer>
|
||||
|
||||
@@ -2,6 +2,7 @@ import _ from 'lodash';
|
||||
import { arrayToHexString, stringifyCellValue } from 'dbgate-tools';
|
||||
import yaml from 'js-yaml';
|
||||
import { DataEditorTypesBehaviour } from 'dbgate-types';
|
||||
import { __t, _t } from '../translations'
|
||||
|
||||
export function copyTextToClipboard(text) {
|
||||
const oldFocus = document.activeElement;
|
||||
@@ -157,53 +158,53 @@ export function copyRowsToClipboard(format, columns, rows, options) {
|
||||
|
||||
export const copyRowsFormatDefs = {
|
||||
textWithHeaders: {
|
||||
label: 'Copy with headers',
|
||||
name: 'With headers',
|
||||
label: __t('clipboard.copyWithHeaders', { defaultMessage : 'Copy with headers' }),
|
||||
name: __t('clipboard.withHeaders', { defaultMessage: 'With headers' }),
|
||||
formatter: clipboardTextFormatter('\t', true),
|
||||
},
|
||||
textWithoutHeaders: {
|
||||
label: 'Copy without headers',
|
||||
name: 'Without headers',
|
||||
label: __t('clipboard.copyWithoutHeaders', { defaultMessage : 'Copy without headers' }),
|
||||
name: __t('clipboard.withoutHeaders', { defaultMessage: 'Without headers' }),
|
||||
formatter: clipboardTextFormatter('\t', false),
|
||||
},
|
||||
headers: {
|
||||
label: 'Copy only headers',
|
||||
name: 'Only Headers',
|
||||
label: __t('clipboard.copyOnlyHeadres', { defaultMessage : 'Copy only headers'}),
|
||||
name: __t('clipboard.onlyHeaders', { defaultMessage : 'Only Headers' }),
|
||||
formatter: clipboardHeadersFormatter('\t'),
|
||||
},
|
||||
csv: {
|
||||
label: 'Copy as CSV',
|
||||
label: __t('clipboard.copyCSV', { defaultMessage : 'Copy as CSV'}),
|
||||
name: 'CSV',
|
||||
formatter: clipboardTextFormatter(',', true),
|
||||
},
|
||||
json: {
|
||||
label: 'Copy as JSON',
|
||||
label: __t('clipboard.copyJSON', { defaultMessage: 'Copy as JSON'}),
|
||||
name: 'JSON',
|
||||
formatter: clipboardJsonFormatter(),
|
||||
},
|
||||
jsonLines: {
|
||||
label: 'Copy as JSON lines/NDJSON',
|
||||
label: __t('clipboard.copyJSONLines', { defaultMessage : 'Copy as JSON lines/NDJSON' }),
|
||||
name: 'JSON lines/NDJSON',
|
||||
formatter: clipboardJsonLinesFormatter(),
|
||||
},
|
||||
yaml: {
|
||||
label: 'Copy as YAML',
|
||||
label: __t('clipboard.copyYAML', { defaultMessage : 'Copy as YAML'}),
|
||||
name: 'YAML',
|
||||
formatter: clipboardYamlFormatter(),
|
||||
},
|
||||
inserts: {
|
||||
label: 'Copy as SQL INSERTs',
|
||||
name: 'SQL INSERTs',
|
||||
label: __t('clipboard.copySQLInsert', { defaultMessage : 'Copy as SQL INSERTs'}),
|
||||
name: __t('clipboard.SQLInsert', { defaultMessage : 'SQL INSERTs' }),
|
||||
formatter: clipboardInsertsFormatter(),
|
||||
},
|
||||
updates: {
|
||||
label: 'Copy as SQL UPDATEs',
|
||||
name: 'SQL UPDATEs',
|
||||
label: __t('clipboard.copySQLUpdate', { defaultMessage : 'Copy as SQL UPDATEs'}),
|
||||
name: __t('clipboard.SQLUpdate', { defaultMessage : 'SQL UPDATEs' }),
|
||||
formatter: clipboardUpdatesFormatter(),
|
||||
},
|
||||
mongoInsert: {
|
||||
label: 'Copy as Mongo INSERTs',
|
||||
name: 'Mongo INSERTs',
|
||||
label: __t('clipboard.copyMongoInsert', { defaultMessage : 'Copy as Mongo INSERTs' }),
|
||||
name: __t('clipboard.mongoInsert', { defaultMessage : 'Mongo INSERTs' }),
|
||||
formatter: clipboardMongoInsertFormatter(),
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import type { QuickExportDefinition } from 'dbgate-types';
|
||||
import { currentArchive, getCurrentArchive, getExtensions } from '../stores';
|
||||
import hasPermission from './hasPermission';
|
||||
import { _t } from '../translations'
|
||||
|
||||
export function createQuickExportMenuItems(handler: (fmt: QuickExportDefinition) => Function, advancedExportMenuItem) {
|
||||
const extensions = getExtensions();
|
||||
return [
|
||||
{
|
||||
text: 'Export advanced...',
|
||||
text: _t('export.exportAdvanced', { defaultMessage : 'Export advanced...'}),
|
||||
...advancedExportMenuItem,
|
||||
},
|
||||
{ divider: true },
|
||||
@@ -16,10 +17,10 @@ export function createQuickExportMenuItems(handler: (fmt: QuickExportDefinition)
|
||||
})),
|
||||
{ divider: true },
|
||||
{
|
||||
text: 'Current archive',
|
||||
text: _t('export.currentArchive', { defaultMessage : 'Current archive'}),
|
||||
onClick: handler({
|
||||
extension: 'jsonl',
|
||||
label: 'Current archive',
|
||||
label: _t('export.currentArchive', { defaultMessage : 'Current archive'}),
|
||||
noFilenameDependency: true,
|
||||
createWriter: (fileName, dataName) => ({
|
||||
functionName: 'archiveWriter',
|
||||
|
||||
@@ -233,7 +233,7 @@
|
||||
{/if}
|
||||
<InlineButton
|
||||
on:click={handleRefreshDatabase}
|
||||
title="Refresh database connection and object list"
|
||||
title={_t('sqlObjectList.refreshDatabase', { defaultMessage: "Refresh database connection and object list" })}
|
||||
square
|
||||
data-testid="SqlObjectList_refreshButton"
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user