mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-19 13:06:01 +00:00
create table - changed workflow
This commit is contained in:
@@ -91,6 +91,7 @@
|
||||
export let dbInfo;
|
||||
export let driver;
|
||||
export let resetCounter;
|
||||
export let isCreateTable;
|
||||
|
||||
$: isWritable = !!setTableInfo;
|
||||
|
||||
@@ -165,15 +166,14 @@
|
||||
</script>
|
||||
|
||||
<div class="wrapper">
|
||||
{#if tableFormOptions}
|
||||
{#if tableInfo && (tableFormOptions || isCreateTable)}
|
||||
{#key resetCounter}
|
||||
<ObjectFieldsEditor
|
||||
title="Table properties"
|
||||
fieldDefinitions={tableFormOptions}
|
||||
values={_.pick(
|
||||
tableInfo,
|
||||
tableFormOptions.map(x => x.name)
|
||||
)}
|
||||
fieldDefinitions={tableFormOptions ?? []}
|
||||
pureNameTitle="Table name"
|
||||
schemaList={dbInfo?.schemas?.length >= 0 ? dbInfo?.schemas : null}
|
||||
values={_.pick(tableInfo, ['schemaName', 'pureName', ...(tableFormOptions ?? []).map(x => x.name)])}
|
||||
onChangeValues={vals => {
|
||||
if (!_.isEmpty(vals)) {
|
||||
setTableInfo(tbl => ({ ...tbl, ...vals }));
|
||||
|
||||
48
packages/web/src/tableeditor/newTable.ts
Normal file
48
packages/web/src/tableeditor/newTable.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import _ from 'lodash';
|
||||
import openNewTab from '../utility/openNewTab';
|
||||
import { findEngineDriver, getConnectionLabel } from 'dbgate-tools';
|
||||
import { getExtensions } from '../stores';
|
||||
|
||||
export default function newTable(connection, database) {
|
||||
const tooltip = `${getConnectionLabel(connection)}\n${database}`;
|
||||
const driver = findEngineDriver(connection, getExtensions());
|
||||
openNewTab(
|
||||
{
|
||||
title: 'Table #',
|
||||
tooltip,
|
||||
icon: 'img table-structure',
|
||||
tabComponent: 'TableStructureTab',
|
||||
props: {
|
||||
conid: connection._id,
|
||||
database,
|
||||
},
|
||||
},
|
||||
{
|
||||
editor: {
|
||||
current: {
|
||||
pureName: 'new_table',
|
||||
schemaName: driver?.dialect?.defaultSchemaName,
|
||||
columns: [
|
||||
{
|
||||
columnName: 'id',
|
||||
dataType: 'int',
|
||||
isNullable: false,
|
||||
isPrimaryKey: true,
|
||||
isAutoIncrement: true,
|
||||
},
|
||||
],
|
||||
primaryKey: {
|
||||
columns: [
|
||||
{
|
||||
columnName: 'id',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
forceNewTab: true,
|
||||
}
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user