mirror of
https://github.com/hcengineering/platform.git
synced 2025-02-13 14:57:59 +00:00
21 lines
541 B
TypeScript
21 lines
541 B
TypeScript
import { type AnyAttribute, type 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 its 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]
|
|
}
|
|
}
|