Browse Source

fix(gui): has many new column relation add

Signed-off-by: Pranav C <61551451+pranavxc@users.noreply.github.com>
pull/350/head
Pranav C 3 years ago
parent
commit
8956c7ef76
  1. 11
      packages/nc-gui/components/project/spreadsheet/components/virtualCell/hasManyCell.vue
  2. 2
      packages/nc-gui/components/project/spreadsheet/components/virtualCell/manyToManyCell.vue
  3. 72
      packages/nc-gui/components/project/spreadsheet/helpers/uiTypes.js

11
packages/nc-gui/components/project/spreadsheet/components/virtualCell/hasManyCell.vue

@ -89,7 +89,7 @@
:has-many="childMeta.hasMany" :has-many="childMeta.hasMany"
:belongs-to="childMeta.belongsTo" :belongs-to="childMeta.belongsTo"
@cancel="selectedChild = null" @cancel="selectedChild = null"
@input="$emit('loadTableData')" @input="onChildSave"
:table="childMeta.tn" :table="childMeta.tn"
v-model="selectedChild" v-model="selectedChild"
:old-row="{...selectedChild}" :old-row="{...selectedChild}"
@ -169,6 +169,13 @@ export default {
await this.loadChildMeta() await this.loadChildMeta()
}, },
methods: { methods: {
onChildSave() {
if (this.isNew) {
this.addChildToParent(this.selectedChild)
} else {
this.$emit('loadTableData')
}
},
async showChildListModal() { async showChildListModal() {
await this.loadChildMeta(); await this.loadChildMeta();
this.childListModal = true; this.childListModal = true;
@ -241,7 +248,7 @@ export default {
this.newRecordModal = true; this.newRecordModal = true;
}, },
async addChildToParent(child) { async addChildToParent(child) {
if (this.isNew) { if (this.isNew && this.localState.every(it => it[this.childForeignKey] !== child[this.childPrimaryKey])) {
this.localState.push(child); this.localState.push(child);
this.newRecordModal = false; this.newRecordModal = false;
return; return;

2
packages/nc-gui/components/project/spreadsheet/components/virtualCell/manyToManyCell.vue

@ -246,7 +246,7 @@ export default {
// this.list = await this.c hildApi.paginatedList({}) // this.list = await this.c hildApi.paginatedList({})
}, },
async addChildToParent(child) { async addChildToParent(child) {
if (this.isNew) { if (this.isNew && this.localState.every(it => it[this.childForeignKey] !== child[this.childPrimaryKey])) {
this.localState.push(child) this.localState.push(child)
this.newRecordModal = false; this.newRecordModal = false;
return return

72
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 = [ const uiTypes = [
@ -40,11 +6,11 @@ const uiTypes = [
icon: 'mdi-identifier', icon: 'mdi-identifier',
}, },
{ {
name: 'ForeignKey', name: 'LinkToAnotherRecord',
icon: 'mdi-link-variant', icon: 'mdi-link-variant',
}, },
{ {
name: 'LinkToAnotherRecord', name: 'ForeignKey',
icon: 'mdi-link-variant', icon: 'mdi-link-variant',
}, },
{ {
@ -177,6 +143,40 @@ const uiTypes = [
export { export {
uiTypes 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 * @copyright Copyright (c) 2021, Xgene Cloud Ltd

Loading…
Cancel
Save