Browse Source

fix: bt & hm cells

Signed-off-by: Wing-Kam Wong <wingkwong.code@gmail.com>
pull/1333/head
Wing-Kam Wong 3 years ago
parent
commit
0be903f8df
  1. 20
      packages/nc-gui/components/project/spreadsheet/components/virtualCell/belongsToCell.vue
  2. 11
      packages/nc-gui/components/project/spreadsheet/components/virtualCell/hasManyCell.vue

20
packages/nc-gui/components/project/spreadsheet/components/virtualCell/belongsToCell.vue

@ -34,7 +34,10 @@
:primary-col="parentPrimaryCol" :primary-col="parentPrimaryCol"
:primary-key="parentPrimaryKey" :primary-key="parentPrimaryKey"
:api="parentApi" :api="parentApi"
:query-params="parentQueryParams" :query-params="{
...parentQueryParams,
where: isNew ? null :`~not(${parentPrimaryKey},eq,${parentId})~or(${parentPrimaryKey},is,null)`,
}"
:is-public="isPublic" :is-public="isPublic"
:tn="bt && bt.rtn" :tn="bt && bt.rtn"
:password="password" :password="password"
@ -165,13 +168,24 @@ export default {
// : null // : null
}, },
parentId() { 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() { parentPrimaryCol() {
return this.parentMeta && (this.parentMeta.columns.find(c => c.pv) || {})._cn return this.parentMeta && (this.parentMeta.columns.find(c => c.pv) || {})._cn
}, },
parentPrimaryKey() { 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() { parentQueryParams() {
if (!this.parentMeta) { if (!this.parentMeta) {

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

@ -54,7 +54,7 @@
:parent-meta="meta" :parent-meta="meta"
:query-params="{ :query-params="{
...childQueryParams, ...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" :is-public="isPublic"
:password="password" :password="password"
@ -80,7 +80,7 @@
:column="column" :column="column"
:query-params="{ :query-params="{
...childQueryParams, ...childQueryParams,
where: `(${childForeignKey},eq,${childForeignKeyVal != '' ? childForeignKeyVal : parentId})` where: `(${childForeignKey},eq,${parentId})`
}" }"
:is-public="isPublic" :is-public="isPublic"
:row-id="parentId" :row-id="parentId"
@ -251,11 +251,10 @@ export default {
} }
}, },
parentId() { 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: { watch: {
isNew(n, o) { isNew(n, o) {

Loading…
Cancel
Save