diff --git a/packages/api/src/controllers/apps.js b/packages/api/src/controllers/apps.js index 462d3d4d..5b9ea438 100644 --- a/packages/api/src/controllers/apps.js +++ b/packages/api/src/controllers/apps.js @@ -126,7 +126,6 @@ module.exports = { } } } - console.log('APPS', apps); for (const folder of apps) { res.push(await this.loadApp({ folder })); } diff --git a/packages/web/src/datagrid/ColumnHeaderControl.svelte b/packages/web/src/datagrid/ColumnHeaderControl.svelte index 762ed303..48a0b88a 100644 --- a/packages/web/src/datagrid/ColumnHeaderControl.svelte +++ b/packages/web/src/datagrid/ColumnHeaderControl.svelte @@ -7,6 +7,8 @@ import { isTypeDateTime } from 'dbgate-tools'; import { openDatabaseObjectDetail } from '../appobj/DatabaseObjectAppObject.svelte'; import { copyTextToClipboard } from '../utility/clipboard'; + import VirtualForeignKeyEditorModal from '../tableeditor/VirtualForeignKeyEditorModal.svelte'; + import { showModal } from '../modals/modalTools'; export let column; export let conid = undefined; @@ -26,6 +28,16 @@ }); }; + const handleDefineVirtualForeignKey = () => { + showModal(VirtualForeignKeyEditorModal, { + schemaName: column.schemaName, + pureName: column.pureName, + conid, + database, + columnName: column.columnName, + }); + }; + function getMenu() { return [ setSort && { onClick: () => setSort('ASC'), text: 'Sort ascending' }, @@ -49,6 +61,9 @@ { onClick: () => setGrouping('GROUP:MONTH'), text: 'Group by MONTH' }, { onClick: () => setGrouping('GROUP:DAY'), text: 'Group by DAY' }, ], + + { divider: true }, + { onClick: handleDefineVirtualForeignKey, text: 'Define virtual foreign key' }, ]; } diff --git a/packages/web/src/tableeditor/VirtualForeignKeyEditorModal.svelte b/packages/web/src/tableeditor/VirtualForeignKeyEditorModal.svelte new file mode 100644 index 00000000..cf01b4c7 --- /dev/null +++ b/packages/web/src/tableeditor/VirtualForeignKeyEditorModal.svelte @@ -0,0 +1,183 @@ + + + + + Virtual foreign key + +
+
+
Referenced table
+
+ ({ + label: fullNameToLabel(tbl), + value: fullNameToString(tbl), + }))} + on:change={e => { + if (e.detail) { + const name = fullNameFromString(e.detail); + refTableName = name.pureName; + refSchemaName = name.schemaName; + } + }} + /> +
+
+ +
+
+ Base column - {$tableInfo.pureName} +
+
+ Ref column - {refTableName || '(table not set)'} +
+
+ + {#each columns as column, index} +
+
+ {#key column.columnName} + ({ + label: col.columnName, + value: col.columnName, + }))} + on:change={e => { + if (e.detail) { + columns = columns.map((col, i) => (i == index ? { ...col, columnName: e.detail } : col)); + } + }} + /> + {/key} +
+
+ {#key column.refColumnName} + ({ + label: col.columnName, + value: col.columnName, + }))} + on:change={e => { + if (e.detail) { + columns = columns.map((col, i) => (i == index ? { ...col, refColumnName: e.detail } : col)); + } + }} + /> + {/key} +
+
+ { + const x = [...columns]; + x.splice(index, 1); + columns = x; + }} + /> +
+
+ {/each} +
+ + { + columns = [...columns, {}]; + }} + /> + + + { + closeCurrentModal(); + }} + /> + + + +
+
+ +