Browse Source

fix: grid view issues

- maintain column order after column rename
- show column menu in main view and hide from grid view
- keep column order from main view for newly created grid view

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/743/head
Pranav C 3 years ago
parent
commit
1e1d21a03c
  1. 2
      packages/nc-gui/components/project/spreadsheet/components/editColumn.vue
  2. 2
      packages/nc-gui/components/project/spreadsheet/components/editVirtualColumn.vue
  3. 2
      packages/nc-gui/components/project/spreadsheet/components/headerCell.vue
  4. 8
      packages/nc-gui/components/project/spreadsheet/components/spreadsheetNavDrawer.vue
  5. 4
      packages/nc-gui/components/project/spreadsheet/components/virtualHeaderCell.vue
  6. 30
      packages/nc-gui/components/project/spreadsheet/rowsXcDataTable.vue
  7. 5
      packages/nc-gui/components/project/spreadsheet/views/xcGridView.vue

2
packages/nc-gui/components/project/spreadsheet/components/editColumn.vue

@ -567,7 +567,7 @@ export default {
await this.$refs.relation.saveRelation() await this.$refs.relation.saveRelation()
} }
this.$emit('saved', this.newColumn._cn) this.$emit('saved', this.newColumn._cn, this.editColumn ? this.meta.columns[this.columnIndex]._cn : null)
} catch (e) { } catch (e) {
console.log(e) console.log(e)
} }

2
packages/nc-gui/components/project/spreadsheet/components/editVirtualColumn.vue

@ -106,7 +106,7 @@ export default {
console.log(e) console.log(e)
this.$toast.error('Failed to update column alias').goAway(3000) this.$toast.error('Failed to update column alias').goAway(3000)
} }
this.$emit('saved', this.newColumn._cn) this.$emit('saved', this.newColumn._cn, this.column._cn)
this.$emit('input', false) this.$emit('input', false)
}, },

2
packages/nc-gui/components/project/spreadsheet/components/headerCell.vue

@ -98,7 +98,7 @@
:column="column" :column="column"
:column-index="columnIndex" :column-index="columnIndex"
@onRelationDelete="$emit('onRelationDelete')" @onRelationDelete="$emit('onRelationDelete')"
@saved="$emit('saved')" @saved="(_cn,_cno) => $emit('saved',_cn,_cno)"
@close="editColumnMenu = false" @close="editColumnMenu = false"
/> />
</v-menu> </v-menu>

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

@ -623,6 +623,14 @@ export default {
this.$store.commit('windows/MutMiniSponsorCard', Date.now()) this.$store.commit('windows/MutMiniSponsorCard', Date.now())
}, },
openCreateViewDlg(type) { openCreateViewDlg(type) {
const mainView = this.viewsList.find(v => v.type === 'table' || v.type === 'view')
try {
this.copyViewRef = this.copyViewRef || {
query_params: JSON.stringify({
fieldsOrder: JSON.parse(mainView.query_params).fieldsOrder
})
}
} catch {}
this.createViewType = type this.createViewType = type
this.showCreateView = true this.showCreateView = true
}, },

4
packages/nc-gui/components/project/spreadsheet/components/virtualHeaderCell.vue

