From d7089dae74dacc17b9193ff975f33eba159e0548 Mon Sep 17 00:00:00 2001 From: Vyacheslav Tumanov Date: Tue, 31 Oct 2023 22:09:02 +0500 Subject: [PATCH] UBER-1143: setting for skill import, redirect to talents from skillsView (#3925) Signed-off-by: Vyacheslav Tumanov --- plugins/recruit-assets/lang/en.json | 3 +- plugins/recruit-assets/lang/ru.json | 3 +- .../src/components/CreateCandidate.svelte | 33 +++++++++++-------- .../src/components/SkillsView.svelte | 23 +++++++++++-- plugins/recruit-resources/src/plugin.ts | 3 +- 5 files changed, 47 insertions(+), 18 deletions(-) diff --git a/plugins/recruit-assets/lang/en.json b/plugins/recruit-assets/lang/en.json index 7f11a92ca7..f5199a64e7 100644 --- a/plugins/recruit-assets/lang/en.json +++ b/plugins/recruit-assets/lang/en.json @@ -119,7 +119,8 @@ "ShowApplications": "Show applications", "GetTalentIds": "Get talents' ids", "HideDoneState": "Hide complete applications", - "HideArchivedVacancies": "Hide from archived Vacancies" + "HideArchivedVacancies": "Hide from archived Vacancies", + "CreateNewSkills": "Create new skills if existing not found" }, "status": { "ApplicationExists": "Application already exists", diff --git a/plugins/recruit-assets/lang/ru.json b/plugins/recruit-assets/lang/ru.json index 293c87ce51..c28f3b9e60 100644 --- a/plugins/recruit-assets/lang/ru.json +++ b/plugins/recruit-assets/lang/ru.json @@ -119,7 +119,8 @@ "ShowApplications": "Показать кандидатов", "GetTalentIds": "Получить ID талантов", "HideDoneState": "Скрыть завершенных кандидатов", - "HideArchivedVacancies": "Скрыть архивные вакансии" + "HideArchivedVacancies": "Скрыть архивные вакансии", + "CreateNewSkills": "Создать навыки, если не найдены существующие" }, "status": { "ApplicationExists": "Кандидат уже существует", diff --git a/plugins/recruit-resources/src/components/CreateCandidate.svelte b/plugins/recruit-resources/src/components/CreateCandidate.svelte index b0dce3c758..36d5580cd5 100644 --- a/plugins/recruit-resources/src/components/CreateCandidate.svelte +++ b/plugins/recruit-resources/src/components/CreateCandidate.svelte @@ -57,7 +57,8 @@ IconInfo, Label, showPopup, - Spinner + Spinner, + MiniToggle } from '@hcengineering/ui' import { createEventDispatcher, onDestroy } from 'svelte' import recruit from '../plugin' @@ -136,6 +137,7 @@ let inputFile: HTMLInputElement let loading = false let dragover = false + let shouldCreateNewSkills = false let avatar: File | undefined = draft?.avatar @@ -349,7 +351,7 @@ for (const s of doc.skills ?? []) { const title = s.trim().toLowerCase() let e = namedElements.get(title) - if (e === undefined) { + if (e === undefined && shouldCreateNewSkills) { // No yet tag with title const category = findTagCategory(s, categories) const cinstance = categoriesMap.get(category) @@ -366,18 +368,20 @@ elements.set(e._id, e) newElements.push(e) } - newSkills.push( - TxProcessor.createDoc2Doc( - client.txFactory.createTxCreateDoc(tags.class.TagReference, tags.space.Tags, { - title: e.title, - color: e.color, - tag: e._id, - attachedTo: '' as Ref, - attachedToClass: recruit.mixin.Candidate, - collection: 'skills' - }) + if (e !== undefined) { + newSkills.push( + TxProcessor.createDoc2Doc( + client.txFactory.createTxCreateDoc(tags.class.TagReference, tags.space.Tags, { + title: e.title, + color: e.color, + tag: e._id, + attachedTo: '' as Ref, + attachedToClass: recruit.mixin.Candidate, + collection: 'skills' + }) + ) ) - ) + } } object.skills = [...object.skills, ...newSkills] } catch (err: any) { @@ -705,6 +709,9 @@ {/if} {/if} +
+ +
{#if matches.length > 0}
diff --git a/plugins/recruit-resources/src/components/SkillsView.svelte b/plugins/recruit-resources/src/components/SkillsView.svelte index 17df7541dd..47aad43519 100644 --- a/plugins/recruit-resources/src/components/SkillsView.svelte +++ b/plugins/recruit-resources/src/components/SkillsView.svelte @@ -2,14 +2,33 @@ import tags, { selectedTagElements, TagElement } from '@hcengineering/tags' import { Component, getCurrentResolvedLocation, navigate } from '@hcengineering/ui' import recruit from '../plugin' + import { buildFilterKey, setFilters } from '@hcengineering/view-resources' + import { getClient } from '@hcengineering/presentation' + import { Filter } from '@hcengineering/view' - function onTag (tag: TagElement): void { + function setFilterTag (tag: TagElement) { + const client = getClient() + const hierarchy = client.getHierarchy() + const attribute = hierarchy.getAttribute(recruit.mixin.Candidate, 'skills') + const key = buildFilterKey(hierarchy, recruit.mixin.Candidate, '_class', attribute) + const filter = { + key, + value: [tag._id], + props: { level: 0 }, + modes: [tags.filter.FilterTagsIn, tags.filter.FilterTagsNin], + mode: tags.filter.FilterTagsIn, + index: 1 + } as Filter + setFilters([filter]) + } + async function onTag (tag: TagElement): Promise { selectedTagElements.set([tag._id]) const loc = getCurrentResolvedLocation() loc.path[2] = 'recruit' - loc.path[3] = 'candidates' + loc.path[3] = 'talents' loc.path.length = 4 navigate(loc) + setTimeout(() => setFilterTag(tag), 50) } diff --git a/plugins/recruit-resources/src/plugin.ts b/plugins/recruit-resources/src/plugin.ts index 5457a01ba9..e11ea90ccd 100644 --- a/plugins/recruit-resources/src/plugin.ts +++ b/plugins/recruit-resources/src/plugin.ts @@ -131,7 +131,8 @@ export default mergeIds(recruitId, recruit, { Apply: '' as IntlString, OpenVacancyList: '' as IntlString, Export: '' as IntlString, - GetTalentIds: '' as IntlString + GetTalentIds: '' as IntlString, + CreateNewSkills: '' as IntlString }, space: { CandidatesPublic: '' as Ref