From 8956c7ef7601517a93739a065d97398416ec05c3 Mon Sep 17 00:00:00 2001 From: Pranav C <61551451+pranavxc@users.noreply.github.com> Date: Tue, 13 Jul 2021 16:02:18 +0530 Subject: [PATCH] fix(gui): has many new column relation add Signed-off-by: Pranav C <61551451+pranavxc@users.noreply.github.com> --- .../components/virtualCell/hasManyCell.vue | 11 ++- .../components/virtualCell/manyToManyCell.vue | 2 +- .../project/spreadsheet/helpers/uiTypes.js | 72 +++++++++---------- 3 files changed, 46 insertions(+), 39 deletions(-) diff --git a/packages/nc-gui/components/project/spreadsheet/components/virtualCell/hasManyCell.vue b/packages/nc-gui/components/project/spreadsheet/components/virtualCell/hasManyCell.vue index dc3758503c..e5149bd7b4 100644 --- a/packages/nc-gui/components/project/spreadsheet/components/virtualCell/hasManyCell.vue +++ b/packages/nc-gui/components/project/spreadsheet/components/virtualCell/hasManyCell.vue @@ -89,7 +89,7 @@ :has-many="childMeta.hasMany" :belongs-to="childMeta.belongsTo" @cancel="selectedChild = null" - @input="$emit('loadTableData')" + @input="onChildSave" :table="childMeta.tn" v-model="selectedChild" :old-row="{...selectedChild}" @@ -169,6 +169,13 @@ export default { await this.loadChildMeta() }, methods: { + onChildSave() { + if (this.isNew) { + this.addChildToParent(this.selectedChild) + } else { + this.$emit('loadTableData') + } + }, async showChildListModal() { await this.loadChildMeta(); this.childListModal = true; @@ -241,7 +248,7 @@ export default { this.newRecordModal = true; }, async addChildToParent(child) { - if (this.isNew) { + if (this.isNew && this.localState.every(it => it[this.childForeignKey] !== child[this.childPrimaryKey])) { this.localState.push(child); this.newRecordModal = false; return; diff --git a/packages/nc-gui/components/project/spreadsheet/components/virtualCell/manyToManyCell.vue b/packages/nc-gui/components/project/spreadsheet/components/virtualCell/manyToManyCell.vue index 89e15a0a21..5dd351e900 100644 --- a/packages/nc-gui/components/project/spreadsheet/components/virtualCell/manyToManyCell.vue +++ b/packages/nc-gui/components/project/spreadsheet/components/virtualCell/manyToManyCell.vue @@ -246,7 +246,7 @@ export default { // this.list = await this.c hildApi.paginatedList({}) }, async addChildToParent(child) { - if (this.isNew) { + if (this.isNew && this.localState.every(it => it[this.childForeignKey] !== child[this.childPrimaryKey])) { this.localState.push(child) this.newRecordModal = false; return diff --git a/packages/nc-gui/components/project/spreadsheet/helpers/uiTypes.js b/packages/nc-gui/components/project/spreadsheet/helpers/uiTypes.js index 2676e473db..6e2195c72f 100644 --- a/packages/nc-gui/components/project/spreadsheet/helpers/uiTypes.js +++ b/packages/nc-gui/components/project/spreadsheet/helpers/uiTypes.js @@ -1,37 +1,3 @@ -export default [ - 'ID', - 'ForeignKey', - 'SingleLineText', - 'LongText', - 'Attachment', - 'Checkbox', - 'MultiSelect', - 'SingleSelect', - 'Collaborator', - 'Date', - 'Year', - 'Time', - 'PhoneNumber', - 'Email', - 'URL', - 'Number', - 'Decimal', - 'Currency', - 'Percent', - 'Duration', - 'Rating', - 'Formula', - 'Rollup', - 'Count', - 'Lookup', - 'DateTime', - 'CreateTime', - 'LastModifiedTime', - 'AutoNumber', - 'Barcode', - 'Button', - 'SpecificDBType', -] const uiTypes = [ @@ -40,11 +6,11 @@ const uiTypes = [ icon: 'mdi-identifier', }, { - name: 'ForeignKey', + name: 'LinkToAnotherRecord', icon: 'mdi-link-variant', }, { - name: 'LinkToAnotherRecord', + name: 'ForeignKey', icon: 'mdi-link-variant', }, { @@ -177,6 +143,40 @@ const uiTypes = [ export { uiTypes } +export default [ + 'ID', + 'ForeignKey', + 'SingleLineText', + 'LongText', + 'Attachment', + 'Checkbox', + 'MultiSelect', + 'SingleSelect', + 'Collaborator', + 'Date', + 'Year', + 'Time', + 'PhoneNumber', + 'Email', + 'URL', + 'Number', + 'Decimal', + 'Currency', + 'Percent', + 'Duration', + 'Rating', + 'Formula', + 'Rollup', + 'Count', + 'Lookup', + 'DateTime', + 'CreateTime', + 'LastModifiedTime', + 'AutoNumber', + 'Barcode', + 'Button', + 'SpecificDBType', +] /** * @copyright Copyright (c) 2021, Xgene Cloud Ltd