From 48be42610e2321e0026786bddb3f9256e0803b22 Mon Sep 17 00:00:00 2001 From: Denis Bykhov Date: Wed, 22 Mar 2023 11:25:28 +0600 Subject: [PATCH] vacancy application table (#2801) Signed-off-by: Denis Bykhov --- models/recruit/src/index.ts | 11 +++ .../src/components/VacancyApplications.svelte | 74 ++++++++++++++----- plugins/recruit-resources/src/plugin.ts | 5 +- 3 files changed, 70 insertions(+), 20 deletions(-) diff --git a/models/recruit/src/index.ts b/models/recruit/src/index.ts index 00594917e2..64166c7fce 100644 --- a/models/recruit/src/index.ts +++ b/models/recruit/src/index.ts @@ -393,6 +393,17 @@ export function createModel (builder: Builder): void { recruit.viewlet.TableCandidate ) + builder.createDoc( + view.class.Viewlet, + core.space.Model, + { + attachTo: recruit.class.Applicant, + descriptor: view.viewlet.Table, + config: ['', 'attachedTo', 'state', 'doneState', 'modifiedOn'] + }, + recruit.viewlet.VacancyApplicationsShort + ) + builder.createDoc( view.class.Viewlet, core.space.Model, diff --git a/plugins/recruit-resources/src/components/VacancyApplications.svelte b/plugins/recruit-resources/src/components/VacancyApplications.svelte index 01238e2344..de3102e7e0 100644 --- a/plugins/recruit-resources/src/components/VacancyApplications.svelte +++ b/plugins/recruit-resources/src/components/VacancyApplications.svelte @@ -16,9 +16,19 @@ import type { Ref } from '@hcengineering/core' import { createQuery } from '@hcengineering/presentation' import { recruitId, Vacancy } from '@hcengineering/recruit' - import { Button, Icon, IconAdd, Label, NavLink, resizeObserver, Scroller, showPopup } from '@hcengineering/ui' - import { BuildModelKey } from '@hcengineering/view' - import { Table } from '@hcengineering/view-resources' + import { + Button, + Icon, + IconAdd, + Label, + Loading, + NavLink, + resizeObserver, + Scroller, + showPopup + } from '@hcengineering/ui' + import view, { Viewlet, ViewletPreference } from '@hcengineering/view' + import { getViewOptions, Table, ViewletSettingButton, viewOptionStore } from '@hcengineering/view-resources' import recruit from '../plugin' import CreateApplication from './CreateApplication.svelte' import IconApplication from './icons/Application.svelte' @@ -35,17 +45,36 @@ const createApp = (ev: MouseEvent): void => { showPopup(CreateApplication, { space: objectId, preserveVacancy: true }, ev.target as HTMLElement) } - const config: (BuildModelKey | string)[] = [ - '', - '$lookup.space.name', - '$lookup.space.$lookup.company', - 'state', - 'doneState' - ] let wSection: number + + let viewlet: Viewlet | undefined + let preference: ViewletPreference | undefined + let loading = true + + const viewletQuery = createQuery() + $: viewletQuery.query(view.class.Viewlet, { _id: recruit.viewlet.VacancyApplicationsShort }, (res) => { + ;[viewlet] = res + }) + + $: viewOptions = viewlet !== undefined ? getViewOptions(viewlet, $viewOptionStore) : undefined + + const preferenceQuery = createQuery() + + $: viewlet && + preferenceQuery.query( + view.class.ViewletPreference, + { + attachedTo: viewlet._id + }, + (res) => { + preference = res[0] + loading = false + }, + { limit: 1 } + ) -
(wSection = element.clientWidth)}> +
(wSection = element.clientWidth)}>
@@ -55,17 +84,24 @@
{#if applications > 0} - - - + {#if viewlet && !loading} + +
+ + {:else} + + {/if} {:else}
diff --git a/plugins/recruit-resources/src/plugin.ts b/plugins/recruit-resources/src/plugin.ts index 83802e94e2..e7e7e3759d 100644 --- a/plugins/recruit-resources/src/plugin.ts +++ b/plugins/recruit-resources/src/plugin.ts @@ -20,9 +20,12 @@ import { ObjectSearchCategory, ObjectSearchFactory } from '@hcengineering/presen import recruit, { recruitId } from '@hcengineering/recruit' import { TagCategory } from '@hcengineering/tags' import { AnyComponent } from '@hcengineering/ui' -import { FilterFunction, FilterMode } from '@hcengineering/view' +import { FilterFunction, FilterMode, Viewlet } from '@hcengineering/view' export default mergeIds(recruitId, recruit, { + viewlet: { + VacancyApplicationsShort: '' as Ref + }, status: { ApplicationExists: '' as StatusCode, TalentRequired: '' as StatusCode,