new perspective command

This commit is contained in:
Jan Prochazka 2022-09-01 11:18:25 +02:00
parent a910e91a91
commit eab5f4fe5e
5 changed files with 33 additions and 6 deletions

View File

@ -8,6 +8,7 @@ module.exports = ({ editMenu }) => [
{ command: 'new.query', hideDisabled: true },
{ command: 'new.queryDesign', hideDisabled: true },
{ command: 'new.diagram', hideDisabled: true },
{ command: 'new.perspective', hideDisabled: true },
{ command: 'new.freetable', hideDisabled: true },
{ command: 'new.shell', hideDisabled: true },
{ command: 'new.jsonl', hideDisabled: true },

View File

@ -116,7 +116,16 @@ export function createPerspectiveNodeConfig(name: { schemaName?: string; pureNam
return node;
}
export function createPerspectiveConfig(rootObject: { schemaName?: string; pureName: string }): PerspectiveConfig {
export function createPerspectiveConfig(rootObject?: { schemaName?: string; pureName: string }): PerspectiveConfig {
if (!rootObject) {
return {
nodes: [],
references: [],
isArranged: true,
rootDesignerId: null,
};
}
const rootNode = createPerspectiveNodeConfig(rootObject);
return {
nodes: [rootNode],

View File

@ -6,7 +6,7 @@ import SettingsModal from '../settings/SettingsModal.svelte';
import ImportExportModal from '../modals/ImportExportModal.svelte';
import SqlGeneratorModal from '../modals/SqlGeneratorModal.svelte';
import { showModal } from '../modals/modalTools';
import newQuery, { newDiagram, newQueryDesign } from '../query/newQuery';
import newQuery, { newDiagram, newPerspective, newQueryDesign } from '../query/newQuery';
import saveTabFile from '../utility/saveTabFile';
import openNewTab from '../utility/openNewTab';
import getElectron from '../utility/getElectron';
@ -129,6 +129,15 @@ registerCommand({
onClick: () => newQueryDesign(),
});
registerCommand({
id: 'new.perspective',
category: 'New',
icon: 'img perspective',
name: 'Perspective',
menuName: 'New perspective',
onClick: () => newPerspective(),
});
registerCommand({
id: 'new.diagram',
category: 'New',

View File

@ -40,3 +40,7 @@ export function newQueryDesign() {
export function newDiagram() {
return newQuery({ tabComponent: 'DiagramTab', icon: 'img diagram', title: 'Diagram #' });
}
export function newPerspective() {
return newQuery({ tabComponent: 'PerspectiveTab', icon: 'img perspective', title: 'Perspective #' });
}

View File

@ -101,10 +101,14 @@
});
const [modelState, dispatchModel] = createUndoReducer(
createPerspectiveConfig({
schemaName,
pureName,
})
createPerspectiveConfig(
pureName
? {
schemaName,
pureName,
}
: null
)
);
const cache = new PerspectiveCache();