diff --git a/packages/web/src/datagrid/CollectionDataGridCore.svelte b/packages/web/src/datagrid/CollectionDataGridCore.svelte index 8cdd1fdf..80483398 100644 --- a/packages/web/src/datagrid/CollectionDataGridCore.svelte +++ b/packages/web/src/datagrid/CollectionDataGridCore.svelte @@ -137,47 +137,6 @@ initialValues.sourceList = display.baseTable ? [display.baseTable.pureName] : []; showModal(ImportExportModal, { initialValues }); } - - function openQuery() { - openNewTab( - { - title: 'Query #', - icon: 'img sql-file', - tabComponent: 'QueryTab', - props: { - schemaName: display.baseTable.schemaName, - pureName: display.baseTable.pureName, - conid, - database, - }, - }, - { - editor: display.getExportQuery(), - } - ); - } - - function openActiveChart() { - openNewTab( - { - title: 'Chart #', - icon: 'img chart', - tabComponent: 'ChartTab', - props: { - conid, - database, - }, - }, - { - editor: { - config: { chartType: 'bar' }, - sql: display.getExportQuery(select => { - select.orderBy = null; - }), - }, - } - ); - } getCurrentDataGrid().clearFilter(), }); - registerCommand({ - id: 'dataGrid.openQuery', - category: 'Data grid', - name: 'Open query', - testEnabled: () => getCurrentDataGrid()?.openQueryEnabled(), - onClick: () => getCurrentDataGrid().openQuery(), - }); - registerCommand({ id: 'dataGrid.openFreeTable', category: 'Data grid', @@ -251,7 +243,6 @@ // export let onSelectedCellsPublishedChanged = undefined; export let focusOnVisible = false; export let onExportGrid = null; - export let onOpenQuery = null; export let formViewAvailable = false; export let jsonViewAvailable = false; export let errorMessage = undefined; @@ -428,14 +419,6 @@ return display.filterCount > 0; } - export function openQuery() { - if (onOpenQuery) onOpenQuery(); - } - - export function openQueryEnabled() { - return onOpenQuery != null; - } - export function openFreeTable() { openNewTab( { @@ -1010,7 +993,7 @@ { command: 'dataGrid.undo' }, { command: 'dataGrid.redo' }, { divider: true }, - { command: 'dataGrid.openQuery' }, + { placeTag: 'export' }, { command: 'dataGrid.openFreeTable' }, { command: 'dataGrid.openChartFromSelection' }, { placeTag: 'chart' } diff --git a/packages/web/src/datagrid/SqlDataGridCore.svelte b/packages/web/src/datagrid/SqlDataGridCore.svelte index 64565a4d..443900fc 100644 --- a/packages/web/src/datagrid/SqlDataGridCore.svelte +++ b/packages/web/src/datagrid/SqlDataGridCore.svelte @@ -2,13 +2,21 @@ const getCurrentEditor = () => getActiveComponent('SqlDataGridCore'); registerCommand({ - id: 'dataGrid.openActiveChart', + id: 'sqlDataGrid.openActiveChart', category: 'Data grid', name: 'Open active chart', testEnabled: () => getCurrentEditor() != null, onClick: () => getCurrentEditor().openActiveChart(), }); + registerCommand({ + id: 'sqlDataGrid.openQuery', + category: 'Data grid', + name: 'Open query', + testEnabled: () => getCurrentEditor() != null, + onClick: () => getCurrentEditor().openQuery(), + }); + async function loadDataPage(props, offset, limit) { const { display, conid, database } = props; @@ -112,7 +120,7 @@ showModal(ImportExportModal, { initialValues }); } - function openQuery() { + export function openQuery() { openNewTab( { title: 'Query #', @@ -153,7 +161,10 @@ ); } - registerMenu({ command: 'dataGrid.openActiveChart', tag: 'chart' }); + registerMenu( + { command: 'sqlDataGrid.openActiveChart', tag: 'chart' }, + { command: 'sqlDataGrid.openQuery', tag: 'export' } + );