From c646a83608388de69dbe08a25bab1793dedbc10f Mon Sep 17 00:00:00 2001 From: Jan Prochazka Date: Sun, 5 Mar 2023 17:11:02 +0100 Subject: [PATCH] close functions in tab group --- packages/web/src/tabpanel/TabsPanel.svelte | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/web/src/tabpanel/TabsPanel.svelte b/packages/web/src/tabpanel/TabsPanel.svelte index 43dc31b5..96a36f4f 100644 --- a/packages/web/src/tabpanel/TabsPanel.svelte +++ b/packages/web/src/tabpanel/TabsPanel.svelte @@ -108,7 +108,7 @@ } const closeTab = closeTabFunc((x, active) => x.tabid == active.tabid); - const closeAll = async () => { + const closeAll = async multiTabIndex => { const closeCandidates = getOpenedTabs() .filter(x => x.unsaved) .filter(x => shouldShowTab(x)); @@ -119,7 +119,10 @@ openedTabs.update(tabs => tabs.map(tab => ({ ...tab, - closedTime: shouldShowTab(tab) ? closedTime : tab.closedTime, + closedTime: + shouldShowTab(tab) && (multiTabIndex == null || multiTabIndex == (tab.multiTabIndex || 0)) + ? closedTime + : tab.closedTime, selected: false, visibleSecondary: false, })) @@ -150,7 +153,8 @@ _.get(x, 'props.conid') != _.get(active, 'props.conid') || _.get(x, 'props.database') != _.get(active, 'props.database') ); - const closeOthers = closeTabFunc((x, active) => x.tabid != active.tabid); + const closeOthersInMultiTab = multiTabIndex => + closeTabFunc((x, active) => x.tabid != active.tabid && (x.multiTabIndex || 0) == multiTabIndex); function getTabDbName(tab, connectionList) { if (tab.tabComponent == 'ConnectionTab') return 'Connections'; @@ -348,11 +352,11 @@ }, { text: 'Close all', - onClick: closeAll, + onClick: () => closeAll(multiTabIndex), }, { text: 'Close others', - onClick: () => closeOthers(tabid), + onClick: () => closeOthersInMultiTab(multiTabIndex)(tabid), }, { text: 'Duplicate',