waibu-mpa 2.14.0 → 2.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/class/widget.js +14 -5
- package/package.json +1 -1
- package/wiki/CHANGES.md +5 -0
package/lib/class/widget.js
CHANGED
|
@@ -108,8 +108,8 @@ async function widgetFactory () {
|
|
|
108
108
|
const { get, find } = this.app.lib._
|
|
109
109
|
const prop = find(this.schema.properties ?? [], p => p.name === field)
|
|
110
110
|
if (!prop) return {}
|
|
111
|
-
if (!refName
|
|
112
|
-
const key = this.params.attr.refName
|
|
111
|
+
if (!refName) refName = this.getRefName(field)
|
|
112
|
+
const key = refName ?? this.params.attr.refName
|
|
113
113
|
const ref = get(prop, `ref.${key}`, {})
|
|
114
114
|
if (returning === 'all') return { ref, key }
|
|
115
115
|
else if (returning === 'key') return key
|
|
@@ -125,9 +125,18 @@ async function widgetFactory () {
|
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
getRefName = (field) => {
|
|
128
|
-
const { get } = this.app.lib._
|
|
129
|
-
|
|
130
|
-
if (!
|
|
128
|
+
const { get, find } = this.app.lib._
|
|
129
|
+
const prop = find(this.schema.properties ?? [], p => p.name === field) ?? {}
|
|
130
|
+
if (!prop.ref) return
|
|
131
|
+
const keys = Object.keys(prop.ref)
|
|
132
|
+
let refName = get(this.schema, `view.widget.${field}.attr.refName`, this.params.attr.refName)
|
|
133
|
+
if (!refName) {
|
|
134
|
+
if (keys.includes(field)) refName = field
|
|
135
|
+
else if (field.endsWith('Id')) {
|
|
136
|
+
refName = field.slice(0, -2)
|
|
137
|
+
refName = keys.includes(refName) ? refName : undefined
|
|
138
|
+
}
|
|
139
|
+
}
|
|
131
140
|
return refName
|
|
132
141
|
}
|
|
133
142
|
|
package/package.json
CHANGED
package/wiki/CHANGES.md
CHANGED