mirror of
https://github.com/hcengineering/platform.git
synced 2025-02-08 03:47:20 +00:00
1ad84330cd
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
21 lines
532 B
TypeScript
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]
|
|
}
|
|
}
|