mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-24 01:07:50 +00:00
TSK-840. Fixed focusing in the menu (#2770)
Signed-off-by: Alexander Platov <sas_lord@mail.ru>
This commit is contained in:
parent
9460e7a406
commit
6bdc76351a
@ -159,7 +159,6 @@
|
|||||||
color: var(--accent-color);
|
color: var(--accent-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
&.bordered { border-color: var(--divider-color); }
|
|
||||||
&:hover, &.hovered, &.selected {
|
&:hover, &.hovered, &.selected {
|
||||||
background-color: var(--menu-bg-select);
|
background-color: var(--menu-bg-select);
|
||||||
.an-element__icon { color: var(--menu-icon-hover); }
|
.an-element__icon { color: var(--menu-icon-hover); }
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
export let currentSpace: Ref<Space> | undefined
|
export let currentSpace: Ref<Space> | undefined
|
||||||
export let currentSpecial: string | undefined
|
export let currentSpecial: string | undefined
|
||||||
export let getActions: Function
|
export let getActions: Function
|
||||||
|
export let deselect: boolean = false
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if model.specials}
|
{#if model.specials}
|
||||||
@ -35,7 +36,7 @@
|
|||||||
indent={'ml-4'}
|
indent={'ml-4'}
|
||||||
label={special.label}
|
label={special.label}
|
||||||
icon={special.icon}
|
icon={special.icon}
|
||||||
selected={currentSpace === space._id && special.id === currentSpecial}
|
selected={deselect ? false : currentSpace === space._id && special.id === currentSpecial}
|
||||||
/>
|
/>
|
||||||
</NavLink>
|
</NavLink>
|
||||||
{/each}
|
{/each}
|
||||||
|
@ -28,7 +28,6 @@
|
|||||||
export let parent = false
|
export let parent = false
|
||||||
export let collapsed = false
|
export let collapsed = false
|
||||||
export let selected = false
|
export let selected = false
|
||||||
export let bordered = false
|
|
||||||
export let bold = false
|
export let bold = false
|
||||||
export let actions: () => Promise<Action[]> = async () => []
|
export let actions: () => Promise<Action[]> = async () => []
|
||||||
export let indent: 'default' | 'ml-2' | 'ml-4' | 'ml-8' = 'default'
|
export let indent: 'default' | 'ml-2' | 'ml-4' | 'ml-8' = 'default'
|
||||||
@ -48,7 +47,6 @@
|
|||||||
<div
|
<div
|
||||||
class="antiNav-element"
|
class="antiNav-element"
|
||||||
class:selected
|
class:selected
|
||||||
class:bordered
|
|
||||||
class:hovered
|
class:hovered
|
||||||
class:ml-2={indent === 'ml-2'}
|
class:ml-2={indent === 'ml-2'}
|
||||||
class:ml-4={indent === 'ml-4'}
|
class:ml-4={indent === 'ml-4'}
|
||||||
|
@ -24,9 +24,8 @@
|
|||||||
export let notifications = 0
|
export let notifications = 0
|
||||||
export let actions: () => Promise<Action[]> = async () => []
|
export let actions: () => Promise<Action[]> = async () => []
|
||||||
export let selected: boolean = false
|
export let selected: boolean = false
|
||||||
export let bordered: boolean = false
|
|
||||||
export let bold = false
|
export let bold = false
|
||||||
export let indent: 'default' | 'ml-2' | 'ml-4' | 'ml-8' = 'default'
|
export let indent: 'default' | 'ml-2' | 'ml-4' | 'ml-8' = 'default'
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<TreeElement {_id} {icon} {title} {notifications} {selected} {bordered} {actions} {bold} collapsed {indent} on:click />
|
<TreeElement {_id} {icon} {title} {notifications} {selected} {actions} {bold} collapsed {indent} on:click />
|
||||||
|
@ -134,6 +134,9 @@
|
|||||||
async function checkIsDisabled (special: SpecialNavModel) {
|
async function checkIsDisabled (special: SpecialNavModel) {
|
||||||
return special.checkIsDisabled && (await (await getResource(special.checkIsDisabled))())
|
return special.checkIsDisabled && (await (await getResource(special.checkIsDisabled))())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let savedMenu: boolean = false
|
||||||
|
let menuSelection: boolean = false
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if model}
|
{#if model}
|
||||||
@ -141,14 +144,14 @@
|
|||||||
{#if model.specials}
|
{#if model.specials}
|
||||||
{#each specials as special, row}
|
{#each specials as special, row}
|
||||||
{#if row > 0 && specials[row].position !== specials[row - 1].position}
|
{#if row > 0 && specials[row].position !== specials[row - 1].position}
|
||||||
<TreeSeparator />
|
<TreeSeparator line />
|
||||||
{/if}
|
{/if}
|
||||||
{#await checkIsDisabled(special) then disabled}
|
{#await checkIsDisabled(special) then disabled}
|
||||||
<NavLink space={special.id} {disabled}>
|
<NavLink space={special.id} {disabled}>
|
||||||
<SpecialElement
|
<SpecialElement
|
||||||
label={special.label}
|
label={special.label}
|
||||||
icon={special.icon}
|
icon={special.icon}
|
||||||
selected={special.id === currentSpecial}
|
selected={menuSelection ? false : special.id === currentSpecial}
|
||||||
indent={'ml-2'}
|
indent={'ml-2'}
|
||||||
{disabled}
|
{disabled}
|
||||||
/>
|
/>
|
||||||
@ -157,13 +160,18 @@
|
|||||||
{/each}
|
{/each}
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if specials.length > 0}<TreeSeparator />{/if}
|
{#if specials.length > 0 && (starred.length > 0 || savedMenu)}<TreeSeparator line />{/if}
|
||||||
<SavedView {currentApplication} />
|
<SavedView
|
||||||
|
{currentApplication}
|
||||||
|
on:shown={(res) => (savedMenu = res.detail)}
|
||||||
|
on:select={(res) => (menuSelection = res.detail)}
|
||||||
|
/>
|
||||||
{#if starred.length}
|
{#if starred.length}
|
||||||
<StarredNav label={preference.string.Starred} spaces={starred} on:space {currentSpace} />
|
<StarredNav label={preference.string.Starred} spaces={starred} on:space {currentSpace} />
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#each model.spaces as m (m.label)}
|
{#each model.spaces as m, i (m.label)}
|
||||||
|
{#if (i === 0 && (specials.length > 0 || starred.length || savedMenu)) || i !== 0}<TreeSeparator line />{/if}
|
||||||
<SpacesNav
|
<SpacesNav
|
||||||
spaces={shownSpaces.filter((it) => hierarchy.isDerived(it._class, m.spaceClass))}
|
spaces={shownSpaces.filter((it) => hierarchy.isDerived(it._class, m.spaceClass))}
|
||||||
{currentSpace}
|
{currentSpace}
|
||||||
@ -171,6 +179,8 @@
|
|||||||
model={m}
|
model={m}
|
||||||
on:open
|
on:open
|
||||||
{currentSpecial}
|
{currentSpecial}
|
||||||
|
deselect={menuSelection}
|
||||||
|
separate
|
||||||
/>
|
/>
|
||||||
{/each}
|
{/each}
|
||||||
<div class="antiNav-space" />
|
<div class="antiNav-space" />
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
import { Doc, Ref } from '@hcengineering/core'
|
import { Doc, Ref } from '@hcengineering/core'
|
||||||
import { createQuery, getClient } from '@hcengineering/presentation'
|
import { createQuery, getClient } from '@hcengineering/presentation'
|
||||||
import setting from '@hcengineering/setting'
|
import setting from '@hcengineering/setting'
|
||||||
import { Action, navigate } from '@hcengineering/ui'
|
import { Action, navigate, getCurrentLocation, location } from '@hcengineering/ui'
|
||||||
import view, { FilteredView } from '@hcengineering/view'
|
import view, { FilteredView } from '@hcengineering/view'
|
||||||
import {
|
import {
|
||||||
filterStore,
|
filterStore,
|
||||||
@ -13,9 +13,11 @@
|
|||||||
TreeNode
|
TreeNode
|
||||||
} from '@hcengineering/view-resources'
|
} from '@hcengineering/view-resources'
|
||||||
import { Application } from '@hcengineering/workbench'
|
import { Application } from '@hcengineering/workbench'
|
||||||
|
import { createEventDispatcher } from 'svelte'
|
||||||
|
|
||||||
export let currentApplication: Application | undefined
|
export let currentApplication: Application | undefined
|
||||||
|
|
||||||
|
const dispatch = createEventDispatcher()
|
||||||
const client = getClient()
|
const client = getClient()
|
||||||
|
|
||||||
const filteredViewsQuery = createQuery()
|
const filteredViewsQuery = createQuery()
|
||||||
@ -58,12 +60,26 @@
|
|||||||
navigate(fv.location)
|
navigate(fv.location)
|
||||||
$filterStore = JSON.parse(fv.filters)
|
$filterStore = JSON.parse(fv.filters)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let oldLocation: string = ''
|
||||||
|
$: loc = $location
|
||||||
|
const clearSelection = () => {
|
||||||
|
selectedId = selectedFW = undefined
|
||||||
|
oldLocation = getCurrentLocation().path.join()
|
||||||
|
dispatch('select', false)
|
||||||
|
}
|
||||||
|
|
||||||
$: fs = $filterStore
|
$: fs = $filterStore
|
||||||
$: if (Array.isArray(fs) && Array.isArray(filteredViews)) {
|
$: if (loc && Array.isArray(fs) && fs.length > 0 && Array.isArray(filteredViews)) {
|
||||||
const filters = JSON.stringify(fs)
|
const filters = JSON.stringify(fs)
|
||||||
selectedFW = filteredViews.filter((fv) => fv.filters === filters)
|
selectedFW = filteredViews.filter((fv) => fv.filters === filters)
|
||||||
selectedId = selectedFW.length > 0 ? selectedFW[0]._id : undefined
|
if (selectedFW.length > 0 && selectedFW[0].location.path.join() === loc.path.join()) {
|
||||||
} else selectedId = selectedFW = undefined
|
selectedId = selectedFW[0]._id
|
||||||
|
oldLocation = selectedFW[0].location.path.join()
|
||||||
|
dispatch('select', true)
|
||||||
|
} else clearSelection()
|
||||||
|
} else clearSelection()
|
||||||
|
$: dispatch('shown', filteredViews !== undefined && filteredViews.length > 0)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if filteredViews && filteredViews.length > 0}
|
{#if filteredViews && filteredViews.length > 0}
|
||||||
@ -73,7 +89,7 @@
|
|||||||
_id={fv._id}
|
_id={fv._id}
|
||||||
title={fv.name}
|
title={fv.name}
|
||||||
indent={'ml-2'}
|
indent={'ml-2'}
|
||||||
bordered={selectedId === fv._id}
|
selected={selectedId === fv._id}
|
||||||
on:click={() => load(fv)}
|
on:click={() => load(fv)}
|
||||||
actions={() => removeAction(fv)}
|
actions={() => removeAction(fv)}
|
||||||
/>
|
/>
|
||||||
|
@ -40,12 +40,16 @@
|
|||||||
import { createEventDispatcher } from 'svelte'
|
import { createEventDispatcher } from 'svelte'
|
||||||
import plugin from '../../plugin'
|
import plugin from '../../plugin'
|
||||||
import { classIcon, getSpaceName } from '../../utils'
|
import { classIcon, getSpaceName } from '../../utils'
|
||||||
|
import TreeSeparator from './TreeSeparator.svelte'
|
||||||
|
|
||||||
export let model: SpacesNavModel
|
export let model: SpacesNavModel
|
||||||
export let currentSpace: Ref<Space> | undefined
|
export let currentSpace: Ref<Space> | undefined
|
||||||
export let spaces: Space[]
|
export let spaces: Space[]
|
||||||
export let currentSpecial: string | undefined
|
export let currentSpecial: string | undefined
|
||||||
export let hasSpaceBrowser: boolean = false
|
export let hasSpaceBrowser: boolean = false
|
||||||
|
export let deselect: boolean = false
|
||||||
|
export let separate: boolean = false
|
||||||
|
|
||||||
const client = getClient()
|
const client = getClient()
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
|
|
||||||
@ -120,10 +124,19 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<TreeNode label={model.label} parent actions={async () => getParentActions()} indent={'ml-2'}>
|
<TreeNode label={model.label} parent actions={async () => getParentActions()} indent={'ml-2'}>
|
||||||
{#each spaces as space (space._id)}
|
{#each spaces as space, i (space._id)}
|
||||||
{#await getObjectPresenter(client, space._class, { key: '' }) then presenter}
|
{#await getObjectPresenter(client, space._class, { key: '' }) then presenter}
|
||||||
|
{#if separate && i !== 0}<TreeSeparator line />{/if}
|
||||||
{#if model.specials && presenter}
|
{#if model.specials && presenter}
|
||||||
<svelte:component this={presenter.presenter} {space} {model} {currentSpace} {currentSpecial} {getActions} />
|
<svelte:component
|
||||||
|
this={presenter.presenter}
|
||||||
|
{space}
|
||||||
|
{model}
|
||||||
|
{currentSpace}
|
||||||
|
{currentSpecial}
|
||||||
|
{getActions}
|
||||||
|
{deselect}
|
||||||
|
/>
|
||||||
{:else}
|
{:else}
|
||||||
<NavLink space={space._id}>
|
<NavLink space={space._id}>
|
||||||
{#await getSpaceName(client, space) then name}
|
{#await getSpaceName(client, space) then name}
|
||||||
@ -132,7 +145,7 @@
|
|||||||
_id={space._id}
|
_id={space._id}
|
||||||
title={name}
|
title={name}
|
||||||
icon={classIcon(client, space._class)}
|
icon={classIcon(client, space._class)}
|
||||||
selected={currentSpace === space._id}
|
selected={deselect ? false : currentSpace === space._id}
|
||||||
actions={() => getActions(space)}
|
actions={() => getActions(space)}
|
||||||
bold={isChanged(space, $lastViews)}
|
bold={isChanged(space, $lastViews)}
|
||||||
/>
|
/>
|
||||||
|
@ -12,5 +12,9 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
-->
|
-->
|
||||||
|
<script lang="ts">
|
||||||
|
export let line: boolean = false
|
||||||
|
export let short: boolean = false
|
||||||
|
</script>
|
||||||
|
|
||||||
<div class="antiNav-divider" />
|
<div class="antiNav-divider" class:line class:short />
|
||||||
|
Loading…
Reference in New Issue
Block a user