mirror of https://github.com/nocodb/nocodb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
234 lines
6.5 KiB
234 lines
6.5 KiB
4 years ago
|
<template>
|
||
3 years ago
|
<v-container fluid class="pa-0 ma-0 nc-table-tab" style="height: 100%">
|
||
4 years ago
|
<v-alert v-if="error" type="error" class="ma-2">
|
||
|
{{ error }}
|
||
|
</v-alert>
|
||
|
<template v-else>
|
||
|
<v-tabs
|
||
|
v-model="active"
|
||
3 years ago
|
:height="relationTabs && relationTabs.length ? 38 : 0"
|
||
4 years ago
|
class="table-tabs"
|
||
3 years ago
|
:class="{ 'hidden-tab': !relationTabs || !relationTabs.length }"
|
||
4 years ago
|
color="pink"
|
||
3 years ago
|
@change="onTabChange"
|
||
4 years ago
|
>
|
||
3 years ago
|
<template v-if="_isUIAllowed('smartSheet')">
|
||
3 years ago
|
<v-tab v-show="relationTabs && relationTabs.length" class="">
|
||
3 years ago
|
<v-icon small>
|
||
|
mdi-table-edit
|
||
|
</v-icon> <span
|
||
3 years ago
|
class="caption text-capitalize font-weight-bold"
|
||
|
>
|
||
3 years ago
|
{{ nodes.title }}</span>
|
||
3 years ago
|
</v-tab>
|
||
3 years ago
|
<v-tab-item style="height: 100%">
|
||
3 years ago
|
<rows-xc-data-table
|
||
|
ref="tabs7"
|
||
3 years ago
|
:is-view="isView"
|
||
3 years ago
|
:is-active="isActive"
|
||
3 years ago
|
:tab-id="tabId"
|
||
3 years ago
|
:show-tabs="relationTabs && relationTabs.length"
|
||
3 years ago
|
:table="nodes.table_name"
|
||
3 years ago
|
:nodes="nodes"
|
||
3 years ago
|
:new-table="newTableCopy"
|
||
|
:mtd-new-table-update="mtdNewTableUpdate"
|
||
|
:delete-table="deleteTable"
|
||
3 years ago
|
:is-meta-table="isMetaTable"
|
||
|
/>
|
||
4 years ago
|
</v-tab-item>
|
||
|
</template>
|
||
|
</v-tabs>
|
||
|
</template>
|
||
|
<dlgLabelSubmitCancel
|
||
|
v-if="dialogShow"
|
||
3 years ago
|
type="error"
|
||
|
:actions-mtd="deleteTable"
|
||
|
:dialog-show="dialogShow"
|
||
4 years ago
|
heading="Click Submit to Delete the Table"
|
||
|
/>
|
||
|
</v-container>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
3 years ago
|
import { mapActions } from 'vuex'
|
||
|
import { UITypes } from 'nocodb-sdk'
|
||
3 years ago
|
import dlgLabelSubmitCancel from '../utils/DlgLabelSubmitCancel'
|
||
3 years ago
|
import { isMetaTable } from '@/helpers/xutils'
|
||
3 years ago
|
import RowsXcDataTable from '~/components/project/spreadsheet/RowsXcDataTable'
|
||
4 years ago
|
|
||
|
export default {
|
||
|
components: {
|
||
|
RowsXcDataTable,
|
||
3 years ago
|
dlgLabelSubmitCancel
|
||
4 years ago
|
},
|
||
3 years ago
|
data() {
|
||
4 years ago
|
return {
|
||
|
error: false,
|
||
3 years ago
|
active: 1,
|
||
3 years ago
|
newTableCopy: !!this.nodes.newTable,
|
||
4 years ago
|
dialogShow: false,
|
||
|
loadIndexList: false,
|
||
|
loadTriggerList: false,
|
||
|
loadRelationList: false,
|
||
|
loadConstraintList: false,
|
||
|
loadRows: false,
|
||
|
loadColumnsMock: false,
|
||
3 years ago
|
relationTabs: [],
|
||
3 years ago
|
deleteId: null
|
||
|
}
|
||
4 years ago
|
},
|
||
|
methods: {
|
||
3 years ago
|
async handleKeyDown(event) {
|
||
3 years ago
|
const activeTabEleKey = `tabs${this.active}`
|
||
3 years ago
|
if (
|
||
|
this.$refs[activeTabEleKey] &&
|
||
3 years ago
|
this.$refs[activeTabEleKey].handleKeyDown
|
||
4 years ago
|
) {
|
||
3 years ago
|
await this.$refs[activeTabEleKey].handleKeyDown(event)
|
||
4 years ago
|
}
|
||
|
},
|
||
|
...mapActions({
|
||
3 years ago
|
removeTableTab: 'tabs/removeTableTab',
|
||
|
loadTablesFromParentTreeNode: 'project/loadTablesFromParentTreeNode'
|
||
4 years ago
|
}),
|
||
3 years ago
|
mtdNewTableUpdate(value) {
|
||
3 years ago
|
this.newTableCopy = value
|
||
4 years ago
|
},
|
||
3 years ago
|
async deleteTable(action = '', id) {
|
||
3 years ago
|
if (id) {
|
||
3 years ago
|
this.deleteId = id
|
||
3 years ago
|
}
|
||
3 years ago
|
if (action === 'showDialog') {
|
||
|
this.dialogShow = true
|
||
|
} else if (action === 'hideDialog') {
|
||
|
this.dialogShow = false
|
||
4 years ago
|
} else {
|
||
3 years ago
|
try {
|
||
3 years ago
|
const meta = await this.$store.dispatch('meta/ActLoadMeta', { id: this.deleteId })
|
||
|
|
||
|
const relationColumns = meta.columns.filter(c => c.uidt === UITypes.LinkToAnotherRecord)
|
||
|
|
||
|
if (relationColumns.length) {
|
||
3 years ago
|
const refColMsgs = await Promise.all(relationColumns.map(async(c, i) => {
|
||
3 years ago
|
const refMeta = await this.$store.dispatch('meta/ActLoadMeta', { id: c.colOptions.fk_related_model_id })
|
||
3 years ago
|
return `${i + 1}. ${c.title} is a LinkToAnotherRecord of ${(refMeta && refMeta.title) || c.title}`
|
||
3 years ago
|
}))
|
||
3 years ago
|
this.$toast.info(`<div style="padding:10px 4px">Unable to delete tables because of the following.
|
||
|
<br><br>${refColMsgs.join('<br>')}<br><br>
|
||
|
Delete them & try again</div>
|
||
|
`).goAway(10000)
|
||
3 years ago
|
this.dialogShow = false
|
||
|
return
|
||
|
}
|
||
|
|
||
|
await this.$api.dbTable.delete(this.deleteId)
|
||
3 years ago
|
|
||
|
this.removeTableTab({
|
||
|
env: this.nodes.env,
|
||
|
dbAlias: this.nodes.dbAlias,
|
||
3 years ago
|
table_name: this.nodes.table_name
|
||
|
})
|
||
3 years ago
|
|
||
|
await this.loadTablesFromParentTreeNode({
|
||
|
_nodes: {
|
||
3 years ago
|
...this.nodes
|
||
|
}
|
||
|
})
|
||
3 years ago
|
|
||
3 years ago
|
this.$store.commit('meta/MutMeta', {
|
||
3 years ago
|
key: this.nodes.table_name,
|
||
3 years ago
|
value: null
|
||
|
})
|
||
|
this.$store.commit('meta/MutMeta', {
|
||
3 years ago
|
key: this.deleteId,
|
||
3 years ago
|
value: null
|
||
|
})
|
||
3 years ago
|
} catch (e) {
|
||
3 years ago
|
const msg = await this._extractSdkResponseErrorMsg(e)
|
||
|
this.$toast.error(msg).goAway(3000)
|
||
4 years ago
|
}
|
||
3 years ago
|
this.dialogShow = false
|
||
|
this.$e('a:table:delete')
|
||
4 years ago
|
}
|
||
|
},
|
||
3 years ago
|
onTabChange() {
|
||
3 years ago
|
this.$emit('update:hideLogWindows', this.active === 2)
|
||
|
}
|
||
4 years ago
|
},
|
||
|
computed: {
|
||
3 years ago
|
isMetaTable() {
|
||
3 years ago
|
return isMetaTable(this.nodes.table_name)
|
||
|
}
|
||
4 years ago
|
},
|
||
3 years ago
|
mounted() {
|
||
3 years ago
|
this.onTabChange()
|
||
4 years ago
|
},
|
||
3 years ago
|
props: {
|
||
|
nodes: Object,
|
||
|
hideLogWindows: Boolean,
|
||
|
tabId: String,
|
||
|
isActive: Boolean,
|
||
3 years ago
|
isView: Boolean
|
||
|
}
|
||
|
}
|
||
4 years ago
|
</script>
|
||
|
|
||
|
<style scoped>
|
||
3 years ago
|
/*/deep/ .table-tabs > .v-tabs-items {
|
||
4 years ago
|
border-top: 1px solid #7F828B33;
|
||
3 years ago
|
}*/
|
||
4 years ago
|
|
||
|
/deep/ .scaffoldOnSave .v-input__control {
|
||
|
margin-top: -2px;
|
||
|
}
|
||
|
|
||
3 years ago
|
.table-tabs,
|
||
|
/deep/ .table-tabs > .v-windows {
|
||
4 years ago
|
height: 100%;
|
||
|
}
|
||
3 years ago
|
|
||
4 years ago
|
/deep/ .v-window-item {
|
||
3 years ago
|
height: 100%;
|
||
4 years ago
|
}
|
||
|
|
||
|
.rel-row-parent {
|
||
|
text-align: center;
|
||
|
left: 0;
|
||
|
padding: 2px 3px;
|
||
|
text-transform: none;
|
||
|
display: inline-block;
|
||
|
position: absolute;
|
||
|
top: 0;
|
||
|
font-size: 8px;
|
||
|
white-space: nowrap;
|
||
|
text-overflow: ellipsis;
|
||
|
width: 100%;
|
||
|
overflow: hidden;
|
||
|
color: grey;
|
||
|
}
|
||
|
</style>
|
||
|
<!--
|
||
|
/**
|
||
|
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
|
||
|
*
|
||
|
* @author Naveen MR <oof1lab@gmail.com>
|
||
|
* @author Pranav C Balan <pranavxc@gmail.com>
|
||
|
*
|
||
|
* @license GNU AGPL version 3 or any later version
|
||
|
*
|
||
|
* This program is free software: you can redistribute it and/or modify
|
||
|
* it under the terms of the GNU Affero General Public License as
|
||
|
* published by the Free Software Foundation, either version 3 of the
|
||
|
* License, or (at your option) any later version.
|
||
|
*
|
||
|
* This program is distributed in the hope that it will be useful,
|
||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
* GNU Affero General Public License for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU Affero General Public License
|
||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
|
*
|
||
|
*/
|
||
|
-->
|