c.uidt === UITypes.LinkToAnotherRecord)
+
+ if (relationColumns.length) {
+ const refColMsgs = await Promise.all(relationColumns.map(async(c, i) => {
+ const refMeta = await this.$store.dispatch('meta/ActLoadMeta', { id: c.colOptions.fk_related_model_id })
+ return `${i + 1}. ${c.title} is a LinkToAnotherRecord of ${(refMeta && refMeta.title) || c.title}`
+ }))
+ this.$toast.info(`Unable to delete tables because of the following.
+
${refColMsgs.join('
')}
+ Delete them & try again
+ `).goAway(10000)
+ this.dialogDeleteTable.dialogShow = false
+ return
+ }
+ await this.$api.dbTable.delete(id)
+
+ this.removeTableTab({
+ env: nodes.env,
+ dbAlias: nodes.dbAlias,
+ table_name: nodes.table_name
+ })
+
+ await this.loadTablesFromParentTreeNode({
+ _nodes: {
+ ...nodes
+ }
+ })
+
+ this.$store.commit('meta/MutMeta', {
+ key: nodes.table_name,
+ value: null
+ })
+ this.$store.commit('meta/MutMeta', {
+ key: id,
+ value: null
+ })
+ this.$toast.info(`Deleted table ${nodes.title} successfully`).goAway(3000)
+ } catch (e) {
+ const msg = await this._extractSdkResponseErrorMsg(e)
+ this.$toast.error(msg).goAway(3000)
+ }
+ this.dialogDeleteTable.dialogShow = false
+ this.$e('a:table:delete')
+ }
+ },
/* settingsTabAdd() {
const tabIndex = this.tabs.findIndex(el => el.key === `projectSettings`);
if (tabIndex !== -1) {
@@ -1189,6 +1274,7 @@ export default {
"project/loadProceduresFromParentTreeNode",
removeTabsByName: "tabs/removeTabsByName",
clearProjects: "project/clearProjects",
+ removeTableTab: 'tabs/removeTableTab',
}),
async addTab(item, open, leaf) {
// console.log("addtab item", item, open, leaf);
@@ -1792,7 +1878,7 @@ export default {
this.selectedNodeForDelete = {
dialog: true,
item: item,
- heading: `Click Submit to Delete The ${item._nodes.type}`,
+ heading: `Click Submit to Delete The ${item._nodes.type}: ${item.name}`,
};
} else if (action === "hideDialog") {
this.selectedNodeForDelete = {
@@ -1803,34 +1889,8 @@ export default {
} else {
item = this.selectedNodeForDelete.item;
if (item._nodes.type === "table") {
- const result = await this.$store.dispatch("sqlMgr/ActSqlOp", [
- {
- env: item._nodes.env,
- dbAlias: item._nodes.dbAlias,
- },
- "columnList",
- {
- table_name: item._nodes.table_name,
- },
- ]);
-
- await this.sqlMgr.sqlOpPlus(
- {
- env: item._nodes.env,
- dbAlias: item._nodes.dbAlias,
- },
- "tableDelete",
- {
- table_name: item._nodes.table_name,
- columns: columns.data.list,
- }
- );
- await this.loadTablesFromParentTreeNode({
- _nodes: {
- ...item._nodes,
- },
- });
- this.$toast.success("Table deleted successfully").goAway(3000);
+ await this.checkAndDeleteTable(item, '')
+
} else if (item._nodes.type === "view") {
const view = await this.$store.dispatch("sqlMgr/ActSqlOp", [
{
diff --git a/packages/nc-gui/components/project/Table.vue b/packages/nc-gui/components/project/Table.vue
index 62b7f88e22..5bd46ab9d9 100644
--- a/packages/nc-gui/components/project/Table.vue
+++ b/packages/nc-gui/components/project/Table.vue
@@ -143,6 +143,7 @@ export default {
key: this.deleteId,
value: null
})
+ this.$toast.info(`Deleted table ${this.nodes.title} successfully`).goAway(3000)
} catch (e) {
const msg = await this._extractSdkResponseErrorMsg(e)
this.$toast.error(msg).goAway(3000)
diff --git a/packages/nc-gui/helpers/rightClickOptions.js b/packages/nc-gui/helpers/rightClickOptions.js
index 6efb42a43e..644c6ca3e0 100644
--- a/packages/nc-gui/helpers/rightClickOptions.js
+++ b/packages/nc-gui/helpers/rightClickOptions.js
@@ -61,7 +61,7 @@ export default {
},
table: {
'Table Rename': 'ENV_DB_TABLES_RENAME',
- // "Table Delete": "ENV_DB_TABLES_DELETE",
+ "Table Delete": "ENV_DB_TABLES_DELETE",
// d1: null,
// "Send to SQL Editor": {
// 'Copy To Clipboard': {