aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/CollectionDockingView.tsx
diff options
context:
space:
mode:
authormehekj <mehek.jethani@gmail.com>2023-01-13 18:11:34 -0500
committermehekj <mehek.jethani@gmail.com>2023-01-13 18:11:34 -0500
commit82de335e0643f907e44cb193c9b2c6da1b3cbaf1 (patch)
treee72a74f8b18bfd1e9d6f7262a0fb5203d82b6921 /src/client/views/collections/CollectionDockingView.tsx
parent73d3c63658c4bdf3268ea81a02eb96566869b855 (diff)
parent6d32fe60ce32d650a2ba0d5eb8e36dccb591521f (diff)
Merge branch 'master' into schema-mehek
Diffstat (limited to 'src/client/views/collections/CollectionDockingView.tsx')
-rw-r--r--src/client/views/collections/CollectionDockingView.tsx36
1 files changed, 22 insertions, 14 deletions
diff --git a/src/client/views/collections/CollectionDockingView.tsx b/src/client/views/collections/CollectionDockingView.tsx
index 92319d080..ffc004df6 100644
--- a/src/client/views/collections/CollectionDockingView.tsx
+++ b/src/client/views/collections/CollectionDockingView.tsx
@@ -25,6 +25,7 @@ import { CollectionFreeFormView } from './collectionFreeForm';
import { CollectionSubView, SubCollectionViewProps } from './CollectionSubView';
import { TabDocView } from './TabDocView';
import React = require('react');
+import { OpenWhere, OpenWhereMod } from '../nodes/DocumentView';
const _global = (window /* browser */ || global) /* node */ as any;
@observer
@@ -142,7 +143,7 @@ export class CollectionDockingView extends CollectionSubView() {
@undoBatch
@action
- public static ReplaceTab(document: Doc, panelName: string, stack: any, addToSplit?: boolean): boolean {
+ public static ReplaceTab(document: Doc, panelName: OpenWhereMod, stack: any, addToSplit?: boolean): boolean {
const instance = CollectionDockingView.Instance;
if (!instance) return false;
const newConfig = CollectionDockingView.makeDocumentConfig(document, panelName);
@@ -164,7 +165,7 @@ export class CollectionDockingView extends CollectionSubView() {
}
@undoBatch
- public static ToggleSplit(doc: Doc, location: string, stack?: any, panelName?: string) {
+ public static ToggleSplit(doc: Doc, location: OpenWhereMod, stack?: any, panelName?: string) {
return CollectionDockingView.Instance && Array.from(CollectionDockingView.Instance.tabMap.keys()).findIndex(tab => tab.DashDoc === doc) !== -1
? CollectionDockingView.CloseSplit(doc)
: CollectionDockingView.AddSplit(doc, location, stack, panelName);
@@ -175,7 +176,7 @@ export class CollectionDockingView extends CollectionSubView() {
//
@undoBatch
@action
- public static AddSplit(document: Doc, pullSide: string, stack?: any, panelName?: string) {
+ public static AddSplit(document: Doc, pullSide: OpenWhereMod, stack?: any, panelName?: string) {
if (document?._viewType === CollectionViewType.Docking) return DashboardView.openDashboard(document);
if (!CollectionDockingView.Instance) return false;
const tab = Array.from(CollectionDockingView.Instance.tabMap).find(tab => tab.DashDoc === document);
@@ -190,7 +191,7 @@ export class CollectionDockingView extends CollectionSubView() {
if (!pullSide && stack) {
stack.addChild(docContentConfig, undefined);
- stack.setActiveContentItem(stack.contentItems[stack.contentItems.length - 1]);
+ setTimeout(() => stack.setActiveContentItem(stack.contentItems[stack.contentItems.length - 1]));
} else {
const newContentItem = () => {
const newItem = glayRoot.layoutManager.createContentItem({ type: 'stack', content: [docContentConfig] }, instance._goldenLayout);
@@ -208,14 +209,15 @@ export class CollectionDockingView extends CollectionSubView() {
// if row
switch (pullSide) {
default:
- case 'right':
+ case OpenWhereMod.none:
+ case OpenWhereMod.right:
glayRoot.contentItems[0].addChild(newContentItem());
break;
- case 'left':
+ case OpenWhereMod.left:
glayRoot.contentItems[0].addChild(newContentItem(), 0);
break;
- case 'top':
- case 'bottom':
+ case OpenWhereMod.top:
+ case OpenWhereMod.bottom:
// if not going in a row layout, must add already existing content into column
const rowlayout = glayRoot.contentItems[0];
const newColumn = rowlayout.layoutManager.createContentItem({ type: 'column' }, instance._goldenLayout);
@@ -387,6 +389,7 @@ export class CollectionDockingView extends CollectionSubView() {
const className = typeof htmlTarget.className === 'string' ? htmlTarget.className : '';
if (!className.includes('lm_close') && !className.includes('lm_maximise')) {
this._flush = UndoManager.StartBatch('golden layout edit');
+ DocServer.UPDATE_SERVER_CACHE();
}
}
}
@@ -452,7 +455,7 @@ export class CollectionDockingView extends CollectionSubView() {
.map(id => DocServer.GetCachedRefField(id))
.filter(f => f)
.map(f => f as Doc);
- const changesMade = this.props.Document.dockcingConfig !== json;
+ const changesMade = this.props.Document.dockingConfig !== json;
if (changesMade && !this._flush) {
UndoManager.RunInBatch(() => {
this.props.Document.dockingConfig = json;
@@ -496,7 +499,7 @@ export class CollectionDockingView extends CollectionSubView() {
title: `Untitled Tab ${NumCast(dashboard['pane-count'])}`,
});
this.props.Document.isShared && inheritParentAcls(this.props.Document, docToAdd);
- CollectionDockingView.AddSplit(docToAdd, '', stack);
+ CollectionDockingView.AddSplit(docToAdd, OpenWhereMod.none, stack);
}
});
@@ -507,7 +510,12 @@ export class CollectionDockingView extends CollectionSubView() {
action(() => {
//if (confirm('really close this?')) {
if ((!stack.parent.isRoot && !stack.parent.parent.isRoot) || stack.parent.contentItems.length > 1) {
+ const batch = UndoManager.StartBatch('close stack');
stack.remove();
+ setTimeout(() => {
+ this.stateChanged();
+ batch.end();
+ });
} else {
alert('cant delete the last stack');
}
@@ -534,7 +542,7 @@ export class CollectionDockingView extends CollectionSubView() {
title: `Untitled Tab ${NumCast(dashboard['pane-count'])}`,
});
this.props.Document.isShared && inheritParentAcls(this.props.Document, docToAdd);
- CollectionDockingView.AddSplit(docToAdd, '', stack);
+ CollectionDockingView.AddSplit(docToAdd, OpenWhereMod.none, stack);
}
})
);
@@ -563,14 +571,14 @@ export class CollectionDockingView extends CollectionSubView() {
ScriptingGlobals.add(
function openInLightbox(doc: any) {
- LightboxView.AddDocTab(doc, 'lightbox');
+ LightboxView.AddDocTab(doc, OpenWhere.lightbox);
},
'opens up document in a lightbox',
'(doc: any)'
);
ScriptingGlobals.add(
function openOnRight(doc: any) {
- return CollectionDockingView.AddSplit(doc, 'right');
+ return CollectionDockingView.AddSplit(doc, OpenWhereMod.right);
},
'opens up document in tab on right side of the screen',
'(doc: any)'
@@ -583,5 +591,5 @@ ScriptingGlobals.add(
'(doc: any)'
);
ScriptingGlobals.add(function useRightSplit(doc: any, shiftKey?: boolean) {
- CollectionDockingView.ReplaceTab(doc, 'right', undefined, shiftKey);
+ CollectionDockingView.ReplaceTab(doc, OpenWhereMod.right, undefined, shiftKey);
});