mirror of
https://github.com/hcengineering/platform.git
synced 2026-10-01 22:15:04 +02:00
Fix view settings (#10706)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
@@ -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 =
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user