Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov 2022-10-31 17:57:49 +06:00 committed by GitHub
parent 242b3dc96e
commit b600d736b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 17 deletions

View File

@ -147,21 +147,18 @@
const result = getBaseConfig(viewlet) const result = getBaseConfig(viewlet)
const allAttributes = hierarchy.getAllAttributes(viewlet.attachTo) const allAttributes = hierarchy.getAllAttributes(viewlet.attachTo)
for (const [, attribute] of allAttributes) { for (const [, attribute] of allAttributes) {
processAttribute(attribute, result) processAttribute(attribute, result)
} }
hierarchy hierarchy.getDescendants(viewlet.attachTo).forEach((it) => {
.getDescendants(viewlet.attachTo) const ancestor = hierarchy.getAncestors(it)[1]
.filter((it) => hierarchy.isMixin(it)) hierarchy.getAllAttributes(it, ancestor).forEach((attr) => {
.forEach((it) => if (attr.isCustom === true) {
hierarchy.getAllAttributes(it, viewlet.attachTo).forEach((attr) => { processAttribute(attr, result, true)
if (attr.isCustom === true) { }
processAttribute(attr, result, true) })
} })
})
)
return preference === undefined ? result : setStatus(result, preference) return preference === undefined ? result : setStatus(result, preference)
} }

View File

@ -53,8 +53,9 @@
} }
: {} : {}
let prefix = '' let prefix = ''
const attr = client.getHierarchy().getAttribute(filter.key._class, filter.key.key) const hieararchy = client.getHierarchy()
if (client.getHierarchy().isMixin(attr.attributeOf)) { const attr = hieararchy.getAttribute(filter.key._class, filter.key.key)
if (hieararchy.isMixin(attr.attributeOf)) {
prefix = attr.attributeOf + '.' prefix = attr.attributeOf + '.'
console.log('prefix', prefix) console.log('prefix', prefix)
} }
@ -66,8 +67,8 @@
for (const object of res) { for (const object of res) {
let asDoc = object let asDoc = object
if (client.getHierarchy().isMixin(filter.key._class)) { if (hieararchy.isMixin(filter.key._class)) {
asDoc = client.getHierarchy().as(object, filter.key._class) asDoc = hieararchy.as(object, filter.key._class)
} }
const realValue = getObjectValue(filter.key.key, asDoc) const realValue = getObjectValue(filter.key.key, asDoc)
const value = getValue(realValue) const value = getValue(realValue)

View File

@ -240,7 +240,7 @@ export async function buildModel (options: BuildModelOptions): Promise<Attribute
const pos = key.key.lastIndexOf('.') const pos = key.key.lastIndexOf('.')
if (pos !== -1) { if (pos !== -1) {
const mixinName = key.key.substring(0, pos) as Ref<Class<Doc>> const mixinName = key.key.substring(0, pos) as Ref<Class<Doc>>
if (options.client.getHierarchy().isMixin(mixinName)) { if (!mixinName.includes('$lookup')) {
const realKey = key.key.substring(pos + 1) const realKey = key.key.substring(pos + 1)
const rkey = { ...key, key: realKey } const rkey = { ...key, key: realKey }
return { return {
@ -251,7 +251,6 @@ export async function buildModel (options: BuildModelOptions): Promise<Attribute
} }
} }
} }
return await getPresenter(options.client, options._class, key, key, options.lookup) return await getPresenter(options.client, options._class, key, key, options.lookup)
} catch (err: any) { } catch (err: any) {
if (options.ignoreMissing ?? false) { if (options.ignoreMissing ?? false) {