mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-27 02:42:11 +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
|
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(
|
builder.createDoc(
|
||||||
templates.class.TemplateField,
|
templates.class.TemplateField,
|
||||||
core.space.Model,
|
core.space.Model,
|
||||||
|
@ -103,6 +103,7 @@ export default mergeIds(contactId, contact, {
|
|||||||
function: {
|
function: {
|
||||||
GetCurrentEmployeeName: '' as Resource<TemplateFieldFunc>,
|
GetCurrentEmployeeName: '' as Resource<TemplateFieldFunc>,
|
||||||
GetCurrentEmployeeEmail: '' as Resource<TemplateFieldFunc>,
|
GetCurrentEmployeeEmail: '' as Resource<TemplateFieldFunc>,
|
||||||
|
GetCurrentEmployeePosition: '' as Resource<TemplateFieldFunc>,
|
||||||
GetContactName: '' as Resource<TemplateFieldFunc>,
|
GetContactName: '' as Resource<TemplateFieldFunc>,
|
||||||
GetContactFirstName: '' as Resource<TemplateFieldFunc>,
|
GetContactFirstName: '' as Resource<TemplateFieldFunc>,
|
||||||
GetContactLastName: '' as Resource<TemplateFieldFunc>
|
GetContactLastName: '' as Resource<TemplateFieldFunc>
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
"@hcengineering/ui": "^0.6.3",
|
"@hcengineering/ui": "^0.6.3",
|
||||||
"@hcengineering/view": "^0.6.2",
|
"@hcengineering/view": "^0.6.2",
|
||||||
"@hcengineering/setting": "^0.6.3",
|
"@hcengineering/setting": "^0.6.3",
|
||||||
|
"@hcengineering/contact": "^0.6.11",
|
||||||
"@hcengineering/setting-resources": "^0.6.0",
|
"@hcengineering/setting-resources": "^0.6.0",
|
||||||
"@hcengineering/platform": "^0.6.8",
|
"@hcengineering/platform": "^0.6.8",
|
||||||
"@hcengineering/model-core": "^0.6.0",
|
"@hcengineering/model-core": "^0.6.0",
|
||||||
|
@ -32,6 +32,7 @@ import {
|
|||||||
import task from '@hcengineering/task'
|
import task from '@hcengineering/task'
|
||||||
import setting from './plugin'
|
import setting from './plugin'
|
||||||
import templates from '@hcengineering/templates'
|
import templates from '@hcengineering/templates'
|
||||||
|
import contact from '@hcengineering/contact'
|
||||||
|
|
||||||
import workbench from '@hcengineering/model-workbench'
|
import workbench from '@hcengineering/model-workbench'
|
||||||
import { AnyComponent } from '@hcengineering/ui'
|
import { AnyComponent } from '@hcengineering/ui'
|
||||||
@ -445,6 +446,17 @@ export function createModel (builder: Builder): void {
|
|||||||
},
|
},
|
||||||
setting.templateField.OwnerName
|
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'
|
export { settingOperation } from './migration'
|
||||||
|
@ -59,6 +59,7 @@ export default mergeIds(settingId, setting, {
|
|||||||
},
|
},
|
||||||
function: {
|
function: {
|
||||||
GetValue: '' as Resource<TemplateFieldFunc>,
|
GetValue: '' as Resource<TemplateFieldFunc>,
|
||||||
GetOwnerName: '' as Resource<TemplateFieldFunc>
|
GetOwnerName: '' as Resource<TemplateFieldFunc>,
|
||||||
|
GetOwnerPosition: '' as Resource<TemplateFieldFunc>
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -81,6 +81,7 @@ import {
|
|||||||
getContactName,
|
getContactName,
|
||||||
getCurrentEmployeeEmail,
|
getCurrentEmployeeEmail,
|
||||||
getCurrentEmployeeName,
|
getCurrentEmployeeName,
|
||||||
|
getCurrentEmployeePosition,
|
||||||
resolveLocation
|
resolveLocation
|
||||||
} from './utils'
|
} from './utils'
|
||||||
|
|
||||||
@ -282,6 +283,7 @@ export default async (): Promise<Resources> => ({
|
|||||||
FilterChannelNinResult: filterChannelNinResult,
|
FilterChannelNinResult: filterChannelNinResult,
|
||||||
GetCurrentEmployeeName: getCurrentEmployeeName,
|
GetCurrentEmployeeName: getCurrentEmployeeName,
|
||||||
GetCurrentEmployeeEmail: getCurrentEmployeeEmail,
|
GetCurrentEmployeeEmail: getCurrentEmployeeEmail,
|
||||||
|
GetCurrentEmployeePosition: getCurrentEmployeePosition,
|
||||||
GetContactName: getContactName,
|
GetContactName: getContactName,
|
||||||
GetContactFirstName: getContactFirstName,
|
GetContactFirstName: getContactFirstName,
|
||||||
GetContactLastName: getContactLastName,
|
GetContactLastName: getContactLastName,
|
||||||
|
@ -125,6 +125,15 @@ export async function getCurrentEmployeeEmail (): Promise<string> {
|
|||||||
return me.email
|
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> {
|
export async function getContactName (provider: TemplateDataProvider): Promise<string | undefined> {
|
||||||
const value = provider.get(contact.class.Contact) as Contact
|
const value = provider.get(contact.class.Contact) as Contact
|
||||||
if (value === undefined) return
|
if (value === undefined) return
|
||||||
|
@ -265,6 +265,7 @@ export const contactPlugin = plugin(contactId, {
|
|||||||
},
|
},
|
||||||
templateField: {
|
templateField: {
|
||||||
CurrentEmployeeName: '' as Ref<TemplateField>,
|
CurrentEmployeeName: '' as Ref<TemplateField>,
|
||||||
|
CurrentEmployeePosition: '' as Ref<TemplateField>,
|
||||||
CurrentEmployeeEmail: '' as Ref<TemplateField>,
|
CurrentEmployeeEmail: '' as Ref<TemplateField>,
|
||||||
ContactName: '' as Ref<TemplateField>,
|
ContactName: '' as Ref<TemplateField>,
|
||||||
ContactFirstName: '' 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 WorkspaceSettings from './components/WorkspaceSettings.svelte'
|
||||||
import InviteSetting from './components/InviteSetting.svelte'
|
import InviteSetting from './components/InviteSetting.svelte'
|
||||||
import setting from './plugin'
|
import setting from './plugin'
|
||||||
import { getOwnerName, getValue } from './utils'
|
import { getOwnerName, getOwnerPosition, getValue } from './utils'
|
||||||
|
|
||||||
export { ClassSetting }
|
export { ClassSetting }
|
||||||
|
|
||||||
@ -105,6 +105,7 @@ export default async (): Promise<Resources> => ({
|
|||||||
},
|
},
|
||||||
function: {
|
function: {
|
||||||
GetOwnerName: getOwnerName,
|
GetOwnerName: getOwnerName,
|
||||||
|
GetOwnerPosition: getOwnerPosition,
|
||||||
GetValue: getValue
|
GetValue: getValue
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -69,3 +69,16 @@ export async function getOwnerName (provider: TemplateDataProvider): Promise<str
|
|||||||
return employee != null ? getName(employee) : undefined
|
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: {
|
templateField: {
|
||||||
OwnerName: '' as Ref<TemplateField>,
|
OwnerName: '' as Ref<TemplateField>,
|
||||||
|
OwnerPosition: '' as Ref<TemplateField>,
|
||||||
Value: '' as Ref<TemplateField>
|
Value: '' as Ref<TemplateField>
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user