Use default space if no space is selected (#1670)

Signed-off-by: Sergei Ogorelkov <sergei.ogorelkov@xored.com>
This commit is contained in:
Sergei Ogorelkov 2022-05-06 13:42:45 +07:00 committed by GitHub
parent 8588404964
commit 472ee0537b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -14,13 +14,32 @@
-->
<script lang="ts">
import { Ref, Space } from '@anticrm/core'
import { getClient } from '@anticrm/presentation'
import { Button, showPopup } from '@anticrm/ui'
import tracker from '../plugin'
import CreateIssue from './CreateIssue.svelte'
export let currentSpace: Ref<Space>
export let currentSpace: Ref<Space> | undefined
const client = getClient()
let space: Ref<Space> | undefined
$: updateSpace(currentSpace)
async function updateSpace (spaceId: Ref<Space> | undefined): Promise<void> {
if (space) {
space = spaceId
return
}
const team = await client.findOne(tracker.class.Team, {})
space = team?._id
}
async function newIssue (): Promise<void> {
showPopup(CreateIssue, { space: currentSpace }, 'top')
if (space) {
showPopup(CreateIssue, { space }, 'top')
}
}
</script>
@ -31,7 +50,7 @@
label={tracker.string.NewIssue}
justify={'left'}
width={'100%'}
on:click={() => newIssue()}
on:click={newIssue}
/>
</div>
<Button icon={tracker.icon.Magnifier} on:click={async () => {}} />