hide archieved vacanies toggle in viewoptions (#4220)

Signed-off-by: Sergey Voytsehovich <syargreg@gmail.com>
This commit is contained in:
Sergey Voytsehovich 2023-12-21 10:50:49 +03:00 committed by GitHub
parent f0dbfe3971
commit c705fd385c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 122 additions and 55 deletions

View File

@ -272,7 +272,6 @@ export function createModel (builder: Builder): void {
const talentsId = 'talents' const talentsId = 'talents'
const skillsId = 'skills' const skillsId = 'skills'
const candidatesId = 'candidates' const candidatesId = 'candidates'
const archiveId = 'archive'
const myApplicationsId = 'my-applications' const myApplicationsId = 'my-applications'
const organizationsId = 'organizations' const organizationsId = 'organizations'
@ -341,18 +340,6 @@ export function createModel (builder: Builder): void {
}, },
position: 'vacancy' 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, id: skillsId,
component: recruit.component.SkillsView, component: recruit.component.SkillsView,
@ -502,6 +489,14 @@ export function createModel (builder: Builder): void {
recruit.viewlet.VacancyApplicationsEmbeddeed recruit.viewlet.VacancyApplicationsEmbeddeed
) )
// hiding arhived vacancies from vacancy view
const vacancyHideArchivedOption: ViewOptionModel = {
key: 'hideArchived',
type: 'toggle',
defaultValue: true,
label: recruit.string.HideArchivedVacancies
}
builder.createDoc( builder.createDoc(
view.class.Viewlet, view.class.Viewlet,
core.space.Model, core.space.Model,
@ -535,6 +530,11 @@ export function createModel (builder: Builder): void {
configOptions: { configOptions: {
hiddenKeys: ['name', 'space', 'modifiedOn'], hiddenKeys: ['name', 'space', 'modifiedOn'],
sortable: true sortable: true
},
viewOptions: {
groupBy: [],
orderBy: [],
other: [vacancyHideArchivedOption]
} }
}, },
recruit.viewlet.TableVacancy recruit.viewlet.TableVacancy
@ -730,13 +730,14 @@ export function createModel (builder: Builder): void {
label: recruit.string.HideDoneState label: recruit.string.HideDoneState
} }
const vacancyHideOption: ViewOptionModel = { // hiding applicants related to archived vacancies from applicants view
const hideApplicantsFromArchivedVacanciesOption: ViewOptionModel = {
key: 'hideArchivedVacancies', key: 'hideArchivedVacancies',
type: 'toggle', type: 'toggle',
defaultValue: true, defaultValue: true,
actionTarget: 'query', actionTarget: 'query',
action: recruit.function.HideArchivedVacancies, action: recruit.function.HideArchivedVacancies,
label: recruit.string.HideArchivedVacancies label: recruit.string.HideApplicantsFromArchivedVacancies
} }
const applicantViewOptions = (colors: boolean, hides: boolean): ViewOptionsModel => { const applicantViewOptions = (colors: boolean, hides: boolean): ViewOptionsModel => {
@ -764,7 +765,7 @@ export function createModel (builder: Builder): void {
model.other.push(showColorsViewOption) model.other.push(showColorsViewOption)
} }
if (hides) { if (hides) {
model.other.push(...[applicationDoneOption, vacancyHideOption]) model.other.push(...[applicationDoneOption, hideApplicantsFromArchivedVacanciesOption])
} }
return model return model
} }
@ -997,7 +998,7 @@ export function createModel (builder: Builder): void {
['modifiedOn', SortingOrder.Descending], ['modifiedOn', SortingOrder.Descending],
['createdOn', SortingOrder.Descending] ['createdOn', SortingOrder.Descending]
], ],
other: [] other: [vacancyHideArchivedOption]
} }
}, },
recruit.viewlet.ListVacancy recruit.viewlet.ListVacancy

View File

