mirror of
https://github.com/hcengineering/platform.git
synced 2024-12-22 19:11:33 +03:00
TSK-1257: Split owner name to first and last name fields (#3156)
Signed-off-by: Vyacheslav Tumanov <me@slavatumanov.me>
This commit is contained in:
parent
f136bdff42
commit
8c50419027
@ -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(
|
||||
|
@ -64,7 +64,8 @@ export default mergeIds(settingId, setting, {
|
||||
},
|
||||
function: {
|
||||
GetValue: '' as Resource<TemplateFieldFunc>,
|
||||
GetOwnerName: '' as Resource<TemplateFieldFunc>,
|
||||
GetOwnerFirstName: '' as Resource<TemplateFieldFunc>,
|
||||
GetOwnerLastName: '' as Resource<TemplateFieldFunc>,
|
||||
GetOwnerPosition: '' as Resource<TemplateFieldFunc>
|
||||
}
|
||||
})
|
||||
|
@ -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",
|
||||
|
@ -57,6 +57,8 @@
|
||||
"User": "Пользователь",
|
||||
"Maintainer": "Maintainer",
|
||||
"Owner": "Владелец",
|
||||
"OwnerFirstName": "Имя владельца",
|
||||
"OwnerLastName": "Фамилия владельца",
|
||||
"Role": "Роль",
|
||||
"FailedToSave": "Не удалось обновить пароль",
|
||||
"ImportEnum": "Загрузить значения справочника",
|
||||
|
@ -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<Resources> => ({
|
||||
DeleteMixin
|
||||
},
|
||||
function: {
|
||||
GetOwnerName: getOwnerName,
|
||||
GetOwnerFirstName: getOwnerFirstName,
|
||||
GetOwnerLastName: getOwnerLastName,
|
||||
GetOwnerPosition: getOwnerPosition,
|
||||
GetValue: getValue
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -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<string
|
||||
return value.value
|
||||
}
|
||||
|
||||
export async function getOwnerName (provider: TemplateDataProvider): Promise<string | undefined> {
|
||||
export async function getOwnerFirstName (provider: TemplateDataProvider): Promise<string | undefined> {
|
||||
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<str
|
||||
})
|
||||
if (employeeAccount !== undefined) {
|
||||
const employee = get(employeeByIdStore).get(employeeAccount.employee)
|
||||
return employee != null ? getName(employee) : undefined
|
||||
return employee != null ? getFirstName(employee.name) : undefined
|
||||
}
|
||||
}
|
||||
|
||||
export async function getOwnerLastName (provider: TemplateDataProvider): Promise<string | undefined> {
|
||||
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<EmployeeAccount>
|
||||
})
|
||||
if (employeeAccount !== undefined) {
|
||||
const employee = get(employeeByIdStore).get(employeeAccount.employee)
|
||||
return employee != null ? getLastName(employee.name) : undefined
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -181,7 +181,8 @@ export default plugin(settingId, {
|
||||
Integration: '' as Ref<TemplateFieldCategory>
|
||||
},
|
||||
templateField: {
|
||||
OwnerName: '' as Ref<TemplateField>,
|
||||
OwnerFirstName: '' as Ref<TemplateField>,
|
||||
OwnerLastName: '' as Ref<TemplateField>,
|
||||
OwnerPosition: '' as Ref<TemplateField>,
|
||||
Value: '' as Ref<TemplateField>
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user