do not use lookup if RefPresenter is set (#6289)

Signed-off-by: Vyacheslav Tumanov <me@slavatumanov.me>
This commit is contained in:
Vyacheslav Tumanov 2024-08-08 19:32:25 +05:00 committed by GitHub
parent 96b73dff9c
commit c752b20321
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -148,13 +148,14 @@
return result
}
function getValue (name: string, type: Type<any>): string {
function getValue (name: string, type: Type<any>, attrClass: Ref<Class<Doc>>): string {
const presenter = hierarchy.classHierarchyMixin(attrClass, view.mixin.AttributePresenter)?.presenter
if (presenter !== undefined) {
return name
}
if (hierarchy.isDerived(type._class, core.class.RefTo)) {
return '$lookup.' + name
}
// if (hierarchy.isDerived(type._class, core.class.ArrOf)) {
// return getValue(name, (type as ArrOf<any>).of)
// }
return name
}
@ -162,14 +163,14 @@
if (attribute.hidden === true || attribute.label === undefined) return
if (viewlet.configOptions?.hiddenKeys?.includes(attribute.name)) return
if (hierarchy.isDerived(attribute.type._class, core.class.Collection)) return
const value = getValue(attribute.name, attribute.type)
const { attrClass, category } = getAttributePresenterClass(hierarchy, attribute)
const value = getValue(attribute.name, attribute.type, attrClass)
for (const res of result) {
const key = typeof res.value === 'string' ? res.value : res.value?.key
if (key === undefined) return
if (key === attribute.name) return
if (key === value) return
}
const { attrClass, category } = getAttributePresenterClass(hierarchy, attribute)
const mixin =
category === 'object'
? view.mixin.ObjectPresenter