diff --git a/packages/nc-gui/components/project/spreadsheet/components/virtualCell/belongsToCell.vue b/packages/nc-gui/components/project/spreadsheet/components/virtualCell/belongsToCell.vue index a3b81a0fb7..111d2529e2 100644 --- a/packages/nc-gui/components/project/spreadsheet/components/virtualCell/belongsToCell.vue +++ b/packages/nc-gui/components/project/spreadsheet/components/virtualCell/belongsToCell.vue @@ -34,7 +34,10 @@ :primary-col="parentPrimaryCol" :primary-key="parentPrimaryKey" :api="parentApi" - :query-params="parentQueryParams" + :query-params="{ + ...parentQueryParams, + where: isNew ? null :`~not(${parentPrimaryKey},eq,${parentId})~or(${parentPrimaryKey},is,null)`, + }" :is-public="isPublic" :tn="bt && bt.rtn" :password="password" @@ -165,13 +168,24 @@ export default { // : null }, parentId() { - return this.pid ?? (this.value && this.parentMeta && this.parentMeta.columns.filter(c => c.pk).map(c => this.value[c._cn]).join('___')) + return this.pid ?? + ((this.parentMeta.columns + .filter(c => c._cn === (this.parentMeta && (this.parentMeta.columns.find(c => c.cn === this.bt.cn) || {})._cn)) + .map(c => this.value[c._cn]).join('___')) || + (this.value && this.parentMeta && this.parentMeta.columns.filter(c => c.pk).map(c => this.value[c._cn]).join('___'))) }, parentPrimaryCol() { return this.parentMeta && (this.parentMeta.columns.find(c => c.pv) || {})._cn }, parentPrimaryKey() { - return this.parentMeta && (this.parentMeta.columns.find(c => c.pk) || {})._cn + // ((this.parentMeta.columns + // .filter(c => c._cn === (this.parentMeta && (this.parentMeta.columns.find(c => c.cn === this.bt.cn) || {})._cn)) + // .map(c => this.value[c._cn]).join('___')) + + console.log((this.parentMeta && (this.parentMeta.columns.find(c => c.cn === this.bt.cn) || {})._cn) || + (this.parentMeta && (this.parentMeta.columns.find(c => c.pk) || {})._cn)) + return (this.parentMeta && (this.parentMeta.columns.find(c => c.cn === this.bt.cn) || {})._cn) || + (this.parentMeta && (this.parentMeta.columns.find(c => c.pk) || {})._cn) }, parentQueryParams() { if (!this.parentMeta) { 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 7921571148..05ad634bb7 100644 --- a/packages/nc-gui/components/project/spreadsheet/components/virtualCell/hasManyCell.vue +++ b/packages/nc-gui/components/project/spreadsheet/components/virtualCell/hasManyCell.vue @@ -54,7 +54,7 @@ :parent-meta="meta" :query-params="{ ...childQueryParams, - where: isNew ? null :`~not(${childForeignKey},eq,${childForeignKeyVal != '' ? childForeignKeyVal : parentId})~or(${childForeignKey},is,null)`, + where: isNew ? null :`~not(${childForeignKey},eq,${parentId})~or(${childForeignKey},is,null)`, }" :is-public="isPublic" :password="password" @@ -80,7 +80,7 @@ :column="column" :query-params="{ ...childQueryParams, - where: `(${childForeignKey},eq,${childForeignKeyVal != '' ? childForeignKeyVal : parentId})` + where: `(${childForeignKey},eq,${parentId})` }" :is-public="isPublic" :row-id="parentId" @@ -251,11 +251,10 @@ export default { } }, parentId() { - return this.meta && this.meta.columns ? this.meta.columns.filter(c => c.pk).map(c => this.row[c._cn]).join('___') : '' + return (this.meta && this.meta.columns && + (this.meta.columns.filter(c => c._cn === this.childForeignKey).map(c => this.row[c._cn]).join('___') || + this.meta.columns.filter(c => c.pk).map(c => this.row[c._cn]).join('___'))) || '' }, - childForeignKeyVal() { - return this.meta && this.meta.columns ? this.meta.columns.filter(c => c._cn === this.childForeignKey).map(c => this.row[c._cn]) : '' - } }, watch: { isNew(n, o) {