mirror of
https://github.com/hcengineering/platform.git
synced 2025-05-12 10:25:51 +00:00
Fix thread open (#8344)
Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>
This commit is contained in:
parent
d9316aa8da
commit
6bf3ecd30a
@ -24,17 +24,15 @@ import type {
|
|||||||
ApplicationNavModel,
|
ApplicationNavModel,
|
||||||
HiddenApplication,
|
HiddenApplication,
|
||||||
SpaceView,
|
SpaceView,
|
||||||
TxSidebarEvent,
|
|
||||||
ViewConfiguration,
|
ViewConfiguration,
|
||||||
Widget,
|
Widget,
|
||||||
WidgetPreference,
|
WidgetPreference,
|
||||||
WidgetTab,
|
WidgetTab,
|
||||||
WidgetType,
|
WidgetType,
|
||||||
SidebarEvent,
|
|
||||||
WorkbenchTab
|
WorkbenchTab
|
||||||
} from '@hcengineering/workbench'
|
} from '@hcengineering/workbench'
|
||||||
import { type AnyComponent } from '@hcengineering/ui/src/types'
|
import { type AnyComponent } from '@hcengineering/ui/src/types'
|
||||||
import core, { TClass, TDoc, TTx } from '@hcengineering/model-core'
|
import core, { TClass, TDoc } from '@hcengineering/model-core'
|
||||||
import presentation from '@hcengineering/model-presentation'
|
import presentation from '@hcengineering/model-presentation'
|
||||||
|
|
||||||
import workbench from './plugin'
|
import workbench from './plugin'
|
||||||
@ -97,12 +95,6 @@ export class TWidgetPreference extends TPreference implements WidgetPreference {
|
|||||||
enabled!: boolean
|
enabled!: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
@Model(workbench.class.TxSidebarEvent, core.class.Doc)
|
|
||||||
export class TTxSidebarEvent extends TTx implements TxSidebarEvent {
|
|
||||||
event!: SidebarEvent
|
|
||||||
params!: Record<string, any>
|
|
||||||
}
|
|
||||||
|
|
||||||
@Model(workbench.class.WorkbenchTab, preference.class.Preference)
|
@Model(workbench.class.WorkbenchTab, preference.class.Preference)
|
||||||
@UX(workbench.string.Tab)
|
@UX(workbench.string.Tab)
|
||||||
export class TWorkbenchTab extends TPreference implements WorkbenchTab {
|
export class TWorkbenchTab extends TPreference implements WorkbenchTab {
|
||||||
@ -120,7 +112,6 @@ export function createModel (builder: Builder): void {
|
|||||||
TApplicationNavModel,
|
TApplicationNavModel,
|
||||||
TWidget,
|
TWidget,
|
||||||
TWidgetPreference,
|
TWidgetPreference,
|
||||||
TTxSidebarEvent,
|
|
||||||
TWorkbenchTab
|
TWorkbenchTab
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -13,14 +13,12 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
-->
|
-->
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Tx } from '@hcengineering/core'
|
import { createQuery, getClient } from '@hcengineering/presentation'
|
||||||
import { addTxListener, createQuery, getClient, removeTxListener } from '@hcengineering/presentation'
|
|
||||||
import { panelstore } from '@hcengineering/ui'
|
import { panelstore } from '@hcengineering/ui'
|
||||||
import { OpenSidebarWidgetParams, SidebarEvent, TxSidebarEvent, WidgetPreference } from '@hcengineering/workbench'
|
import { WidgetPreference } from '@hcengineering/workbench'
|
||||||
import { onMount } from 'svelte'
|
|
||||||
|
|
||||||
import workbench from '../../plugin'
|
import workbench from '../../plugin'
|
||||||
import { createWidgetTab, openWidget, sidebarStore, SidebarVariant } from '../../sidebar'
|
import { sidebarStore, SidebarVariant } from '../../sidebar'
|
||||||
import SidebarExpanded from './SidebarExpanded.svelte'
|
import SidebarExpanded from './SidebarExpanded.svelte'
|
||||||
import SidebarMini from './SidebarMini.svelte'
|
import SidebarMini from './SidebarMini.svelte'
|
||||||
|
|
||||||
@ -36,29 +34,6 @@
|
|||||||
|
|
||||||
$: mini = $sidebarStore.variant === SidebarVariant.MINI
|
$: mini = $sidebarStore.variant === SidebarVariant.MINI
|
||||||
$: if ((!mini || mini) && $panelstore.panel?.refit !== undefined) $panelstore.panel.refit()
|
$: if ((!mini || mini) && $panelstore.panel?.refit !== undefined) $panelstore.panel.refit()
|
||||||
|
|
||||||
function txListener (txes: Tx[]): void {
|
|
||||||
const evt = txes.findLast(
|
|
||||||
(it) => it._class === workbench.class.TxSidebarEvent && evt.event === SidebarEvent.OpenWidget
|
|
||||||
) as TxSidebarEvent
|
|
||||||
if (evt !== undefined) {
|
|
||||||
const params = evt.params as OpenSidebarWidgetParams
|
|
||||||
const widget = client.getModel().findAllSync(workbench.class.Widget, { _id: params.widget })[0]
|
|
||||||
if (widget === undefined) return
|
|
||||||
if (params.tab !== undefined) {
|
|
||||||
createWidgetTab(widget, params.tab)
|
|
||||||
} else {
|
|
||||||
openWidget(widget)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onMount(() => {
|
|
||||||
addTxListener(txListener)
|
|
||||||
return () => {
|
|
||||||
removeTxListener(txListener)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div id="sidebar" class="antiPanel-application vertical sidebar-container" class:mini={mini || $sidebarStore.float}>
|
<div id="sidebar" class="antiPanel-application vertical sidebar-container" class:mini={mini || $sidebarStore.float}>
|
||||||
|
@ -73,7 +73,10 @@
|
|||||||
})
|
})
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
|
// We need to wait for location to be updated
|
||||||
|
setTimeout(() => {
|
||||||
closeWrongTabs(getCurrentLocation())
|
closeWrongTabs(getCurrentLocation())
|
||||||
|
}, 100)
|
||||||
})
|
})
|
||||||
|
|
||||||
onDestroy(() => {
|
onDestroy(() => {
|
||||||
|
@ -25,7 +25,6 @@ import type {
|
|||||||
ApplicationNavModel,
|
ApplicationNavModel,
|
||||||
HiddenApplication,
|
HiddenApplication,
|
||||||
SpaceView,
|
SpaceView,
|
||||||
TxSidebarEvent,
|
|
||||||
Widget,
|
Widget,
|
||||||
WidgetPreference,
|
WidgetPreference,
|
||||||
WidgetTab,
|
WidgetTab,
|
||||||
@ -43,7 +42,6 @@ export const workbenchPlugin = plugin(workbenchId, {
|
|||||||
HiddenApplication: '' as Ref<Class<HiddenApplication>>,
|
HiddenApplication: '' as Ref<Class<HiddenApplication>>,
|
||||||
Widget: '' as Ref<Class<Widget>>,
|
Widget: '' as Ref<Class<Widget>>,
|
||||||
WidgetPreference: '' as Ref<Class<WidgetPreference>>,
|
WidgetPreference: '' as Ref<Class<WidgetPreference>>,
|
||||||
TxSidebarEvent: '' as Ref<Class<TxSidebarEvent<Record<string, any>>>>,
|
|
||||||
WorkbenchTab: '' as Ref<Class<WorkbenchTab>>
|
WorkbenchTab: '' as Ref<Class<WorkbenchTab>>
|
||||||
},
|
},
|
||||||
mixin: {
|
mixin: {
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
//
|
//
|
||||||
|
|
||||||
import type { AccountRole, AccountUuid, Class, Doc, DocumentQuery, Obj, Ref, Space, Tx } from '@hcengineering/core'
|
import type { AccountRole, AccountUuid, Class, Doc, DocumentQuery, Obj, Ref, Space } from '@hcengineering/core'
|
||||||
import { DocNotifyContext, InboxNotification } from '@hcengineering/notification'
|
import { DocNotifyContext, InboxNotification } from '@hcengineering/notification'
|
||||||
import type { Asset, IntlString, Resource } from '@hcengineering/platform'
|
import type { Asset, IntlString, Resource } from '@hcengineering/platform'
|
||||||
import type { Preference } from '@hcengineering/preference'
|
import type { Preference } from '@hcengineering/preference'
|
||||||
@ -96,23 +96,6 @@ export interface WidgetTab {
|
|||||||
readonly?: boolean
|
readonly?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @public */
|
|
||||||
export enum SidebarEvent {
|
|
||||||
OpenWidget = 'openWidget'
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @public */
|
|
||||||
export interface OpenSidebarWidgetParams {
|
|
||||||
widget: Ref<Widget>
|
|
||||||
tab?: WidgetTab
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @public */
|
|
||||||
export interface TxSidebarEvent<T extends Record<string, any> = Record<string, any>> extends Tx {
|
|
||||||
event: SidebarEvent
|
|
||||||
params: T
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @public */
|
/** @public */
|
||||||
export interface WorkbenchTab extends Preference {
|
export interface WorkbenchTab extends Preference {
|
||||||
attachedTo: AccountUuid
|
attachedTo: AccountUuid
|
||||||
|
Loading…
Reference in New Issue
Block a user