@ -46,7 +46,7 @@
<v-spacer /> <v-spacer />
<v-menu <v-menu
v-if="!isLocked && !isPublicView && _isUIAllowed('edit-column') && !isForm" v-if="!isLocked && !isVirtual && !isPublicView && _isUIAllowed('edit-column') && !isForm"
offset-y offset-y
open-on-hover open-on-hover
left left
@ -133,7 +133,7 @@ import EditVirtualColumn from '@/components/project/spreadsheet/components/editV
export default { export default {
name: 'VirtualHeaderCell', name: 'VirtualHeaderCell',
components: { EditVirtualColumn }, components: { EditVirtualColumn },
props: ['column', 'nodes', 'meta', 'isForm', 'isPublicView', 'sqlUi', 'required', 'isLocked'], props: ['column', 'nodes', 'meta', 'isForm', 'isPublicView', 'sqlUi', 'required', 'isLocked', 'isVirtual'],
data: () => ({ data: () => ({
columnDeleteDialog: false, columnDeleteDialog: false,
editColumnMenu: false, editColumnMenu: false,

30
packages/nc-gui/components/project/spreadsheet/rowsXcDataTable.vue

@ -223,10 +223,10 @@
:style="{height:isForm ? '100%' : 'calc(100% - 36px)'}" :style="{height:isForm ? '100%' : 'calc(100% - 36px)'}"
style="overflow: auto;width:100%" style="overflow: auto;width:100%"
> >
<v-skeleton-loader v-if="!dataLoaded && (loadingData || loadingData) || !meta" type="table" /> <v-skeleton-loader v-if="!dataLoaded && loadingData || !meta" type="table" />
<template v-else-if="selectedView && (selectedView.type === 'table' || selectedView.show_as === 'grid' )"> <template v-else-if="selectedView && (selectedView.type === 'table' || selectedView.show_as === 'grid' )">
<xc-grid-view <xc-grid-view
:key="key" :key="key + selectedViewId"
ref="ncgridview" ref="ncgridview"
:relation-type="relationType" :relation-type="relationType"
:columns-width.sync="columnsWidth" :columns-width.sync="columnsWidth"
@ -372,7 +372,7 @@
</template> </template>
Create Automations or API Webhooks Create Automations or API Webhooks
</v-tooltip> </v-tooltip>
<v-tooltip bottom> <!-- <v-tooltip bottom>
<template #activator="{on}"> <template #activator="{on}">
<v-list-item <v-list-item
v-on="on" v-on="on"
@ -385,7 +385,7 @@
</v-list-item> </v-list-item>
</template> </template>
Create / Edit API Webhooks Create / Edit API Webhooks
</v-tooltip> </v-tooltip>-->
<v-list-item <v-list-item
v-if="showAdvanceOptions" v-if="showAdvanceOptions"
@click="showAdditionalFeatOverlay('validators')" @click="showAdditionalFeatOverlay('validators')"
@ -519,7 +519,6 @@
@prev="loadPrev" @prev="loadPrev"
/> />
</v-dialog> </v-dialog>
<additional-features <additional-features
v-model="showAddFeatOverlay" v-model="showAddFeatOverlay"
:selected-view="selectedView" :selected-view="selectedView"
@ -1016,15 +1015,26 @@ export default {
break break
} }
}, },
async loadMeta(updateShowFields = true, col) { async loadMeta(updateShowFields = true, col, oldCol) {
this.loadingMeta = true // update column name in column meta data
if (oldCol && col) {
this.$set(this.columnsWidth, col, this.columnsWidth[oldCol])
this.$set(this.showFields, col, this.showFields[oldCol])
const i = (this.fieldsOrder || []).indexOf(oldCol)
if (i > -1) {
this.$set(this.fieldsOrder, i, col)
}
}
// load latest table meta
const tableMeta = await this.$store.dispatch('meta/ActLoadMeta', { const tableMeta = await this.$store.dispatch('meta/ActLoadMeta', {
env: this.nodes.env, env: this.nodes.env,
dbAlias: this.nodes.dbAlias, dbAlias: this.nodes.dbAlias,
tn: this.table, tn: this.table,
force: true force: true
}) })
this.loadingMeta = false
// update column visibility
if (updateShowFields) { if (updateShowFields) {
try { try {
const qp = JSON.parse(tableMeta.query_params) const qp = JSON.parse(tableMeta.query_params)
@ -1082,8 +1092,8 @@ export default {
this.selectedExpandRowIndex = row this.selectedExpandRowIndex = row
this.selectedExpandRowMeta = rowMeta this.selectedExpandRowMeta = rowMeta
}, },
async onNewColCreation(col) { async onNewColCreation(col, oldCol) {
await this.loadMeta(true, col) await this.loadMeta(true, col, oldCol)
this.$nextTick(async() => { this.$nextTick(async() => {
await this.loadTableData() await this.loadTableData()
// this.mapFieldsAndShowFields(); // this.mapFieldsAndShowFields();

5
packages/nc-gui/components/project/spreadsheet/views/xcGridView.vue

@ -37,6 +37,7 @@
:sql-ui="sqlUi" :sql-ui="sqlUi"
:is-public-view="isPublicView" :is-public-view="isPublicView"
:is-locked="isLocked" :is-locked="isLocked"
:is-virtual="isVirtual"
@saved="onNewColCreation" @saved="onNewColCreation"
/> />
@ -464,10 +465,10 @@ export default {
this.selected.col = null this.selected.col = null
this.selected.row = null this.selected.row = null
}, },
onNewColCreation(col) { onNewColCreation(col, oldCol) {
this.addNewColMenu = false this.addNewColMenu = false
this.addNewColModal = false this.addNewColModal = false
this.$emit('onNewColCreation', col) this.$emit('onNewColCreation', col, oldCol)
}, },
expandRow(...args) { expandRow(...args) {
this.$emit('expandRow', ...args) this.$emit('expandRow', ...args)

Loading…
Cancel
Save