mirror of
https://github.com/hcengineering/platform.git
synced 2025-01-03 08:57:14 +03:00
TSK-1216: Fix bitrix import (#3005)
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
parent
2d32f677d9
commit
4a29f8dc8b
@ -157,7 +157,7 @@
|
|||||||
"@hcengineering/document": "^0.6.0",
|
"@hcengineering/document": "^0.6.0",
|
||||||
"@hcengineering/document-assets": "^0.6.0",
|
"@hcengineering/document-assets": "^0.6.0",
|
||||||
"@hcengineering/document-resources": "^0.6.0",
|
"@hcengineering/document-resources": "^0.6.0",
|
||||||
"@hcengineering/bitrix": "^0.6.31",
|
"@hcengineering/bitrix": "^0.6.32",
|
||||||
"@hcengineering/bitrix-assets": "^0.6.0",
|
"@hcengineering/bitrix-assets": "^0.6.0",
|
||||||
"@hcengineering/bitrix-resources": "^0.6.0",
|
"@hcengineering/bitrix-resources": "^0.6.0",
|
||||||
"@hcengineering/request": "^0.6.0",
|
"@hcengineering/request": "^0.6.0",
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
"@hcengineering/view": "^0.6.4",
|
"@hcengineering/view": "^0.6.4",
|
||||||
"@hcengineering/model-view": "^0.6.0",
|
"@hcengineering/model-view": "^0.6.0",
|
||||||
"@hcengineering/contact": "^0.6.13",
|
"@hcengineering/contact": "^0.6.13",
|
||||||
"@hcengineering/bitrix": "^0.6.31",
|
"@hcengineering/bitrix": "^0.6.32",
|
||||||
"@hcengineering/bitrix-resources": "^0.6.0",
|
"@hcengineering/bitrix-resources": "^0.6.0",
|
||||||
"@hcengineering/preference": "^0.6.4",
|
"@hcengineering/preference": "^0.6.4",
|
||||||
"@hcengineering/model-preference": "^0.6.0",
|
"@hcengineering/model-preference": "^0.6.0",
|
||||||
|
@ -999,7 +999,7 @@ export function createModel (builder: Builder): void {
|
|||||||
attribute: 'state',
|
attribute: 'state',
|
||||||
_class: task.class.State,
|
_class: task.class.State,
|
||||||
query: {},
|
query: {},
|
||||||
searchField: 'title',
|
searchField: 'name',
|
||||||
// should match space
|
// should match space
|
||||||
fillQuery: { space: 'space' },
|
fillQuery: { space: 'space' },
|
||||||
// Only apply for same vacancy
|
// Only apply for same vacancy
|
||||||
|
@ -30,6 +30,6 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@hcengineering/platform": "^0.6.8",
|
"@hcengineering/platform": "^0.6.8",
|
||||||
"@hcengineering/bitrix": "^0.6.31"
|
"@hcengineering/bitrix": "^0.6.32"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@hcengineering/platform": "^0.6.8",
|
"@hcengineering/platform": "^0.6.8",
|
||||||
"svelte": "3.55.1",
|
"svelte": "3.55.1",
|
||||||
"@hcengineering/bitrix": "^0.6.31",
|
"@hcengineering/bitrix": "^0.6.32",
|
||||||
"@hcengineering/ui": "^0.6.6",
|
"@hcengineering/ui": "^0.6.6",
|
||||||
"@hcengineering/presentation": "^0.6.2",
|
"@hcengineering/presentation": "^0.6.2",
|
||||||
"@hcengineering/text-editor": "^0.6.0",
|
"@hcengineering/text-editor": "^0.6.0",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@hcengineering/bitrix",
|
"name": "@hcengineering/bitrix",
|
||||||
"version": "0.6.31",
|
"version": "0.6.32",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"author": "Anticrm Platform Contributors",
|
"author": "Anticrm Platform Contributors",
|
||||||
"license": "EPL-2.0",
|
"license": "EPL-2.0",
|
||||||
|
@ -109,12 +109,11 @@ export async function syncDocument (
|
|||||||
const hierarchy = client.getHierarchy()
|
const hierarchy = client.getHierarchy()
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const applyOp = client.apply('bitrix')
|
|
||||||
|
|
||||||
if (existing !== undefined) {
|
if (existing !== undefined) {
|
||||||
// We need update document id.
|
// We need update document id.
|
||||||
resultDoc.document._id = existing._id as Ref<BitrixSyncDoc>
|
resultDoc.document._id = existing._id as Ref<BitrixSyncDoc>
|
||||||
}
|
}
|
||||||
|
const applyOp = client.apply(resultDoc.document._id)
|
||||||
|
|
||||||
// Operations could add more change instructions
|
// Operations could add more change instructions
|
||||||
for (const op of resultDoc.postOperations) {
|
for (const op of resultDoc.postOperations) {
|
||||||
|
@ -408,6 +408,7 @@ export async function convert (
|
|||||||
const getCreateAttachedValue = async (attr: AnyAttribute, operation: CreateHRApplication): Promise<void> => {
|
const getCreateAttachedValue = async (attr: AnyAttribute, operation: CreateHRApplication): Promise<void> => {
|
||||||
const vacancyName = extractValue(operation.vacancyField)
|
const vacancyName = extractValue(operation.vacancyField)
|
||||||
const sourceStatusName = extractValue(operation.stateField)
|
const sourceStatusName = extractValue(operation.stateField)
|
||||||
|
|
||||||
postOperations.push(async (doc, extraDocs, ops, existingDoc) => {
|
postOperations.push(async (doc, extraDocs, ops, existingDoc) => {
|
||||||
let vacancyId: Ref<Vacancy> | undefined
|
let vacancyId: Ref<Vacancy> | undefined
|
||||||
if (ops.syncVacancy === false) {
|
if (ops.syncVacancy === false) {
|
||||||
@ -419,7 +420,6 @@ export async function convert (
|
|||||||
|
|
||||||
if (vacancyName !== undefined) {
|
if (vacancyName !== undefined) {
|
||||||
const tName = vacancyName.trim().toLowerCase()
|
const tName = vacancyName.trim().toLowerCase()
|
||||||
const vacancy = vacancies.find((it) => it.name.toLowerCase().trim() === tName)
|
|
||||||
|
|
||||||
let refOrgField: Ref<Organization> | undefined
|
let refOrgField: Ref<Organization> | undefined
|
||||||
const allAttrs = hierarchy.getAllAttributes(recruit.mixin.Candidate)
|
const allAttrs = hierarchy.getAllAttributes(recruit.mixin.Candidate)
|
||||||
@ -429,6 +429,8 @@ export async function convert (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const vacancy = vacancies.find((it) => it.name.toLowerCase().trim() === tName && it.company === refOrgField)
|
||||||
|
|
||||||
if (vacancy !== undefined) {
|
if (vacancy !== undefined) {
|
||||||
vacancyId = vacancy?._id
|
vacancyId = vacancy?._id
|
||||||
} else {
|
} else {
|
||||||
@ -449,10 +451,8 @@ export async function convert (
|
|||||||
|
|
||||||
if (sourceStatusName != null && sourceStatusName !== '') {
|
if (sourceStatusName != null && sourceStatusName !== '') {
|
||||||
// Check if candidate already have vacancy
|
// Check if candidate already have vacancy
|
||||||
const existing = applications.find(
|
const existingApplicants = applications.filter(
|
||||||
(it) =>
|
(it) => it.attachedTo === ((existingDoc?._id ?? doc.document._id) as unknown as Ref<Candidate>)
|
||||||
it.attachedTo === ((existingDoc?._id ?? doc.document._id) as unknown as Ref<Candidate>) &&
|
|
||||||
it.space === vacancyId
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const candidate = doc.mixins[recruit.mixin.Candidate] as Data<Candidate>
|
const candidate = doc.mixins[recruit.mixin.Candidate] as Data<Candidate>
|
||||||
@ -482,15 +482,25 @@ export async function convert (
|
|||||||
;(doc.document as any)[u.attr] = u.value
|
;(doc.document as any)[u.attr] = u.value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Find status for vacancy
|
|
||||||
const update: DocumentUpdate<Applicant> = {}
|
|
||||||
for (const k of operation.copyTalentFields ?? []) {
|
|
||||||
const val = (candidate as any)[k.candidate]
|
|
||||||
if ((existing as any)?.[k.applicant] !== val) {
|
|
||||||
;(update as any)[k.applicant] = val
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (vacancyId !== undefined) {
|
if (vacancyId !== undefined) {
|
||||||
|
let existing: Applicant | undefined
|
||||||
|
for (const a of existingApplicants) {
|
||||||
|
if (a.space === vacancyId) {
|
||||||
|
existing = a
|
||||||
|
} else {
|
||||||
|
await ops.remove(a)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find status for vacancy
|
||||||
|
const update: DocumentUpdate<Applicant> = {}
|
||||||
|
for (const k of operation.copyTalentFields ?? []) {
|
||||||
|
const val = (candidate as any)[k.candidate]
|
||||||
|
if ((existing as any)?.[k.applicant] !== val) {
|
||||||
|
;(update as any)[k.applicant] = val
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const states = await client.findAll(task.class.State, { space: vacancyId })
|
const states = await client.findAll(task.class.State, { space: vacancyId })
|
||||||
const state = states.find((it) => it.name.toLowerCase().trim() === statusName.toLowerCase().trim())
|
const state = states.find((it) => it.name.toLowerCase().trim() === statusName.toLowerCase().trim())
|
||||||
if (state !== undefined) {
|
if (state !== undefined) {
|
||||||
|
@ -135,7 +135,7 @@
|
|||||||
"@hcengineering/board": "^0.6.4",
|
"@hcengineering/board": "^0.6.4",
|
||||||
"@hcengineering/hr": "^0.6.4",
|
"@hcengineering/hr": "^0.6.4",
|
||||||
"@hcengineering/document": "^0.6.0",
|
"@hcengineering/document": "^0.6.0",
|
||||||
"@hcengineering/bitrix": "^0.6.31",
|
"@hcengineering/bitrix": "^0.6.32",
|
||||||
"@hcengineering/request": "^0.6.0"
|
"@hcengineering/request": "^0.6.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user