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 // eslint-disable-next-line no-cond-assign
while (child = this.localState.pop()) { while (child = this.localState.pop()) {
if (row) { if (row) {
// todo: use common method
const pid = this.meta.columns.filter(c => c.pk).map(c => row[c.title]).join('___') 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 id = this.childMeta.columns.filter(c => c.pk).map(c => child[c.title]).join('___')
const title = this.childForeignKey
await this.childApi.update(id, { await this.$api.dbTableRow.nestedAdd(
[title]: parseIfInteger(pid) 'noco',
}, { this.projectName,
[title]: child[this.childForeignKey] this.meta.title,
}) pid,
'hm',
this.column.title,
id
)
} else { } else {
await this.addChildToParent(child) 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 // eslint-disable-next-line no-cond-assign
while (child = this.localState.pop()) { while (child = this.localState.pop()) {
if (row) { if (row) {
// todo: use common method
const cid = this.childMeta.columns.filter(c => c.pk).map(c => child[c.title]).join('___') 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 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 await this.$api.dbTableRow.nestedAdd(
const vpidCol = this.assocMeta.columns.find(c => c.id === this.column.colOptions.fk_mm_child_column_id).title 'noco',
await this.assocApi.insert({ this.projectName,
[vcidCol]: parseIfInteger(cid), this.meta.title,
[vpidCol]: parseIfInteger(pid) pid,
}) 'mm',
this.column.title,
cid
)
} else { } else {
await this.addChildToParent(child) await this.addChildToParent(child)
} }

Loading…
Cancel
Save