Browse Source

fix: save relation column data fro newly created row by using `nestedAdd` method

re #1696

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/1697/head
Pranav C 3 years ago
parent
commit
3bb41d7ba0
  1. 17
      packages/nc-gui/components/project/spreadsheet/components/virtualCell/hasManyCell.vue
  2. 16
      packages/nc-gui/components/project/spreadsheet/components/virtualCell/manyToManyCell.vue

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

@ -442,15 +442,18 @@ export default {
// eslint-disable-next-line no-cond-assign
while (child = this.localState.pop()) {
if (row) {
// todo: use common method
const pid = this.meta.columns.filter(c => c.pk).map(c => row[c.title]).join('___')
const id = this.childMeta.columns.filter(c => c.pk).map(c => child[c.title]).join('___')
const title = this.childForeignKey
await this.childApi.update(id, {
[title]: parseIfInteger(pid)
}, {
[title]: child[this.childForeignKey]
})
await this.$api.dbTableRow.nestedAdd(
'noco',
this.projectName,
this.meta.title,
pid,
'hm',
this.column.title,
id
)
} else {
await this.addChildToParent(child)
}

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

@ -461,16 +461,18 @@ export default {
// eslint-disable-next-line no-cond-assign
while (child = this.localState.pop()) {
if (row) {
// todo: use common method
const cid = this.childMeta.columns.filter(c => c.pk).map(c => child[c.title]).join('___')
const pid = this.meta.columns.filter(c => c.pk).map(c => row[c.title]).join('___')
const vcidCol = this.assocMeta.columns.find(c => c.id === this.column.colOptions.fk_mm_parent_column_id).title
const vpidCol = this.assocMeta.columns.find(c => c.id === this.column.colOptions.fk_mm_child_column_id).title
await this.assocApi.insert({
[vcidCol]: parseIfInteger(cid),
[vpidCol]: parseIfInteger(pid)
})
await this.$api.dbTableRow.nestedAdd(
'noco',
this.projectName,
this.meta.title,
pid,
'mm',
this.column.title,
cid
)
} else {
await this.addChildToParent(child)
}

Loading…
Cancel
Save