Fix up down navigator (#3185)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov 2023-05-15 21:35:46 +06:00 committed by GitHub
parent 5081e6e048
commit aa265ef597
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 75 additions and 43 deletions

View File

@ -87,9 +87,11 @@
await save()
}
;[issue] = result
title = issue.title
description = issue.description
currentProject = issue.$lookup?.space
if (issue) {
title = issue.title
description = issue.description
currentProject = issue.$lookup?.space
}
},
{ lookup: { attachedTo: tracker.class.Issue, space: tracker.class.Project } }
)

View File

@ -1,17 +1,10 @@
<script lang="ts">
import { Doc } from '@hcengineering/core'
import { getClient } from '@hcengineering/presentation'
import ui, {
Button,
closeTooltip,
IconDownOutline,
IconNavPrev,
IconUpOutline,
navigate,
panelstore
} from '@hcengineering/ui'
import ui, { Button, closeTooltip, IconDownOutline, IconNavPrev, IconUpOutline, navigate } from '@hcengineering/ui'
import { tick } from 'svelte'
import { select } from '../actionImpl'
import view from '../plugin'
import { focusStore } from '../selection'
import { getObjectLinkFragment } from '../utils'
@ -22,10 +15,16 @@
async function next (evt: Event, pn: boolean): Promise<void> {
select(evt, pn ? 1 : -1, element, 'vertical')
await tick()
if ($focusStore.focus !== undefined && $panelstore.panel !== undefined) {
if ($focusStore.focus !== undefined) {
const doc = await client.findOne($focusStore.focus._class, { _id: $focusStore.focus._id })
if (doc !== undefined) {
const link = await getObjectLinkFragment(client.getHierarchy(), doc, {}, $panelstore.panel.component)
const component = client.getHierarchy().classHierarchyMixin(doc._class, view.mixin.ObjectPanel)
const link = await getObjectLinkFragment(
client.getHierarchy(),
doc,
{},
component?.component ?? view.component.EditDoc
)
navigate(link)
}
}
@ -39,20 +38,22 @@
$: select(undefined, 0, element, 'vertical')
</script>
<Button
focusIndex={10005}
icon={IconDownOutline}
kind={'secondary'}
size={'medium'}
on:click={(evt) => next(evt, true)}
/>
<Button
focusIndex={10006}
icon={IconUpOutline}
kind={'secondary'}
size={'medium'}
on:click={(evt) => next(evt, false)}
/>
{#if $focusStore.focus !== undefined && $focusStore.provider !== undefined}
<Button
focusIndex={10005}
icon={IconDownOutline}
kind={'secondary'}
size={'medium'}
on:click={(evt) => next(evt, true)}
/>
<Button
focusIndex={10006}
icon={IconUpOutline}
kind={'secondary'}
size={'medium'}
on:click={(evt) => next(evt, false)}
/>
{/if}
<Button
focusIndex={10007}
showTooltip={{ label: ui.string.Back, direction: 'bottom' }}

View File

@ -1,4 +1,4 @@
import { Doc } from '@hcengineering/core'
import { Doc, Ref } from '@hcengineering/core'
import { panelstore } from '@hcengineering/ui'
import { onDestroy } from 'svelte'
import { Unsubscriber, derived, writable } from 'svelte/store'
@ -124,6 +124,14 @@ export class ListSelectionProvider implements SelectionFocusProvider {
}
}
static Find (_id: Ref<Doc>): ListSelectionProvider | undefined {
for (const provider of providers) {
if (provider.docs().findIndex((p) => p._id === _id) !== -1) {
return provider
}
}
}
static Pop (): void {
if (providers.length === 0) return
const last = providers[providers.length - 1]

View File

@ -48,7 +48,14 @@
showPopup
} from '@hcengineering/ui'
import view from '@hcengineering/view'
import { ActionContext, ActionHandler, NavLink, migrateViewOpttions } from '@hcengineering/view-resources'
import {
ActionContext,
ActionHandler,
ListSelectionProvider,
NavLink,
migrateViewOpttions,
updateFocus
} from '@hcengineering/view-resources'
import type { Application, NavigatorModel, SpecialNavModel, ViewConfiguration } from '@hcengineering/workbench'
import { getContext, onDestroy, onMount, tick } from 'svelte'
import { get } from 'svelte/store'
@ -314,25 +321,39 @@
if (fragment !== currentFragment) {
currentFragment = fragment
if (fragment !== undefined && fragment.trim().length > 0) {
const props = decodeURIComponent(fragment).split('|')
if (props.length >= 3) {
openPanel(
props[0] as AnyComponent,
props[1],
props[2],
(props[3] ?? undefined) as PopupAlignment,
(props[4] ?? undefined) as AnyComponent
)
} else {
closePanel(false)
}
setOpenPanelFocus(fragment)
} else {
closePanel()
}
}
}
async function setOpenPanelFocus (fragment: string): Promise<void> {
const props = decodeURIComponent(fragment).split('|')
if (props.length >= 3) {
const doc = await client.findOne(props[2] as Ref<Class<Doc>>, { _id: props[1] as Ref<Doc> })
if (doc !== undefined) {
const provider = ListSelectionProvider.Find(doc._id)
updateFocus({
provider,
focus: doc
})
openPanel(
props[0] as AnyComponent,
props[1],
props[2],
(props[3] ?? undefined) as PopupAlignment,
(props[4] ?? undefined) as AnyComponent
)
} else {
closePanel(false)
}
} else {
closePanel(false)
}
}
function clear (level: number): void {
switch (level) {
case 1: