mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-13 13:17:45 +02:00
Fillable templates (#2667)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
import contact, { EmployeeAccount, formatName } from '@hcengineering/contact'
|
||||
import { Class, Doc, Hierarchy, Ref } from '@hcengineering/core'
|
||||
import setting from '@hcengineering/setting'
|
||||
import { getClient } from '@hcengineering/presentation'
|
||||
import setting, { Integration } from '@hcengineering/setting'
|
||||
import { TemplateDataProvider } from '@hcengineering/templates'
|
||||
|
||||
function isEditable (hierarchy: Hierarchy, p: Class<Doc>): boolean {
|
||||
let ancestors = [p._id]
|
||||
@@ -45,3 +48,19 @@ export function filterDescendants (
|
||||
|
||||
return _classes.map((p) => p._id)
|
||||
}
|
||||
|
||||
export async function getValue (provider: TemplateDataProvider): Promise<string | undefined> {
|
||||
const value = provider.get(setting.templateFieldCategory.Integration) as Integration
|
||||
if (value === undefined) return
|
||||
return value.value
|
||||
}
|
||||
|
||||
export async function getOwnerName (provider: TemplateDataProvider): Promise<string | undefined> {
|
||||
const value = provider.get(setting.templateFieldCategory.Integration) as Integration
|
||||
if (value === undefined) return
|
||||
const client = getClient()
|
||||
const employeeAccount = await client.findOne(contact.class.EmployeeAccount, {
|
||||
_id: value.modifiedBy as Ref<EmployeeAccount>
|
||||
})
|
||||
return employeeAccount != null ? formatName(employeeAccount.name) : undefined
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user