Fix view settings (#10706)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov
2026-03-30 22:43:47 +05:00
committed by GitHub
parent c3079951a8
commit d09f05acb4
3 changed files with 12 additions and 14 deletions
@@ -158,11 +158,10 @@
if (hierarchy.isDerived(attribute.type._class, core.class.Collection)) return
const { attrClass, category } = getAttributePresenterClass(hierarchy, attribute.type)
const value = getValue(attribute.name, attribute.type, attrClass)
const proxiedValue = attribute.attributeOf + '.' + attribute.name
for (const res of result) {
const key = getKey(res.value)
if (key === undefined) continue
if (key === attribute.name || key === value || key === proxiedValue) return
if (key === attribute.name || key === value) return
if (key === '' && isAttribute(res) && res.label === attribute.label) return
}
const mixin =
@@ -235,19 +234,12 @@
function getConfig (viewlet: Viewlet, preference: ViewletPreference | undefined): Config[] {
const result = getBaseConfig(viewlet)
if (viewlet.configOptions?.strict !== true) {
const allAttributes = hierarchy.getAllAttributes(viewlet.attachTo)
for (const [, attribute] of allAttributes) {
processAttribute(attribute, result)
}
hierarchy.getDescendants(viewlet.attachTo).forEach((it) => {
hierarchy.getOwnAttributes(it).forEach((attr) => {
processAttribute(attr, result, true)
})
})
const desc = hierarchy.getDescendants(viewlet.attachTo)
for (const d of desc) {
if (!hierarchy.isMixin(d)) continue
@@ -196,11 +196,10 @@
if (hierarchy.isDerived(attribute.type._class, core.class.Collection)) return
const { attrClass, category } = getAttributePresenterClass(hierarchy, attribute.type)
const value = getValue(attribute.name, attribute.type, attrClass)
const proxiedValue = attribute.attributeOf + '.' + attribute.name
for (const res of result) {
const key = getKey(res.value)
if (key === undefined) continue
if (key === attribute.name || key === value || key === proxiedValue) return
if (key === attribute.name || key === value) return
if (key === '' && isAttribute(res) && res.label === attribute.label) return
}
const mixin =
+10 -3
View File
@@ -1172,11 +1172,13 @@ export function canResolveAttribute<T extends Doc> (
}
}
if (key.length === 0) return true
try {
const parts = key.split('.')
if (parts.length === 1) {
return hierarchy.findAttribute(_class, key) !== undefined
} catch {
return false
} else if (hierarchy.isDerived(parts[0] as Ref<Class<Doc>>, _class)) {
return hierarchy.findAttribute(parts[0] as Ref<Class<Doc>>, parts[1]) !== undefined
}
return false
}
export function getKeyLabel<T extends Doc> (
@@ -1206,6 +1208,11 @@ export function getKeyLabel<T extends Doc> (
const clazz = client.getHierarchy().getClass(_class)
return clazz.label
} else {
const parts = key.split('.')
if (parts.length === 2 && client.getHierarchy().isDerived(parts[0] as Ref<Class<Doc>>, _class)) {
const attribute = client.getHierarchy().getAttribute(parts[0] as Ref<Class<Doc>>, parts[1])
return attribute.label
}
const attribute = client.getHierarchy().getAttribute(_class, key)
return attribute.label
}