Vacancy search fix (#1192)

Signed-off-by: Denis Bykhov <80476319+BykhovDenis@users.noreply.github.com>
This commit is contained in:
Denis Bykhov 2022-03-22 15:13:17 +06:00 committed by GitHub
parent 61ee083d0e
commit 90955638c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 12 deletions

View File

@ -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[]
}
/**

View File

@ -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)
}