mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-05-02 06:43:59 +00:00
This commit is contained in:
@@ -107,6 +107,14 @@
|
|||||||
onClick: () => getCurrentDataGrid().editJsonDocument(),
|
onClick: () => getCurrentDataGrid().editJsonDocument(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
registerCommand({
|
||||||
|
id: 'dataGrid.copyJsonDocument',
|
||||||
|
category: 'Data grid',
|
||||||
|
name: 'Copy JSON document',
|
||||||
|
testEnabled: () => getCurrentDataGrid()?.copyJsonEnabled(),
|
||||||
|
onClick: () => getCurrentDataGrid().copyJsonDocument(),
|
||||||
|
});
|
||||||
|
|
||||||
registerCommand({
|
registerCommand({
|
||||||
id: 'dataGrid.filterSelected',
|
id: 'dataGrid.filterSelected',
|
||||||
category: 'Data grid',
|
category: 'Data grid',
|
||||||
@@ -432,11 +440,21 @@
|
|||||||
return grider.editable && isDynamicStructure && _.uniq(selectedCells.map(x => x[0])).length == 1;
|
return grider.editable && isDynamicStructure && _.uniq(selectedCells.map(x => x[0])).length == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function copyJsonEnabled() {
|
||||||
|
return isDynamicStructure && _.uniq(selectedCells.map(x => x[0])).length == 1;
|
||||||
|
}
|
||||||
|
|
||||||
export function editJsonDocument() {
|
export function editJsonDocument() {
|
||||||
const rowIndex = selectedCells[0][0];
|
const rowIndex = selectedCells[0][0];
|
||||||
editJsonRowDocument(grider, rowIndex);
|
editJsonRowDocument(grider, rowIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function copyJsonDocument() {
|
||||||
|
const rowIndex = selectedCells[0][0];
|
||||||
|
const rowData = grider.getRowData(rowIndex);
|
||||||
|
copyTextToClipboard(JSON.stringify(rowData, undefined, 2));
|
||||||
|
}
|
||||||
|
|
||||||
export function buildFindMenu() {
|
export function buildFindMenu() {
|
||||||
const res = [];
|
const res = [];
|
||||||
|
|
||||||
@@ -1104,6 +1122,7 @@
|
|||||||
registerMenu(
|
registerMenu(
|
||||||
{ command: 'dataGrid.refresh' },
|
{ command: 'dataGrid.refresh' },
|
||||||
{ command: 'dataGrid.copyToClipboard' },
|
{ command: 'dataGrid.copyToClipboard' },
|
||||||
|
{ command: 'dataGrid.copyJsonDocument', hideDisabled: true },
|
||||||
{ placeTag: 'switch' },
|
{ placeTag: 'switch' },
|
||||||
{ divider: true },
|
{ divider: true },
|
||||||
{ placeTag: 'save' },
|
{ placeTag: 'save' },
|
||||||
@@ -1120,7 +1139,7 @@
|
|||||||
{ command: 'dataGrid.clearFilter' },
|
{ command: 'dataGrid.clearFilter' },
|
||||||
{ command: 'dataGrid.undo' },
|
{ command: 'dataGrid.undo' },
|
||||||
{ command: 'dataGrid.redo' },
|
{ command: 'dataGrid.redo' },
|
||||||
{ command: 'dataGrid.editJsonDocument' },
|
{ command: 'dataGrid.editJsonDocument', hideDisabled: true },
|
||||||
{ divider: true },
|
{ divider: true },
|
||||||
{ placeTag: 'export' },
|
{ placeTag: 'export' },
|
||||||
{ command: 'dataGrid.generateSqlFromData' },
|
{ command: 'dataGrid.generateSqlFromData' },
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
import EditJsonModal from '../modals/EditJsonModal.svelte';
|
import EditJsonModal from '../modals/EditJsonModal.svelte';
|
||||||
import ErrorMessageModal from '../modals/ErrorMessageModal.svelte';
|
import ErrorMessageModal from '../modals/ErrorMessageModal.svelte';
|
||||||
import { showModal } from '../modals/modalTools';
|
import { showModal } from '../modals/modalTools';
|
||||||
|
import { copyTextToClipboard } from '../utility/clipboard';
|
||||||
import { getContextMenu, registerMenu } from '../utility/contextMenu';
|
import { getContextMenu, registerMenu } from '../utility/contextMenu';
|
||||||
|
|
||||||
export let rowIndex;
|
export let rowIndex;
|
||||||
@@ -32,7 +33,13 @@
|
|||||||
editJsonRowDocument(grider, rowIndex);
|
editJsonRowDocument(grider, rowIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleCopyJsonDocument() {
|
||||||
|
const rowData = grider.getRowData(rowIndex);
|
||||||
|
copyTextToClipboard(JSON.stringify(rowData, undefined, 2));
|
||||||
|
}
|
||||||
|
|
||||||
registerMenu([
|
registerMenu([
|
||||||
|
{ text: 'Copy JSON document', onClick: handleCopyJsonDocument },
|
||||||
{ text: 'Edit document', onClick: handleEditDocument },
|
{ text: 'Edit document', onClick: handleEditDocument },
|
||||||
{ text: 'Delete document', onClick: () => grider.deleteRow(rowIndex) },
|
{ text: 'Delete document', onClick: () => grider.deleteRow(rowIndex) },
|
||||||
{ text: 'Revert row changes', onClick: () => grider.revertRowChanges(rowIndex) },
|
{ text: 'Revert row changes', onClick: () => grider.revertRowChanges(rowIndex) },
|
||||||
|
|||||||
Reference in New Issue
Block a user