mirror of
https://github.com/hcengineering/platform.git
synced 2025-01-23 12:05:36 +00:00
Employee position template (#2889)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
parent
3d7a02f316
commit
5cf989b314
@ -690,6 +690,17 @@ export function createModel (builder: Builder): void {
|
||||
contact.templateField.ContactName
|
||||
)
|
||||
|
||||
builder.createDoc(
|
||||
templates.class.TemplateField,
|
||||
core.space.Model,
|
||||
{
|
||||
label: contact.string.Position,
|
||||
category: contact.templateFieldCategory.CurrentEmployee,
|
||||
func: contact.function.GetCurrentEmployeePosition
|
||||
},
|
||||
contact.templateField.CurrentEmployeePosition
|
||||
)
|
||||
|
||||
builder.createDoc(
|
||||
templates.class.TemplateField,
|
||||
core.space.Model,
|
||||
|
@ -103,6 +103,7 @@ export default mergeIds(contactId, contact, {
|
||||
function: {
|
||||
GetCurrentEmployeeName: '' as Resource<TemplateFieldFunc>,
|
||||
GetCurrentEmployeeEmail: '' as Resource<TemplateFieldFunc>,
|
||||
GetCurrentEmployeePosition: '' as Resource<TemplateFieldFunc>,
|
||||
GetContactName: '' as Resource<TemplateFieldFunc>,
|
||||
GetContactFirstName: '' as Resource<TemplateFieldFunc>,
|
||||
GetContactLastName: '' as Resource<TemplateFieldFunc>
|
||||
|
@ -30,6 +30,7 @@
|
||||
"@hcengineering/ui": "^0.6.3",
|
||||
"@hcengineering/view": "^0.6.2",
|
||||
"@hcengineering/setting": "^0.6.3",
|
||||
"@hcengineering/contact": "^0.6.11",
|
||||
"@hcengineering/setting-resources": "^0.6.0",
|
||||
"@hcengineering/platform": "^0.6.8",
|
||||
"@hcengineering/model-core": "^0.6.0",
|
||||
|
@ -32,6 +32,7 @@ import {
|
||||
import task from '@hcengineering/task'
|
||||
import setting from './plugin'
|
||||
import templates from '@hcengineering/templates'
|
||||
import contact from '@hcengineering/contact'
|
||||
|
||||
import workbench from '@hcengineering/model-workbench'
|
||||
import { AnyComponent } from '@hcengineering/ui'
|
||||
@ -445,6 +446,17 @@ export function createModel (builder: Builder): void {
|
||||
},
|
||||
setting.templateField.OwnerName
|
||||
)
|
||||
|
||||
builder.createDoc(
|
||||
templates.class.TemplateField,
|
||||
core.space.Model,
|
||||
{
|
||||
label: contact.string.Position,
|
||||
category: setting.templateFieldCategory.Integration,
|
||||
func: setting.function.GetOwnerPosition
|
||||
},
|
||||
setting.templateField.OwnerPosition
|
||||
)
|
||||
}
|
||||
|
||||
export { settingOperation } from './migration'
|
||||
|
@ -59,6 +59,7 @@ export default mergeIds(settingId, setting, {
|
||||
},
|
||||
function: {
|
||||
GetValue: '' as Resource<TemplateFieldFunc>,
|
||||
GetOwnerName: '' as Resource<TemplateFieldFunc>
|
||||
GetOwnerName: '' as Resource<TemplateFieldFunc>,
|
||||
GetOwnerPosition: '' as Resource<TemplateFieldFunc>
|
||||
}
|
||||
})
|
||||
|
@ -81,6 +81,7 @@ import {
|
||||
getContactName,
|
||||
getCurrentEmployeeEmail,
|
||||
getCurrentEmployeeName,
|
||||
getCurrentEmployeePosition,
|
||||
resolveLocation
|
||||
} from './utils'
|
||||
|
||||
@ -282,6 +283,7 @@ export default async (): Promise<Resources> => ({
|
||||
FilterChannelNinResult: filterChannelNinResult,
|
||||
GetCurrentEmployeeName: getCurrentEmployeeName,
|
||||
GetCurrentEmployeeEmail: getCurrentEmployeeEmail,
|
||||
GetCurrentEmployeePosition: getCurrentEmployeePosition,
|
||||
GetContactName: getContactName,
|
||||
GetContactFirstName: getContactFirstName,
|
||||
GetContactLastName: getContactLastName,
|
||||
|
@ -125,6 +125,15 @@ export async function getCurrentEmployeeEmail (): Promise<string> {
|
||||
return me.email
|
||||
}
|
||||
|
||||
export async function getCurrentEmployeePosition (): Promise<string | undefined> {
|
||||
const me = getCurrentAccount() as EmployeeAccount
|
||||
const client = getClient()
|
||||
const employee = await client.findOne(contact.class.Employee, { _id: me.employee })
|
||||
if (employee !== undefined) {
|
||||
return employee.position ?? ''
|
||||
}
|
||||
}
|
||||
|
||||
export async function getContactName (provider: TemplateDataProvider): Promise<string | undefined> {
|
||||
const value = provider.get(contact.class.Contact) as Contact
|
||||
if (value === undefined) return
|
||||
|
@ -265,6 +265,7 @@ export const contactPlugin = plugin(contactId, {
|
||||
},
|
||||
templateField: {
|
||||
CurrentEmployeeName: '' as Ref<TemplateField>,
|
||||
CurrentEmployeePosition: '' as Ref<TemplateField>,
|
||||
CurrentEmployeeEmail: '' as Ref<TemplateField>,
|
||||
ContactName: '' as Ref<TemplateField>,
|
||||
ContactFirstName: '' as Ref<TemplateField>,
|
||||
|
@ -44,7 +44,7 @@ import StringTypeEditor from './components/typeEditors/StringTypeEditor.svelte'
|
||||
import WorkspaceSettings from './components/WorkspaceSettings.svelte'
|
||||
import InviteSetting from './components/InviteSetting.svelte'
|
||||
import setting from './plugin'
|
||||
import { getOwnerName, getValue } from './utils'
|
||||
import { getOwnerName, getOwnerPosition, getValue } from './utils'
|
||||
|
||||
export { ClassSetting }
|
||||
|
||||
@ -105,6 +105,7 @@ export default async (): Promise<Resources> => ({
|
||||
},
|
||||
function: {
|
||||
GetOwnerName: getOwnerName,
|
||||
GetOwnerPosition: getOwnerPosition,
|
||||
GetValue: getValue
|
||||
}
|
||||
})
|
||||
|
@ -69,3 +69,16 @@ export async function getOwnerName (provider: TemplateDataProvider): Promise<str
|
||||
return employee != null ? getName(employee) : undefined
|
||||
}
|
||||
}
|
||||
|
||||
export async function getOwnerPosition (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 ? employee.position ?? '' : undefined
|
||||
}
|
||||
}
|
||||
|
@ -182,6 +182,7 @@ export default plugin(settingId, {
|
||||
},
|
||||
templateField: {
|
||||
OwnerName: '' as Ref<TemplateField>,
|
||||
OwnerPosition: '' as Ref<TemplateField>,
|
||||
Value: '' as Ref<TemplateField>
|
||||
}
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user