mirror of
https://github.com/hcengineering/platform.git
synced 2025-06-08 08:51:12 +00:00
1510 Show starred dm name (#1534)
Signed-off-by: Denis Bunakalya <denis.bunakalya@xored.com>
This commit is contained in:
parent
d1ae4a8c79
commit
ece3006f2b
@ -36,7 +36,7 @@
|
|||||||
import { SpacesNavModel } from '@anticrm/workbench'
|
import { SpacesNavModel } from '@anticrm/workbench'
|
||||||
import { createEventDispatcher } from 'svelte'
|
import { createEventDispatcher } from 'svelte'
|
||||||
import plugin from '../../plugin'
|
import plugin from '../../plugin'
|
||||||
import { classIcon } from '../../utils'
|
import { classIcon, getSpaceName } from '../../utils'
|
||||||
import SpecialElement from './SpecialElement.svelte'
|
import SpecialElement from './SpecialElement.svelte'
|
||||||
import TreeItem from './TreeItem.svelte'
|
import TreeItem from './TreeItem.svelte'
|
||||||
import TreeNode from './TreeNode.svelte'
|
import TreeNode from './TreeNode.svelte'
|
||||||
@ -132,20 +132,6 @@
|
|||||||
return lastView < value
|
return lastView < value
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getName (space: Space) {
|
|
||||||
const clazz = hierarchy.getClass(space._class)
|
|
||||||
const nameMixin = hierarchy.as(clazz, view.mixin.SpaceName)
|
|
||||||
|
|
||||||
if (nameMixin.getName) {
|
|
||||||
const getSpaceName = await getResource(nameMixin.getName);
|
|
||||||
const name = await getSpaceName(client, space)
|
|
||||||
|
|
||||||
return name
|
|
||||||
}
|
|
||||||
|
|
||||||
return space.name
|
|
||||||
}
|
|
||||||
|
|
||||||
function getParentActions(): Action[] {
|
function getParentActions(): Action[] {
|
||||||
return hasSpaceBrowser ? [browseSpaces, addSpace] : [addSpace]
|
return hasSpaceBrowser ? [browseSpaces, addSpace] : [addSpace]
|
||||||
}
|
}
|
||||||
@ -169,7 +155,7 @@
|
|||||||
{/each}
|
{/each}
|
||||||
</TreeNode>
|
</TreeNode>
|
||||||
{:else}
|
{:else}
|
||||||
{#await getName(space) then name}
|
{#await getSpaceName(client, space) then name}
|
||||||
<TreeItem
|
<TreeItem
|
||||||
indent={'ml-4'}
|
indent={'ml-4'}
|
||||||
_id={space._id}
|
_id={space._id}
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
import view from '@anticrm/view'
|
import view from '@anticrm/view'
|
||||||
import { getActions as getContributedActions } from '@anticrm/view-resources'
|
import { getActions as getContributedActions } from '@anticrm/view-resources'
|
||||||
import { createEventDispatcher } from 'svelte'
|
import { createEventDispatcher } from 'svelte'
|
||||||
import { classIcon } from '../../utils'
|
import { classIcon, getSpaceName } from '../../utils'
|
||||||
import TreeItem from './TreeItem.svelte'
|
import TreeItem from './TreeItem.svelte'
|
||||||
import TreeNode from './TreeNode.svelte'
|
import TreeNode from './TreeNode.svelte'
|
||||||
|
|
||||||
@ -52,15 +52,19 @@
|
|||||||
const ids = spaces.map((space) => space._id)
|
const ids = spaces.map((space) => space._id)
|
||||||
const current = await client.findAll(preference.class.SpacePreference, { attachedTo: { $in: ids } })
|
const current = await client.findAll(preference.class.SpacePreference, { attachedTo: { $in: ids } })
|
||||||
|
|
||||||
await Promise.all(current.map(async (item) => { await client.remove(item) }))
|
await Promise.all(
|
||||||
|
current.map(async (item) => {
|
||||||
|
await client.remove(item)
|
||||||
|
})
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectSpace (id: Ref<Space>, spaceSpecial?: string) {
|
function selectSpace(id: Ref<Space>, spaceSpecial?: string) {
|
||||||
dispatch('space', { space: id, spaceSpecial })
|
dispatch('space', { space: id, spaceSpecial })
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getActions (space: Space): Promise<Action[]> {
|
async function getActions(space: Space): Promise<Action[]> {
|
||||||
const result = [unStarSpace]
|
const result = [unStarSpace]
|
||||||
|
|
||||||
const extraActions = await getContributedActions(client, space, core.class.Space)
|
const extraActions = await getContributedActions(client, space, core.class.Space)
|
||||||
@ -81,7 +85,7 @@
|
|||||||
const lastViews = notificationClient.getLastViews()
|
const lastViews = notificationClient.getLastViews()
|
||||||
const hierarchy = client.getHierarchy()
|
const hierarchy = client.getHierarchy()
|
||||||
|
|
||||||
function isChanged (space: Space, lastViews: Map<Ref<Doc>, number>): boolean {
|
function isChanged(space: Space, lastViews: Map<Ref<Doc>, number>): boolean {
|
||||||
const clazz = hierarchy.getClass(space._class)
|
const clazz = hierarchy.getClass(space._class)
|
||||||
const lastEditMixin = hierarchy.as(clazz, notification.mixin.SpaceLastEdit)
|
const lastEditMixin = hierarchy.as(clazz, notification.mixin.SpaceLastEdit)
|
||||||
const field = lastEditMixin?.lastEditField
|
const field = lastEditMixin?.lastEditField
|
||||||
@ -95,19 +99,21 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<TreeNode label={label} parent actions={async () => [unStarAll]} indent={'ml-2'}>
|
<TreeNode {label} parent actions={async () => [unStarAll]} indent={'ml-2'}>
|
||||||
{#each spaces as space (space._id)}
|
{#each spaces as space (space._id)}
|
||||||
<TreeItem
|
{#await getSpaceName(client, space) then name}
|
||||||
indent={'ml-4'}
|
<TreeItem
|
||||||
_id={space._id}
|
indent={'ml-4'}
|
||||||
title={space.name}
|
_id={space._id}
|
||||||
icon={classIcon(client, space._class)}
|
title={name}
|
||||||
selected={currentSpace === space._id}
|
icon={classIcon(client, space._class)}
|
||||||
actions={() => getActions(space)}
|
selected={currentSpace === space._id}
|
||||||
bold={isChanged(space, $lastViews)}
|
actions={() => getActions(space)}
|
||||||
on:click={() => {
|
bold={isChanged(space, $lastViews)}
|
||||||
selectSpace(space._id)
|
on:click={() => {
|
||||||
}}
|
selectSpace(space._id)
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
|
{/await}
|
||||||
{/each}
|
{/each}
|
||||||
</TreeNode>
|
</TreeNode>
|
||||||
|
@ -16,13 +16,30 @@
|
|||||||
|
|
||||||
import type { Class, Client, Obj, Ref, Space } from '@anticrm/core'
|
import type { Class, Client, Obj, Ref, Space } from '@anticrm/core'
|
||||||
import type { Asset } from '@anticrm/platform'
|
import type { Asset } from '@anticrm/platform'
|
||||||
|
import { getResource } from '@anticrm/platform'
|
||||||
import { NavigatorModel } from '@anticrm/workbench'
|
import { NavigatorModel } from '@anticrm/workbench'
|
||||||
|
import view from '@anticrm/view'
|
||||||
|
|
||||||
export function classIcon (client: Client, _class: Ref<Class<Obj>>): Asset | undefined {
|
export function classIcon(client: Client, _class: Ref<Class<Obj>>): Asset | undefined {
|
||||||
return client.getHierarchy().getClass(_class).icon
|
return client.getHierarchy().getClass(_class).icon
|
||||||
}
|
}
|
||||||
export function getSpecialSpaceClass (model: NavigatorModel): Array<Ref<Class<Space>>> {
|
export function getSpecialSpaceClass(model: NavigatorModel): Array<Ref<Class<Space>>> {
|
||||||
const spaceResult = model.spaces.map(x => x.spaceClass)
|
const spaceResult = model.spaces.map((x) => x.spaceClass)
|
||||||
const result = (model.specials ?? []).map(it => it.spaceClass).filter(it => it !== undefined)
|
const result = (model.specials ?? []).map((it) => it.spaceClass).filter((it) => it !== undefined)
|
||||||
return spaceResult.concat(result as Array<Ref<Class<Space>>>)
|
return spaceResult.concat(result as Array<Ref<Class<Space>>>)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function getSpaceName(client: Client, space: Space) {
|
||||||
|
const hierarchy = client.getHierarchy()
|
||||||
|
const clazz = hierarchy.getClass(space._class)
|
||||||
|
const nameMixin = hierarchy.as(clazz, view.mixin.SpaceName)
|
||||||
|
|
||||||
|
if (nameMixin.getName) {
|
||||||
|
const getSpaceName = await getResource(nameMixin.getName)
|
||||||
|
const name = await getSpaceName(client, space)
|
||||||
|
|
||||||
|
return name
|
||||||
|
}
|
||||||
|
|
||||||
|
return space.name
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user