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 4 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"
: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;

2
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

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 = [
@ -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

Loading…
Cancel
Save