Browse Source

fix: update view name in list after rename

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/644/head
Pranav C 3 years ago
parent
commit
e36a0c3f20
  1. 40
      packages/nc-gui/components/project/spreadsheet/components/spreadsheetNavDrawer.vue

40
packages/nc-gui/components/project/spreadsheet/components/spreadsheetNavDrawer.vue

@ -387,19 +387,19 @@
</v-menu> </v-menu>
</v-list-item> </v-list-item>
<!-- <v-tooltip bottom>--> <!-- <v-tooltip bottom>-->
<!-- <template #activator="{ on }">--> <!-- <template #activator="{ on }">-->
<!-- <v-list-item v-on="on" @click="copyapiUrlToClipboard">--> <!-- <v-list-item v-on="on" @click="copyapiUrlToClipboard">-->
<!-- <v-icon x-small class="mr-2">--> <!-- <v-icon x-small class="mr-2">-->
<!-- mdi-content-copy--> <!-- mdi-content-copy-->
<!-- </v-icon>--> <!-- </v-icon>-->
<!-- &lt;!&ndash; Copy API URL &ndash;&gt;--> <!-- &lt;!&ndash; Copy API URL &ndash;&gt;-->
<!-- <span class="caption">{{ $t('nav_drawer.advanced.views_list') }}</span>--> <!-- <span class="caption">{{ $t('nav_drawer.advanced.views_list') }}</span>-->
<!-- </v-list-item>--> <!-- </v-list-item>-->
<!-- </template>--> <!-- </template>-->
<!-- &lt;!&ndash; Copy API URL &ndash;&gt;--> <!-- &lt;!&ndash; Copy API URL &ndash;&gt;-->
<!-- {{ $t('nav_drawer.advanced.views_list') }}--> <!-- {{ $t('nav_drawer.advanced.views_list') }}-->
<!-- </v-tooltip>--> <!-- </v-tooltip>-->
<template v-if="_isUIAllowed('model')"> <template v-if="_isUIAllowed('model')">
<v-divider class="advance-menu-divider" /> <v-divider class="advance-menu-divider" />
<slot /> <slot />
@ -437,7 +437,11 @@
<div style="border-radius: 4px" class="share-link-box body-2 pa-2 d-flex align-center"> <div style="border-radius: 4px" class="share-link-box body-2 pa-2 d-flex align-center">
{{ `${dashboardUrl}#/nc/${shareLink.view_type || 'view'}/${shareLink.view_id}` }} {{ `${dashboardUrl}#/nc/${shareLink.view_type || 'view'}/${shareLink.view_id}` }}
<v-spacer /> <v-spacer />
<a :href=" `${dashboardUrl}#/nc/${shareLink.view_type || 'view'}/${shareLink.view_id}`" style="text-decoration: none" target="_blank"> <a
:href=" `${dashboardUrl}#/nc/${shareLink.view_type || 'view'}/${shareLink.view_id}`"
style="text-decoration: none"
target="_blank"
>
<v-icon small class="mx-2">mdi-open-in-new</v-icon> <v-icon small class="mx-2">mdi-open-in-new</v-icon>
</a> </a>
<v-icon <v-icon
@ -695,15 +699,17 @@ export default {
this.clipboardSuccessHandler() this.clipboardSuccessHandler()
}, },
async updateViewName(view, index) { async updateViewName(view, index) {
if (view.title_temp === view.title || !view.edit) { return } if (!view.edit) {
return
}
this.$set(view, 'edit', false) this.$set(view, 'edit', false)
if (view.title_temp === view.title) { return }
if (this.viewsList.some((v, i) => i !== index && (v.alias || v.title) === view.title_temp)) { if (this.viewsList.some((v, i) => i !== index && (v.alias || v.title) === view.title_temp)) {
this.$toast.info('View name should be unique').goAway(3000) this.$toast.info('View name should be unique').goAway(3000)
return return
} }
try { try {
if (this.selectedViewIdLocal === view.id) { if (this.selectedViewIdLocal === view.id) {
this.$set(view, 'title', view.title_temp)
await this.$router.push({ await this.$router.push({
query: { query: {
...this.$route.query, ...this.$route.query,
@ -711,6 +717,7 @@ export default {
} }
}) })
} }
this.$set(view, 'title', view.title_temp)
await this.sqlOp({ dbAlias: this.nodes.dbAlias }, 'xcVirtualTableRename', { await this.sqlOp({ dbAlias: this.nodes.dbAlias }, 'xcVirtualTableRename', {
id: view.id, id: view.id,
old_title: view.title, old_title: view.title,
@ -722,7 +729,6 @@ export default {
} catch (e) { } catch (e) {
this.$toast.error(e.message).goAway(3000) this.$toast.error(e.message).goAway(3000)
} }
// await this.loadViews()
}, },
showRenameTextBox(view, i) { showRenameTextBox(view, i) {
this.$set(view, 'edit', true) this.$set(view, 'edit', true)

Loading…
Cancel
Save