Browse Source

enhancement: enable right click to delete table

pull/2547/head
Wing-Kam Wong 2 years ago
parent
commit
f7dfb822bb
  1. 36
      packages/nc-gui/components/ProjectTreeView.vue
  2. 2
      packages/nc-gui/helpers/rightClickOptions.js

36
packages/nc-gui/components/ProjectTreeView.vue

@ -1096,11 +1096,11 @@ export default {
openLink(link) { openLink(link) {
window.open(link, "_blank"); window.open(link, "_blank");
}, },
async checkAndDeleteTable(table) { async checkAndDeleteTable(table, action = 'showDialog') {
this.dialogDeleteTable.tableName = table.table_name this.dialogDeleteTable.tableName = table.table_name
this.dialogDeleteTable.nodes = table._nodes this.dialogDeleteTable.nodes = table._nodes
this.dialogDeleteTable.id = table.id this.dialogDeleteTable.id = table.id
await this.deleteTable('showDialog') await this.deleteTable(action)
this.$e('c:table:delete') this.$e('c:table:delete')
}, },
async deleteTable(action = '') { async deleteTable(action = '') {
@ -1879,7 +1879,7 @@ export default {
this.selectedNodeForDelete = { this.selectedNodeForDelete = {
dialog: true, dialog: true,
item: item, 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") { } else if (action === "hideDialog") {
this.selectedNodeForDelete = { this.selectedNodeForDelete = {
@ -1890,34 +1890,8 @@ export default {
} else { } else {
item = this.selectedNodeForDelete.item; item = this.selectedNodeForDelete.item;
if (item._nodes.type === "table") { if (item._nodes.type === "table") {
const result = await this.$store.dispatch("sqlMgr/ActSqlOp", [ await this.checkAndDeleteTable(item, '')
{
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);
} else if (item._nodes.type === "view") { } else if (item._nodes.type === "view") {
const view = await this.$store.dispatch("sqlMgr/ActSqlOp", [ const view = await this.$store.dispatch("sqlMgr/ActSqlOp", [
{ {

2
packages/nc-gui/helpers/rightClickOptions.js

@ -61,7 +61,7 @@ export default {
}, },
table: { table: {
'Table Rename': 'ENV_DB_TABLES_RENAME', 'Table Rename': 'ENV_DB_TABLES_RENAME',
// "Table Delete": "ENV_DB_TABLES_DELETE", "Table Delete": "ENV_DB_TABLES_DELETE",
// d1: null, // d1: null,
// "Send to SQL Editor": { // "Send to SQL Editor": {
// 'Copy To Clipboard': { // 'Copy To Clipboard': {

Loading…
Cancel
Save