mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-23 16:56:07 +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
|
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'
|
export { contactOperation } from './migration'
|
||||||
|
@ -103,6 +103,8 @@ export default mergeIds(contactId, contact, {
|
|||||||
function: {
|
function: {
|
||||||
GetCurrentEmployeeName: '' as Resource<TemplateFieldFunc>,
|
GetCurrentEmployeeName: '' as Resource<TemplateFieldFunc>,
|
||||||
GetCurrentEmployeeEmail: '' 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": "Фамилия",
|
"PersonLastNamePlaceholder": "Фамилия",
|
||||||
"PersonLocationPlaceholder": "Местоположение",
|
"PersonLocationPlaceholder": "Местоположение",
|
||||||
"PersonsNamePlaceholder": "Папка",
|
"PersonsNamePlaceholder": "Папка",
|
||||||
"Name": "Имя",
|
"Name": "Полное имя",
|
||||||
"SelectFolder": "Выбрать папку",
|
"SelectFolder": "Выбрать папку",
|
||||||
"OrganizationsFolder": "Папка с организациями",
|
"OrganizationsFolder": "Папка с организациями",
|
||||||
"PersonsFolder": "Папка с людьми",
|
"PersonsFolder": "Папка с людьми",
|
||||||
|
@ -75,6 +75,8 @@ import {
|
|||||||
employeeSort,
|
employeeSort,
|
||||||
filterChannelInResult,
|
filterChannelInResult,
|
||||||
filterChannelNinResult,
|
filterChannelNinResult,
|
||||||
|
getContactFirstName,
|
||||||
|
getContactLastName,
|
||||||
getContactLink,
|
getContactLink,
|
||||||
getContactName,
|
getContactName,
|
||||||
getCurrentEmployeeEmail,
|
getCurrentEmployeeEmail,
|
||||||
@ -281,6 +283,8 @@ export default async (): Promise<Resources> => ({
|
|||||||
GetCurrentEmployeeName: getCurrentEmployeeName,
|
GetCurrentEmployeeName: getCurrentEmployeeName,
|
||||||
GetCurrentEmployeeEmail: getCurrentEmployeeEmail,
|
GetCurrentEmployeeEmail: getCurrentEmployeeEmail,
|
||||||
GetContactName: getContactName,
|
GetContactName: getContactName,
|
||||||
|
GetContactFirstName: getContactFirstName,
|
||||||
|
GetContactLastName: getContactLastName,
|
||||||
GetContactLink: getContactLink
|
GetContactLink: getContactLink
|
||||||
},
|
},
|
||||||
resolver: {
|
resolver: {
|
||||||
|
@ -23,6 +23,8 @@ import {
|
|||||||
Employee,
|
Employee,
|
||||||
EmployeeAccount,
|
EmployeeAccount,
|
||||||
formatName,
|
formatName,
|
||||||
|
getFirstName,
|
||||||
|
getLastName,
|
||||||
getName
|
getName
|
||||||
} from '@hcengineering/contact'
|
} from '@hcengineering/contact'
|
||||||
import { Doc, getCurrentAccount, IdMap, ObjQueryType, Ref, Timestamp, toIdMap } from '@hcengineering/core'
|
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> {
|
export async function getContactLink (doc: Doc): Promise<Location> {
|
||||||
const loc = getCurrentLocation()
|
const loc = getCurrentLocation()
|
||||||
loc.path.length = 2
|
loc.path.length = 2
|
||||||
|
@ -266,7 +266,9 @@ export const contactPlugin = plugin(contactId, {
|
|||||||
templateField: {
|
templateField: {
|
||||||
CurrentEmployeeName: '' as Ref<TemplateField>,
|
CurrentEmployeeName: '' as Ref<TemplateField>,
|
||||||
CurrentEmployeeEmail: '' 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