diff --git a/models/setting/src/index.ts b/models/setting/src/index.ts index acb16b8a68..112849a0aa 100644 --- a/models/setting/src/index.ts +++ b/models/setting/src/index.ts @@ -465,11 +465,22 @@ export function createModel (builder: Builder): void { templates.class.TemplateField, core.space.Model, { - label: setting.string.Owner, + label: setting.string.OwnerFirstName, category: setting.templateFieldCategory.Integration, - func: setting.function.GetOwnerName + func: setting.function.GetOwnerFirstName }, - setting.templateField.OwnerName + setting.templateField.OwnerFirstName + ) + + builder.createDoc( + templates.class.TemplateField, + core.space.Model, + { + label: setting.string.OwnerLastName, + category: setting.templateFieldCategory.Integration, + func: setting.function.GetOwnerLastName + }, + setting.templateField.OwnerLastName ) builder.createDoc( diff --git a/models/setting/src/plugin.ts b/models/setting/src/plugin.ts index bb08c8fdf8..70b45c3346 100644 --- a/models/setting/src/plugin.ts +++ b/models/setting/src/plugin.ts @@ -64,7 +64,8 @@ export default mergeIds(settingId, setting, { }, function: { GetValue: '' as Resource, - GetOwnerName: '' as Resource, + GetOwnerFirstName: '' as Resource, + GetOwnerLastName: '' as Resource, GetOwnerPosition: '' as Resource } }) diff --git a/plugins/setting-assets/lang/en.json b/plugins/setting-assets/lang/en.json index 38765024b0..3b31716bb0 100644 --- a/plugins/setting-assets/lang/en.json +++ b/plugins/setting-assets/lang/en.json @@ -57,6 +57,8 @@ "User": "User", "Maintainer": "Maintainer", "Owner": "Owner", + "OwnerFirstName": "Owner's First name", + "OwnerLastName": "Owner's Last name", "Role": "Role", "FailedToSave": "Failed to update password", "ImportEnum": "Import enum values", diff --git a/plugins/setting-assets/lang/ru.json b/plugins/setting-assets/lang/ru.json index 817d86368d..c369e8dab7 100644 --- a/plugins/setting-assets/lang/ru.json +++ b/plugins/setting-assets/lang/ru.json @@ -57,6 +57,8 @@ "User": "Пользователь", "Maintainer": "Maintainer", "Owner": "Владелец", + "OwnerFirstName": "Имя владельца", + "OwnerLastName": "Фамилия владельца", "Role": "Роль", "FailedToSave": "Не удалось обновить пароль", "ImportEnum": "Загрузить значения справочника", diff --git a/plugins/setting-resources/src/index.ts b/plugins/setting-resources/src/index.ts index 0f50a74d24..56da94ca69 100644 --- a/plugins/setting-resources/src/index.ts +++ b/plugins/setting-resources/src/index.ts @@ -45,7 +45,7 @@ import InviteSetting from './components/InviteSetting.svelte' import Configure from './components/Configure.svelte' import setting from './plugin' import IntegrationPanel from './components/IntegrationPanel.svelte' -import { getOwnerName, getOwnerPosition, getValue } from './utils' +import { getOwnerFirstName, getOwnerLastName, getOwnerPosition, getValue } from './utils' export { ClassSetting } @@ -106,7 +106,8 @@ export default async (): Promise => ({ DeleteMixin }, function: { - GetOwnerName: getOwnerName, + GetOwnerFirstName: getOwnerFirstName, + GetOwnerLastName: getOwnerLastName, GetOwnerPosition: getOwnerPosition, GetValue: getValue } diff --git a/plugins/setting-resources/src/plugin.ts b/plugins/setting-resources/src/plugin.ts index 5dfd5a4ccc..0bc7d56089 100644 --- a/plugins/setting-resources/src/plugin.ts +++ b/plugins/setting-resources/src/plugin.ts @@ -51,6 +51,8 @@ export default mergeIds(settingId, setting, { User: '' as IntlString, Maintainer: '' as IntlString, Owner: '' as IntlString, + OwnerFirstName: '' as IntlString, + OwnerLastName: '' as IntlString, Role: '' as IntlString, FailedToSave: '' as IntlString, ImportEnum: '' as IntlString, diff --git a/plugins/setting-resources/src/utils.ts b/plugins/setting-resources/src/utils.ts index 624df2c68f..610d9a68b3 100644 --- a/plugins/setting-resources/src/utils.ts +++ b/plugins/setting-resources/src/utils.ts @@ -1,4 +1,4 @@ -import contact, { EmployeeAccount, getName } from '@hcengineering/contact' +import contact, { EmployeeAccount, getFirstName, getLastName } from '@hcengineering/contact' import { employeeByIdStore } from '@hcengineering/contact-resources' import { Class, Doc, Hierarchy, Ref } from '@hcengineering/core' import { getClient } from '@hcengineering/presentation' @@ -57,7 +57,7 @@ export async function getValue (provider: TemplateDataProvider): Promise { +export async function getOwnerFirstName (provider: TemplateDataProvider): Promise { const value = provider.get(setting.class.Integration) if (value === undefined) return const client = getClient() @@ -66,7 +66,20 @@ export async function getOwnerName (provider: TemplateDataProvider): Promise { + const value = provider.get(setting.class.Integration) + if (value === undefined) return + const client = getClient() + const employeeAccount = await client.findOne(contact.class.EmployeeAccount, { + _id: value.modifiedBy as Ref + }) + if (employeeAccount !== undefined) { + const employee = get(employeeByIdStore).get(employeeAccount.employee) + return employee != null ? getLastName(employee.name) : undefined } } diff --git a/plugins/setting/src/index.ts b/plugins/setting/src/index.ts index be3504ece8..de9a22aacd 100644 --- a/plugins/setting/src/index.ts +++ b/plugins/setting/src/index.ts @@ -181,7 +181,8 @@ export default plugin(settingId, { Integration: '' as Ref }, templateField: { - OwnerName: '' as Ref, + OwnerFirstName: '' as Ref, + OwnerLastName: '' as Ref, OwnerPosition: '' as Ref, Value: '' as Ref }