From c705fd385cc26fd9ac2d291e99a93f5bd7f51348 Mon Sep 17 00:00:00 2001 From: Sergey Voytsehovich Date: Thu, 21 Dec 2023 10:50:49 +0300 Subject: [PATCH] hide archieved vacanies toggle in viewoptions (#4220) Signed-off-by: Sergey Voytsehovich --- models/recruit/src/index.ts | 35 ++++----- models/recruit/src/plugin.ts | 3 +- plugins/recruit-assets/lang/en.json | 3 +- plugins/recruit-assets/lang/ru.json | 1 + .../src/components/Vacancies.svelte | 4 +- .../src/components/ViewOptions.svelte | 71 +++++++++++-------- plugins/view-resources/src/viewOptions.ts | 4 +- .../tests/model/recruiting/vacancies-page.ts | 23 +++++- .../sanity/tests/recruiting/vacancies.spec.ts | 33 +++++++++ 9 files changed, 122 insertions(+), 55 deletions(-) diff --git a/models/recruit/src/index.ts b/models/recruit/src/index.ts index c126b262ca..07bcef106c 100644 --- a/models/recruit/src/index.ts +++ b/models/recruit/src/index.ts @@ -272,7 +272,6 @@ export function createModel (builder: Builder): void { const talentsId = 'talents' const skillsId = 'skills' const candidatesId = 'candidates' - const archiveId = 'archive' const myApplicationsId = 'my-applications' const organizationsId = 'organizations' @@ -341,18 +340,6 @@ export function createModel (builder: Builder): void { }, position: 'vacancy' }, - { - id: archiveId, - component: recruit.component.Vacancies, - icon: view.icon.Archive, - label: workbench.string.Archive, - position: 'bottom', - visibleIf: workbench.function.HasArchiveSpaces, - spaceClass: recruit.class.Vacancy, - componentProps: { - archived: true - } - }, { id: skillsId, component: recruit.component.SkillsView, @@ -502,6 +489,14 @@ export function createModel (builder: Builder): void { recruit.viewlet.VacancyApplicationsEmbeddeed ) + // hiding arhived vacancies from vacancy view + const vacancyHideArchivedOption: ViewOptionModel = { + key: 'hideArchived', + type: 'toggle', + defaultValue: true, + label: recruit.string.HideArchivedVacancies + } + builder.createDoc( view.class.Viewlet, core.space.Model, @@ -535,6 +530,11 @@ export function createModel (builder: Builder): void { configOptions: { hiddenKeys: ['name', 'space', 'modifiedOn'], sortable: true + }, + viewOptions: { + groupBy: [], + orderBy: [], + other: [vacancyHideArchivedOption] } }, recruit.viewlet.TableVacancy @@ -730,13 +730,14 @@ export function createModel (builder: Builder): void { label: recruit.string.HideDoneState } - const vacancyHideOption: ViewOptionModel = { + // hiding applicants related to archived vacancies from applicants view + const hideApplicantsFromArchivedVacanciesOption: ViewOptionModel = { key: 'hideArchivedVacancies', type: 'toggle', defaultValue: true, actionTarget: 'query', action: recruit.function.HideArchivedVacancies, - label: recruit.string.HideArchivedVacancies + label: recruit.string.HideApplicantsFromArchivedVacancies } const applicantViewOptions = (colors: boolean, hides: boolean): ViewOptionsModel => { @@ -764,7 +765,7 @@ export function createModel (builder: Builder): void { model.other.push(showColorsViewOption) } if (hides) { - model.other.push(...[applicationDoneOption, vacancyHideOption]) + model.other.push(...[applicationDoneOption, hideApplicantsFromArchivedVacanciesOption]) } return model } @@ -997,7 +998,7 @@ export function createModel (builder: Builder): void { ['modifiedOn', SortingOrder.Descending], ['createdOn', SortingOrder.Descending] ], - other: [] + other: [vacancyHideArchivedOption] } }, recruit.viewlet.ListVacancy diff --git a/models/recruit/src/plugin.ts b/models/recruit/src/plugin.ts index 8da64de07c..6cc38b51b9 100644 --- a/models/recruit/src/plugin.ts +++ b/models/recruit/src/plugin.ts @@ -72,7 +72,8 @@ export default mergeIds(recruitId, recruit, { ConfigDescription: '' as IntlString, ShowApplications: '' as IntlString, HideDoneState: '' as IntlString, - HideArchivedVacancies: '' as IntlString + HideArchivedVacancies: '' as IntlString, + HideApplicantsFromArchivedVacancies: '' as IntlString }, validator: { ApplicantValidator: '' as Resource<(doc: T, client: Client) => Promise> diff --git a/plugins/recruit-assets/lang/en.json b/plugins/recruit-assets/lang/en.json index f5199a64e7..d70b93f46f 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 archived Vacancies", + "HideApplicantsFromArchivedVacancies": "Hide from archived Vacancies", "CreateNewSkills": "Create new skills if existing not found" }, "status": { diff --git a/plugins/recruit-assets/lang/ru.json b/plugins/recruit-assets/lang/ru.json index c28f3b9e60..96fb4d6d3f 100644 --- a/plugins/recruit-assets/lang/ru.json +++ b/plugins/recruit-assets/lang/ru.json @@ -120,6 +120,7 @@ "GetTalentIds": "Получить ID талантов", "HideDoneState": "Скрыть завершенных кандидатов", "HideArchivedVacancies": "Скрыть архивные вакансии", + "HideApplicantsFromArchivedVacancies": "Скрыть из архивных вакансии", "CreateNewSkills": "Создать навыки, если не найдены существующие" }, "status": { diff --git a/plugins/recruit-resources/src/components/Vacancies.svelte b/plugins/recruit-resources/src/components/Vacancies.svelte index 7cc690b175..71a08adb1f 100644 --- a/plugins/recruit-resources/src/components/Vacancies.svelte +++ b/plugins/recruit-resources/src/components/Vacancies.svelte @@ -22,8 +22,6 @@ import recruit from '../plugin' import CreateVacancy from './CreateVacancy.svelte' - export let archived = false - let search: string = '' let searchQuery: DocumentQuery = {} let resultQuery: DocumentQuery = {} @@ -191,7 +189,7 @@ viewOptionsConfig: viewlet.viewOptions?.other, query: { ...resultQuery, - archived + ...(viewOptions?.hideArchived !== false ? { archived: false } : {}) }, totalQuery: {}, tableId: 'vacanciesData' diff --git a/plugins/view-resources/src/components/ViewOptions.svelte b/plugins/view-resources/src/components/ViewOptions.svelte index 460befa241..31bf921cb8 100644 --- a/plugins/view-resources/src/components/ViewOptions.svelte +++ b/plugins/view-resources/src/components/ViewOptions.svelte @@ -65,49 +65,62 @@ dispatch('update', { key: model.key, value: viewOptions[model.key] }) } + // checking if selector provides multiple choice options + const hasMultipleSelections = (varTocheck: any) => { + if (!varTocheck) return false + if (Array.isArray(varTocheck)) { + return varTocheck.filter((item) => item !== undefined && item !== null && item !== '').length > 1 + } + return true + } + $: visibleOthers = config.other.filter((p) => !p.hidden?.(viewOptions))