mirror of
https://github.com/hcengineering/platform.git
synced 2024-11-22 21:50:34 +03: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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
@ -65,7 +66,7 @@ export type RefKeys<T extends Doc> = Pick<T, KeysByType<T, NullableRef>>
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export type NullableRef = Ref<Doc> | null
|
||||
export type NullableRef = Ref<Doc> | null | undefined
|
||||
|
||||
/**
|
||||
* @public
|
||||
@ -123,7 +124,7 @@ export enum SortingOrder {
|
||||
* @public
|
||||
*/
|
||||
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">
|
||||
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 { Applicant, Vacancy } from '@anticrm/recruit'
|
||||
import { Button, getCurrentLocation, Icon, Label, navigate, Scroller, showPopup, IconAdd } from '@anticrm/ui'
|
||||
@ -35,16 +35,20 @@
|
||||
let resultQuery: DocumentQuery<Doc> = {}
|
||||
let vacancyQuery: DocumentQuery<Doc> = {}
|
||||
|
||||
let vacancies: Vacancy[] = []
|
||||
let vacancies: WithLookup<Vacancy>[] = []
|
||||
const query = createQuery()
|
||||
let appQuery = false
|
||||
|
||||
const lookup: Lookup<Vacancy> = {
|
||||
company: contact.class.Organization
|
||||
}
|
||||
|
||||
$: query.query(recruit.class.Vacancy, { archived: false }, (res) => {
|
||||
vacancies = res
|
||||
})
|
||||
}, { lookup })
|
||||
|
||||
function lowerIncludes (a: string | undefined, b: string): boolean {
|
||||
return (a ?? '').toLowerCase().includes(b)
|
||||
return (a ?? '').toLowerCase().includes(b.toLowerCase())
|
||||
}
|
||||
|
||||
$: if (vacancies.length > 0 && !appQuery) {
|
||||
@ -55,7 +59,7 @@
|
||||
(it) =>
|
||||
lowerIncludes(it.name, vquery) ||
|
||||
lowerIncludes(it.description, vquery) ||
|
||||
lowerIncludes(it.company, vquery) ||
|
||||
lowerIncludes(it.$lookup?.company?.name, vquery) ||
|
||||
(applications?.get(it._id) ?? 0) > 0
|
||||
)
|
||||
.map((it) => it._id)
|
||||
@ -89,10 +93,6 @@
|
||||
)
|
||||
}
|
||||
|
||||
const lookup = {
|
||||
company: contact.class.Organization
|
||||
} as Lookup<Doc>
|
||||
|
||||
function showCreateDialog (ev: Event) {
|
||||
showPopup(CreateVacancy, { space: recruit.space.CandidatesPublic }, ev.target as HTMLElement)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user