From 9c43e2dd5c3ab7ccc61f0e6bb271a95b27c233c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pete=20An=C3=B8ther?= Date: Wed, 6 Dec 2023 00:24:12 -0300 Subject: [PATCH] UBERF-4477: Fixed positioning of `AddSavedView` popup (#4148) Signed-off-by: Petr Vyazovetskiy --- .../src/components/SavedView.svelte | 33 +++++++++++++------ 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/plugins/workbench-resources/src/components/SavedView.svelte b/plugins/workbench-resources/src/components/SavedView.svelte index 8f06d2cb41..4909263c18 100644 --- a/plugins/workbench-resources/src/components/SavedView.svelte +++ b/plugins/workbench-resources/src/components/SavedView.svelte @@ -11,7 +11,8 @@ navigate, showPopup, SelectPopup, - getEventPopupPositionElement + getEventPopupPositionElement, + getPopupPositionElement } from '@hcengineering/ui' import view, { Filter, FilteredView, ViewOptions, Viewlet } from '@hcengineering/view' import { @@ -42,10 +43,14 @@ const filteredViewsQuery = createQuery() let availableFilteredViews: FilteredView[] = [] let myFilteredViews: FilteredView[] = [] - $: filteredViewsQuery.query(view.class.FilteredView, { attachedTo: currentApplication?.alias }, (result) => { - myFilteredViews = result.filter((p) => p.users.includes(me)) - availableFilteredViews = result.filter((p) => p.sharable && !p.users.includes(me)) - }) + $: filteredViewsQuery.query( + view.class.FilteredView, + { attachedTo: currentApplication?.alias }, + (result) => { + myFilteredViews = result.filter((p) => p.users.includes(me)) + availableFilteredViews = result.filter((p) => p.sharable && !p.users.includes(me)) + } + ) async function removeAction (filteredView: FilteredView): Promise { return [ @@ -111,7 +116,7 @@ fragment: fv.location.fragment ?? undefined }) if (fv.viewletId !== undefined && fv.viewletId !== null) { - const viewlet = await client.findOne(view.class.Viewlet, { _id: fv.viewletId }) + const viewlet = await client.findOne(view.class.Viewlet, { _id: fv.viewletId }) setActiveViewletId(fv.viewletId, fv.location) if (viewlet !== undefined && fv.viewOptions !== undefined) { setViewOptions(viewlet, copy(fv.viewOptions)) @@ -120,7 +125,7 @@ setFilters(JSON.parse(fv.filters)) } - const clearSelection = () => { + const clearSelection = (): void => { selectedFilterStore.set(undefined) selectedId = undefined dispatch('select', false) @@ -148,7 +153,7 @@ loc: Location, filteredViews: FilteredView[] | undefined, viewOptionStore: Map - ) { + ): void { const filters = JSON.stringify(fs) if (loc && Array.isArray(fs) && fs.length > 0 && Array.isArray(filteredViews)) { if ($selectedFilterStore !== undefined) { @@ -179,7 +184,7 @@ async function getActions (availableFilteredViews: FilteredView[]): Promise { if (availableFilteredViews.length > 0) { const filteredViewsIdMap = toIdMap(availableFilteredViews) - const pushMeToFV = async (id: Ref) => { + const pushMeToFV = async (id: Ref): Promise => { if (id === undefined) return const filteredView = filteredViewsIdMap.get(id) if (filteredView) await client.update(filteredView, { $push: { users: me } }) @@ -192,7 +197,15 @@ label: view.string.AddSavedView, icon: IconAdd, action: async (_, e): Promise => { - showPopup(SelectPopup, { value, searchable: true }, eventToHTMLElement(e as MouseEvent), pushMeToFV) + showPopup( + SelectPopup, + { value, searchable: true }, + getPopupPositionElement(eventToHTMLElement(e as MouseEvent), { + v: 'top', + h: 'right' + }), + pushMeToFV + ) } } return [add]