Hide archived spaces from dialogs

Closes #858
Closes #865

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev 2022-01-25 15:41:53 +07:00
parent e848480ef3
commit 2fbbfab597
No known key found for this signature in database
GPG Key ID: BD80F68D68D8F7F2
4 changed files with 12 additions and 8 deletions

View File

@ -18,7 +18,7 @@
import type { IntlString } from '@anticrm/platform' import type { IntlString } from '@anticrm/platform'
import { createEventDispatcher } from 'svelte' import { createEventDispatcher } from 'svelte'
import type { Ref, Class, Space } from '@anticrm/core' import type { Ref, Class, Space, DocumentQuery } from '@anticrm/core'
import { Button, Label } from '@anticrm/ui' import { Button, Label } from '@anticrm/ui'
import SpaceSelect from './SpaceSelect.svelte' import SpaceSelect from './SpaceSelect.svelte'
@ -26,6 +26,7 @@
export let spaceClass: Ref<Class<Space>> | undefined = undefined export let spaceClass: Ref<Class<Space>> | undefined = undefined
export let space: Ref<Space> export let space: Ref<Space>
export let spaceQuery: DocumentQuery<Space> | undefined = { archived: false }
export let spaceLabel: IntlString | undefined = undefined export let spaceLabel: IntlString | undefined = undefined
export let spacePlaceholder: IntlString | undefined = undefined export let spacePlaceholder: IntlString | undefined = undefined
export let label: IntlString export let label: IntlString
@ -52,7 +53,7 @@
{#if spaceClass && spaceLabel && spacePlaceholder} {#if spaceClass && spaceLabel && spacePlaceholder}
<div class="flex-col pool"> <div class="flex-col pool">
<div class="separator" /> <div class="separator" />
<SpaceSelect _class={spaceClass} label={spaceLabel} placeholder={spacePlaceholder} bind:value={space} /> <SpaceSelect _class={spaceClass} spaceQuery={spaceQuery} label={spaceLabel} placeholder={spacePlaceholder} bind:value={space} />
</div> </div>
{/if} {/if}
<div class="footer"> <div class="footer">

View File

@ -20,9 +20,10 @@
import { Label, showPopup, IconFolder } from '@anticrm/ui' import { Label, showPopup, IconFolder } from '@anticrm/ui'
import SpacesPopup from './SpacesPopup.svelte' import SpacesPopup from './SpacesPopup.svelte'
import type { Ref, Class, Space } from '@anticrm/core' import type { Ref, Class, Space, DocumentQuery } from '@anticrm/core'
export let _class: Ref<Class<Space>> export let _class: Ref<Class<Space>>
export let spaceQuery: DocumentQuery<Space> | undefined = { archived: false }
export let label: IntlString export let label: IntlString
export let placeholder: IntlString export let placeholder: IntlString
export let value: Ref<Space> export let value: Ref<Space>
@ -33,8 +34,8 @@
const client = getClient() const client = getClient()
async function updateSelected(value: Ref<Space>) { async function updateSelected (value: Ref<Space>) {
selected = await client.findOne(_class, { _id: value }) selected = await client.findOne(_class, { ...(spaceQuery ?? {}), _id: value })
} }
$: updateSelected(value) $: updateSelected(value)
@ -50,7 +51,7 @@
<div class="flex-col cursor-pointer" <div class="flex-col cursor-pointer"
bind:this={btn} bind:this={btn}
on:click|preventDefault={() => { on:click|preventDefault={() => {
showPopup(SpacesPopup, { _class }, btn, (result) => { showPopup(SpacesPopup, { _class, spaceQuery }, btn, (result) => {
if (result) { if (result) {
value = result._id value = result._id
} }

View File

@ -18,17 +18,18 @@
import ui, { Label, EditWithIcon, IconSearch } from '@anticrm/ui' import ui, { Label, EditWithIcon, IconSearch } from '@anticrm/ui'
import SpaceInfo from './SpaceInfo.svelte' import SpaceInfo from './SpaceInfo.svelte'
import type { Ref, Class, Space } from '@anticrm/core' import type { Ref, Class, Space, DocumentQuery } from '@anticrm/core'
import { createQuery } from '../utils' import { createQuery } from '../utils'
export let _class: Ref<Class<Space>> export let _class: Ref<Class<Space>>
export let spaceQuery: DocumentQuery<Space> | undefined
let search: string = '' let search: string = ''
let objects: Space[] = [] let objects: Space[] = []
const dispatch = createEventDispatcher() const dispatch = createEventDispatcher()
const query = createQuery() const query = createQuery()
$: query.query(_class, {}, result => { objects = result }) $: query.query(_class, { ...(spaceQuery ?? {}) }, result => { objects = result })
afterUpdate(() => { dispatch('update', Date.now()) }) afterUpdate(() => { dispatch('update', Date.now()) })
</script> </script>

View File

@ -122,6 +122,7 @@
okAction={createApplication} okAction={createApplication}
canSave={status.severity === Severity.OK} canSave={status.severity === Severity.OK}
spaceClass={recruit.class.Vacancy} spaceClass={recruit.class.Vacancy}
spaceQuery={{ archived: false }}
spaceLabel={recruit.string.Vacancy} spaceLabel={recruit.string.Vacancy}
spacePlaceholder={recruit.string.SelectVacancy} spacePlaceholder={recruit.string.SelectVacancy}
bind:space={doc.space} bind:space={doc.space}