Skip to content

Commit

Permalink
parentRelationFieldName
Browse files Browse the repository at this point in the history
  • Loading branch information
szuprefix committed Aug 20, 2021
1 parent e984d51 commit 0690dcb
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/components/model/Table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
}
},
parent: Object,
parentMultipleRelationFieldName: String,
options: {
type: Object,
default: () => {
Expand Down Expand Up @@ -299,6 +300,9 @@
let f = this.parentMultipleRelationField
if (f) {
let ids = parent.data[f.name]
if(typeof ids === 'string' && ids.startsWith('[')){
ids = JSON.parse(ids)
}
r['id__in'] = ids.length > 0 && ids || [0]
} else {
let am = parent.appModel
Expand Down Expand Up @@ -350,6 +354,9 @@
parentMultipleRelationField () {
if (this.parent) {
let pfs = Object.values(this.parent.fieldConfigs)
if(this.parentMultipleRelationFieldName) {
return pfs.find(a => a.name === this.parentMultipleRelationFieldName)
}
let f = pfs.find(a => a.model === this.model.appModel)
if (f && f.multiple === true) {
return f
Expand Down

0 comments on commit 0690dcb

Please sign in to comment.