mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-22 08:20:39 +00:00
Vacancy search fix (#1192)
Signed-off-by: Denis Bykhov <80476319+BykhovDenis@users.noreply.github.com>
This commit is contained in:
parent
61ee083d0e
commit
90955638c5
@ -49,7 +49,8 @@ export type DocumentQuery<T extends Doc> = {
|
|||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
export type ToClassRefT<T extends object, P extends keyof T> = T[P] extends Ref<infer X> | null ? Ref<Class<X>> | [Ref<Class<X>>, Lookup<X>] : never
|
export type ToClassRefT<T extends object, P extends keyof T> = T[P] extends Ref<infer X> | null | undefined ? Ref<Class<X>> | [Ref<Class<X>>, Lookup<X>] : never
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
@ -65,7 +66,7 @@ export type RefKeys<T extends Doc> = Pick<T, KeysByType<T, NullableRef>>
|
|||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
export type NullableRef = Ref<Doc> | null
|
export type NullableRef = Ref<Doc> | null | undefined
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
@ -123,7 +124,7 @@ export enum SortingOrder {
|
|||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
export type RefsAsDocs<T> = {
|
export type RefsAsDocs<T> = {
|
||||||
[P in keyof T]: T[P] extends Ref<infer X> | null ? (T extends X ? X : X | WithLookup<X>) : AttachedDoc[]
|
[P in keyof T]: T[P] extends Ref<infer X> | null | undefined ? (T extends X ? X : X | WithLookup<X>) : AttachedDoc[]
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
-->
|
-->
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import contact from '@anticrm/contact'
|
import contact from '@anticrm/contact'
|
||||||
import core, { Doc, DocumentQuery, Lookup, Ref } from '@anticrm/core'
|
import core, { Doc, DocumentQuery, Lookup, Ref, WithLookup } from '@anticrm/core'
|
||||||
import { createQuery } from '@anticrm/presentation'
|
import { createQuery } from '@anticrm/presentation'
|
||||||
import { Applicant, Vacancy } from '@anticrm/recruit'
|
import { Applicant, Vacancy } from '@anticrm/recruit'
|
||||||
import { Button, getCurrentLocation, Icon, Label, navigate, Scroller, showPopup, IconAdd } from '@anticrm/ui'
|
import { Button, getCurrentLocation, Icon, Label, navigate, Scroller, showPopup, IconAdd } from '@anticrm/ui'
|
||||||
@ -35,16 +35,20 @@
|
|||||||
let resultQuery: DocumentQuery<Doc> = {}
|
let resultQuery: DocumentQuery<Doc> = {}
|
||||||
let vacancyQuery: DocumentQuery<Doc> = {}
|
let vacancyQuery: DocumentQuery<Doc> = {}
|
||||||
|
|
||||||
let vacancies: Vacancy[] = []
|
let vacancies: WithLookup<Vacancy>[] = []
|
||||||
const query = createQuery()
|
const query = createQuery()
|
||||||
let appQuery = false
|
let appQuery = false
|
||||||
|
|
||||||
|
const lookup: Lookup<Vacancy> = {
|
||||||
|
company: contact.class.Organization
|
||||||
|
}
|
||||||
|
|
||||||
$: query.query(recruit.class.Vacancy, { archived: false }, (res) => {
|
$: query.query(recruit.class.Vacancy, { archived: false }, (res) => {
|
||||||
vacancies = res
|
vacancies = res
|
||||||
})
|
}, { lookup })
|
||||||
|
|
||||||
function lowerIncludes (a: string | undefined, b: string): boolean {
|
function lowerIncludes (a: string | undefined, b: string): boolean {
|
||||||
return (a ?? '').toLowerCase().includes(b)
|
return (a ?? '').toLowerCase().includes(b.toLowerCase())
|
||||||
}
|
}
|
||||||
|
|
||||||
$: if (vacancies.length > 0 && !appQuery) {
|
$: if (vacancies.length > 0 && !appQuery) {
|
||||||
@ -55,7 +59,7 @@
|
|||||||
(it) =>
|
(it) =>
|
||||||
lowerIncludes(it.name, vquery) ||
|
lowerIncludes(it.name, vquery) ||
|
||||||
lowerIncludes(it.description, vquery) ||
|
lowerIncludes(it.description, vquery) ||
|
||||||
lowerIncludes(it.company, vquery) ||
|
lowerIncludes(it.$lookup?.company?.name, vquery) ||
|
||||||
(applications?.get(it._id) ?? 0) > 0
|
(applications?.get(it._id) ?? 0) > 0
|
||||||
)
|
)
|
||||||
.map((it) => it._id)
|
.map((it) => it._id)
|
||||||
@ -89,10 +93,6 @@
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const lookup = {
|
|
||||||
company: contact.class.Organization
|
|
||||||
} as Lookup<Doc>
|
|
||||||
|
|
||||||
function showCreateDialog (ev: Event) {
|
function showCreateDialog (ev: Event) {
|
||||||
showPopup(CreateVacancy, { space: recruit.space.CandidatesPublic }, ev.target as HTMLElement)
|
showPopup(CreateVacancy, { space: recruit.space.CandidatesPublic }, ev.target as HTMLElement)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user