2023-04-07 15:39:53 +00:00
|
|
|
import { AnyAttribute, Client } from '@hcengineering/core'
|
2021-12-30 09:04:32 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface KeyedAttribute {
|
|
|
|
key: string
|
|
|
|
attr: AnyAttribute
|
|
|
|
}
|
|
|
|
|
2023-04-07 15:39:53 +00:00
|
|
|
export { updateAttribute } from '@hcengineering/core'
|
2021-12-30 09:04:32 +00:00
|
|
|
|
|
|
|
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)) {
|
2023-03-24 10:23:44 +00:00
|
|
|
return (client.getHierarchy().as(object, key.attr.attributeOf) as any)[key.key]
|
2021-12-30 09:04:32 +00:00
|
|
|
} else {
|
|
|
|
return object[key.key]
|
|
|
|
}
|
|
|
|
}
|