@ -72,7 +72,8 @@ export default mergeIds(recruitId, recruit, {
ConfigDescription: '' as IntlString, ConfigDescription: '' as IntlString,
ShowApplications: '' as IntlString, ShowApplications: '' as IntlString,
HideDoneState: '' as IntlString, HideDoneState: '' as IntlString,
HideArchivedVacancies: '' as IntlString HideArchivedVacancies: '' as IntlString,
HideApplicantsFromArchivedVacancies: '' as IntlString
}, },
validator: { validator: {
ApplicantValidator: '' as Resource<<T extends Doc>(doc: T, client: Client) => Promise<Status>> ApplicantValidator: '' as Resource<<T extends Doc>(doc: T, client: Client) => Promise<Status>>

View File

@ -119,7 +119,8 @@
"ShowApplications": "Show applications", "ShowApplications": "Show applications",
"GetTalentIds": "Get talents' ids", "GetTalentIds": "Get talents' ids",
"HideDoneState": "Hide complete applications", "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" "CreateNewSkills": "Create new skills if existing not found"
}, },
"status": { "status": {

View File

@ -120,6 +120,7 @@
"GetTalentIds": "Получить ID талантов", "GetTalentIds": "Получить ID талантов",
"HideDoneState": "Скрыть завершенных кандидатов", "HideDoneState": "Скрыть завершенных кандидатов",
"HideArchivedVacancies": "Скрыть архивные вакансии", "HideArchivedVacancies": "Скрыть архивные вакансии",
"HideApplicantsFromArchivedVacancies": "Скрыть из архивных вакансии",
"CreateNewSkills": "Создать навыки, если не найдены существующие" "CreateNewSkills": "Создать навыки, если не найдены существующие"
}, },
"status": { "status": {

View File

@ -22,8 +22,6 @@
import recruit from '../plugin' import recruit from '../plugin'
import CreateVacancy from './CreateVacancy.svelte' import CreateVacancy from './CreateVacancy.svelte'
export let archived = false
let search: string = '' let search: string = ''
let searchQuery: DocumentQuery<Doc> = {} let searchQuery: DocumentQuery<Doc> = {}
let resultQuery: DocumentQuery<Doc> = {} let resultQuery: DocumentQuery<Doc> = {}
@ -191,7 +189,7 @@
viewOptionsConfig: viewlet.viewOptions?.other, viewOptionsConfig: viewlet.viewOptions?.other,
query: { query: {
...resultQuery, ...resultQuery,
archived ...(viewOptions?.hideArchived !== false ? { archived: false } : {})
}, },
totalQuery: {}, totalQuery: {},
tableId: 'vacanciesData' tableId: 'vacanciesData'

View File

@ -65,49 +65,62 @@
dispatch('update', { key: model.key, value: viewOptions[model.key] }) 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)) $: visibleOthers = config.other.filter((p) => !p.hidden?.(viewOptions))
</script> </script>
<div class="antiCard dialog menu"> <div class="antiCard dialog menu">
<div class="antiCard-menu__spacer" /> <div class="antiCard-menu__spacer" />
{#each groups as group, i} {#if hasMultipleSelections(config.groupBy)}
<div class="antiCard-menu__item grouping"> {#each groups as group, i}
<span class="overflow-label"><Label label={i === 0 ? view.string.Grouping : view.string.Then} /></span> <div class="antiCard-menu__item grouping">
<span class="overflow-label"><Label label={i === 0 ? view.string.Grouping : view.string.Then} /></span>
<DropdownLabelsIntl
label={view.string.Grouping}
kind={'regular'}
size={'medium'}
items={getItems(groupBy, i, viewOptions.groupBy)}
selected={group}
width="10rem"
justify="left"
on:selected={(e) => {
selectGrouping(e.detail, i)
}}
/>
</div>
{/each}
{/if}
{#if hasMultipleSelections(config.orderBy)}
<div class="antiCard-menu__item ordering">
<span class="overflow-label"><Label label={view.string.Ordering} /></span>
<DropdownLabelsIntl <DropdownLabelsIntl
label={view.string.Grouping} label={view.string.Ordering}
kind={'regular'} kind={'regular'}
size={'medium'} size={'medium'}
items={getItems(groupBy, i, viewOptions.groupBy)} items={orderBy}
selected={group} selected={viewOptions.orderBy?.[0]}
width="10rem" width="10rem"
justify="left" justify="left"
on:selected={(e) => { on:selected={(e) => {
selectGrouping(e.detail, i) const key = e.detail
const value = config.orderBy.find((p) => p[0] === key)
if (value !== undefined) {
viewOptions.orderBy = value
dispatch('update', { key: 'orderBy', value })
}
}} }}
/> />
</div> </div>
{/each} {/if}
<div class="antiCard-menu__item ordering"> {#if visibleOthers.length > 0 && (hasMultipleSelections(config.groupBy) || hasMultipleSelections(config.orderBy))}
<span class="overflow-label"><Label label={view.string.Ordering} /></span>
<DropdownLabelsIntl
label={view.string.Ordering}
kind={'regular'}
size={'medium'}
items={orderBy}
selected={viewOptions.orderBy?.[0]}
width="10rem"
justify="left"
on:selected={(e) => {
const key = e.detail
const value = config.orderBy.find((p) => p[0] === key)
if (value !== undefined) {
viewOptions.orderBy = value
dispatch('update', { key: 'orderBy', value })
}
}}
/>
</div>
{#if visibleOthers.length > 0}
<div class="antiCard-menu__divider" /> <div class="antiCard-menu__divider" />
{/if} {/if}
{#each visibleOthers as model} {#each visibleOthers as model}

View File

@ -66,8 +66,8 @@ function _getViewOptions (viewlet: Viewlet, viewOptionStore: Map<string, ViewOpt
function getDefaults (viewOptions: ViewOptionsModel): ViewOptions { function getDefaults (viewOptions: ViewOptionsModel): ViewOptions {
const res: ViewOptions = { const res: ViewOptions = {
groupBy: [viewOptions.groupBy[0]], groupBy: [viewOptions.groupBy[0] ?? defaulOptions.groupBy[0]],
orderBy: viewOptions.orderBy?.[0] orderBy: viewOptions.orderBy?.[0] ?? defaulOptions.orderBy
} }
for (const opt of viewOptions.other) { for (const opt of viewOptions.other) {
res[opt.key] = opt.defaultValue res[opt.key] = opt.defaultValue

View File

@ -43,7 +43,26 @@ export class VacanciesPage extends CommonRecruitingPage {
await this.page.locator('tr', { hasText: vacancyName }).locator('div[class$="firstCell"]').click() await this.page.locator('tr', { hasText: vacancyName }).locator('div[class$="firstCell"]').click()
} }
async checkVacancyNotExist (vacancyName: string): Promise<void> { async rightClickVacancyByName (vacancyName: string): Promise<void> {
await expect(this.page.locator('tr', { hasText: vacancyName })).toHaveCount(0) await this.page
.locator('tr', { hasText: vacancyName })
.locator('div[class$="firstCell"]')
.click({ button: 'right' })
}
async archiveVacancyByName (vacancyName: string): Promise<void> {
await this.rightClickVacancyByName(vacancyName)
await this.page.waitForSelector('div.antiPopup :text("Archive")')
await this.page.locator('div.antiPopup :text("Archive")').click()
await this.page.waitForSelector('div.msgbox-container :text("Ok")')
await this.page.locator('div.msgbox-container :text("Ok")').click()
}
async checkVacancyNotExist (vacancyName: string, message: string): Promise<void> {
await expect(this.page.locator('tr', { hasText: vacancyName }), message).toHaveCount(0)
}
async checkVacancyExist (vacancyName: string, message: string): Promise<void> {
await expect(this.page.locator('tr', { hasText: vacancyName }), message).toHaveCount(1)
} }
} }

View File

@ -108,4 +108,37 @@ test.describe('Vacancy tests', () => {
await vacancyDetailsPage.addCompany('Apple') await vacancyDetailsPage.addCompany('Apple')
await vacancyDetailsPage.addDueDateToday() await vacancyDetailsPage.addDueDateToday()
}) })
test('Filter vacancies', async ({ page }) => {
// viable when test set of vacancies fits to single page
const vacancyName = 'Archive Vacancy ' + generateId(5)
const navigationMenuPage = new NavigationMenuPage(page)
await navigationMenuPage.buttonVacancies.click()
const vacanciesPage = new VacanciesPage(page)
await vacanciesPage.createNewVacancy({
title: vacancyName,
description: 'Vacancy description from Filter vacancies test',
location: 'Filter vacancies location'
})
await vacanciesPage.checkVacancyExist(vacancyName, `Created vacancy "${vacancyName}" visible by default.`)
await vacanciesPage.archiveVacancyByName(vacancyName)
await vacanciesPage.checkVacancyNotExist(vacancyName, `Archieved vacancy "${vacancyName}" not visible by default.`)
await page.click("button:has-text('View')")
await page.waitForSelector(".antiCard-menu__item:has-text('Hide archived vacancies')")
await page.click(".antiCard-menu__item:has-text('Hide archived vacancies')")
await vacanciesPage.checkVacancyExist(
vacancyName,
`Archieved vacancy "${vacancyName}" visible when hide archved off.`
)
await page.click(".antiCard-menu__item:has-text('Hide archived vacancies')")
await vacanciesPage.checkVacancyNotExist(
vacancyName,
`Archieved vacancy "${vacancyName}" not visible when hide archved back on.`
)
})
}) })