Clear space on app change (#970)

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev 2022-02-08 21:33:56 +07:00 committed by GitHub
parent 738354e9ac
commit e7fb57d9fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 15 deletions

View File

@ -16,24 +16,20 @@
<script lang="ts"> <script lang="ts">
import type { Ref } from '@anticrm/core' import type { Ref } from '@anticrm/core'
import { getCurrentLocation, navigate } from '@anticrm/ui'
import type { Application } from '@anticrm/workbench' import type { Application } from '@anticrm/workbench'
import { createEventDispatcher } from 'svelte'
import AppItem from './AppItem.svelte' import AppItem from './AppItem.svelte'
export let active: Ref<Application> | undefined export let active: Ref<Application> | undefined
export let apps: Application[] = [] export let apps: Application[] = []
function navigateApp (app: Ref<Application>) { const dispatch = createEventDispatcher()
const loc = getCurrentLocation()
loc.path[1] = app
loc.path.length = 2
navigate(loc)
}
</script> </script>
<div class="flex-col"> <div class="flex-col">
{#each apps as app} {#each apps as app}
<AppItem selected={app._id === active} icon={app.icon} label={app.label} action={async () => { navigateApp(app._id) }} notify={false}/> <AppItem selected={app._id === active} icon={app.icon} label={app.label} action={async () => {
dispatch('active', app)
}} notify={false}/>
{/each} {/each}
</div> </div>

View File

@ -14,7 +14,7 @@
--> -->
<script lang="ts"> <script lang="ts">
import contact, { Employee, EmployeeAccount } from '@anticrm/contact' import contact, { Employee, EmployeeAccount } from '@anticrm/contact'
import core, { Client, Doc, getCurrentAccount, Ref, Space } from '@anticrm/core' import core, { Client, getCurrentAccount, Ref, Space } from '@anticrm/core'
import { Avatar, createQuery, setClient } from '@anticrm/presentation' import { Avatar, createQuery, setClient } from '@anticrm/presentation'
import { import {
AnyComponent, AnyComponent,
@ -22,11 +22,9 @@
Component, Component,
getCurrentLocation, getCurrentLocation,
location, location,
navigate, navigate, PanelInstance, Popup,
Popup,
showPopup, showPopup,
TooltipInstance, TooltipInstance
PanelInstance
} from '@anticrm/ui' } from '@anticrm/ui'
import type { Application, NavigatorModel, ViewConfiguration } from '@anticrm/workbench' import type { Application, NavigatorModel, ViewConfiguration } from '@anticrm/workbench'
import { onDestroy } from 'svelte' import { onDestroy } from 'svelte'
@ -170,6 +168,26 @@
let isNavigate: boolean = false let isNavigate: boolean = false
$: isNavigate = !!navigatorModel $: isNavigate = !!navigatorModel
function navigateApp (app: Application) {
if (currentApp === app._id) {
// Nothing to do.
return
}
currentApp = app._id
currentApplication = app
navigatorModel = currentApplication?.navigatorModel
currentSpace = undefined
currentSpecial = undefined
currentView = undefined
createItemDialog = undefined
const loc = getCurrentLocation()
loc.path[1] = app._id
loc.path.length = 2
navigate(loc)
}
</script> </script>
{#if client} {#if client}
@ -195,7 +213,9 @@
notify={false} notify={false}
/> />
</div> </div>
<Applications {apps} active={currentApp} /> <Applications {apps} active={currentApp} on:active={(evt) => {
navigateApp(evt.detail)
}} />
<div class="flex-center" style="min-height: 6.25rem;"> <div class="flex-center" style="min-height: 6.25rem;">
<div <div
class="cursor-pointer" class="cursor-pointer"