platform/packages/presentation/src/attributes.ts
Andrey Sobolev 1ad84330cd
TSK-1062: Fix merge properly (#2919)
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
2023-04-07 21:39:53 +06:00

21 lines
532 B
TypeScript

import { AnyAttribute, Client } from '@hcengineering/core'
/**
* @public
*/
export interface KeyedAttribute {
key: string
attr: AnyAttribute
}
export { updateAttribute } from '@hcengineering/core'
export function getAttribute (client: Client, object: any, key: KeyedAttribute): any {
// Check if attr is mixin and return it's value
if (client.getHierarchy().isMixin(key.attr.attributeOf)) {
return (client.getHierarchy().as(object, key.attr.attributeOf) as any)[key.key]
} else {
return object[key.key]
}
}