mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-13 03:40:48 +00:00
Template first name (#2887)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
parent
17c9846720
commit
eb25bd2d3c
@ -689,6 +689,28 @@ export function createModel (builder: Builder): void {
|
||||
},
|
||||
contact.templateField.ContactName
|
||||
)
|
||||
|
||||
builder.createDoc(
|
||||
templates.class.TemplateField,
|
||||
core.space.Model,
|
||||
{
|
||||
label: contact.string.PersonFirstNamePlaceholder,
|
||||
category: contact.templateFieldCategory.Contact,
|
||||
func: contact.function.GetContactFirstName
|
||||
},
|
||||
contact.templateField.ContactFirstName
|
||||
)
|
||||
|
||||
builder.createDoc(
|
||||
templates.class.TemplateField,
|
||||
core.space.Model,
|
||||
{
|
||||
label: contact.string.PersonLastNamePlaceholder,
|
||||
category: contact.templateFieldCategory.Contact,
|
||||
func: contact.function.GetContactLastName
|
||||
},
|
||||
contact.templateField.ContactLastName
|
||||
)
|
||||
}
|
||||
|
||||
export { contactOperation } from './migration'
|
||||
|
@ -103,6 +103,8 @@ export default mergeIds(contactId, contact, {
|
||||
function: {
|
||||
GetCurrentEmployeeName: '' as Resource<TemplateFieldFunc>,
|
||||
GetCurrentEmployeeEmail: '' as Resource<TemplateFieldFunc>,
|
||||
GetContactName: '' as Resource<TemplateFieldFunc>
|
||||
GetContactName: '' as Resource<TemplateFieldFunc>,
|
||||
GetContactFirstName: '' as Resource<TemplateFieldFunc>,
|
||||
GetContactLastName: '' as Resource<TemplateFieldFunc>
|
||||
}
|
||||
})
|
||||
|
@ -12,7 +12,7 @@
|
||||
"PersonLastNamePlaceholder": "Фамилия",
|
||||
"PersonLocationPlaceholder": "Местоположение",
|
||||
"PersonsNamePlaceholder": "Папка",
|
||||
"Name": "Имя",
|
||||
"Name": "Полное имя",
|
||||
"SelectFolder": "Выбрать папку",
|
||||
"OrganizationsFolder": "Папка с организациями",
|
||||
"PersonsFolder": "Папка с людьми",
|
||||
|
@ -75,6 +75,8 @@ import {
|
||||
employeeSort,
|
||||
filterChannelInResult,
|
||||
filterChannelNinResult,
|
||||
getContactFirstName,
|
||||
getContactLastName,
|
||||
getContactLink,
|
||||
getContactName,
|
||||
getCurrentEmployeeEmail,
|
||||
@ -281,6 +283,8 @@ export default async (): Promise<Resources> => ({
|
||||
GetCurrentEmployeeName: getCurrentEmployeeName,
|
||||
GetCurrentEmployeeEmail: getCurrentEmployeeEmail,
|
||||
GetContactName: getContactName,
|
||||
GetContactFirstName: getContactFirstName,
|
||||
GetContactLastName: getContactLastName,
|
||||
GetContactLink: getContactLink
|
||||
},
|
||||
resolver: {
|
||||
|
@ -23,6 +23,8 @@ import {
|
||||
Employee,
|
||||
EmployeeAccount,
|
||||
formatName,
|
||||
getFirstName,
|
||||
getLastName,
|
||||
getName
|
||||
} from '@hcengineering/contact'
|
||||
import { Doc, getCurrentAccount, IdMap, ObjQueryType, Ref, Timestamp, toIdMap } from '@hcengineering/core'
|
||||
@ -135,6 +137,30 @@ export async function getContactName (provider: TemplateDataProvider): Promise<s
|
||||
}
|
||||
}
|
||||
|
||||
export async function getContactLastName (provider: TemplateDataProvider): Promise<string | undefined> {
|
||||
const value = provider.get(contact.class.Contact) as Contact
|
||||
if (value === undefined) return
|
||||
const client = getClient()
|
||||
const hierarchy = client.getHierarchy()
|
||||
if (hierarchy.isDerived(value._class, contact.class.Person)) {
|
||||
return getLastName(value.name)
|
||||
} else {
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
export async function getContactFirstName (provider: TemplateDataProvider): Promise<string | undefined> {
|
||||
const value = provider.get(contact.class.Contact) as Contact
|
||||
if (value === undefined) return
|
||||
const client = getClient()
|
||||
const hierarchy = client.getHierarchy()
|
||||
if (hierarchy.isDerived(value._class, contact.class.Person)) {
|
||||
return getFirstName(value.name)
|
||||
} else {
|
||||
return value.name
|
||||
}
|
||||
}
|
||||
|
||||
export async function getContactLink (doc: Doc): Promise<Location> {
|
||||
const loc = getCurrentLocation()
|
||||
loc.path.length = 2
|
||||
|
@ -266,7 +266,9 @@ export const contactPlugin = plugin(contactId, {
|
||||
templateField: {
|
||||
CurrentEmployeeName: '' as Ref<TemplateField>,
|
||||
CurrentEmployeeEmail: '' as Ref<TemplateField>,
|
||||
ContactName: '' as Ref<TemplateField>
|
||||
ContactName: '' as Ref<TemplateField>,
|
||||
ContactFirstName: '' as Ref<TemplateField>,
|
||||
ContactLastName: '' as Ref<TemplateField>
|
||||
}
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user