aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/CollectionDockingView.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/collections/CollectionDockingView.tsx')
-rw-r--r--src/client/views/collections/CollectionDockingView.tsx68
1 files changed, 39 insertions, 29 deletions
diff --git a/src/client/views/collections/CollectionDockingView.tsx b/src/client/views/collections/CollectionDockingView.tsx
index a790a0475..07fcd6a7d 100644
--- a/src/client/views/collections/CollectionDockingView.tsx
+++ b/src/client/views/collections/CollectionDockingView.tsx
@@ -121,7 +121,7 @@ export class CollectionDockingView extends CollectionSubView() {
SelectionManager.DeselectAll();
const instance = CollectionDockingView.Instance;
if (doc._viewType === CollectionViewType.Docking && doc.layoutKey === "layout") {
- return CurrentUserUtils.openDashboard(Doc.UserDoc(), doc);
+ return CurrentUserUtils.openDashboard(doc);
}
const newItemStackConfig = {
type: 'stack',
@@ -172,7 +172,7 @@ export class CollectionDockingView extends CollectionSubView() {
@undoBatch
@action
public static AddSplit(document: Doc, pullSide: string, stack?: any, panelName?: string) {
- if (document._viewType === CollectionViewType.Docking) return CurrentUserUtils.openDashboard(Doc.UserDoc(), document);
+ if (document._viewType === CollectionViewType.Docking) return CurrentUserUtils.openDashboard(document);
const tab = Array.from(CollectionDockingView.Instance.tabMap).find(tab => tab.DashDoc === document);
if (tab) {
@@ -188,10 +188,13 @@ export class CollectionDockingView extends CollectionSubView() {
stack.addChild(docContentConfig, undefined);
stack.setActiveContentItem(stack.contentItems[stack.contentItems.length - 1]);
} else {
- const newItemStackConfig = { type: 'stack', content: [docContentConfig] };
- const newContentItem = glayRoot.layoutManager.createContentItem(newItemStackConfig, instance._goldenLayout);
+ const newContentItem = () => {
+ const newItem = glayRoot.layoutManager.createContentItem({ type: 'stack', content: [docContentConfig] }, instance._goldenLayout);
+ newItem.callDownwards('_$init');
+ return newItem;
+ }
if (glayRoot.contentItems.length === 0) { // if no rows / columns
- glayRoot.addChild(newContentItem);
+ glayRoot.addChild(newContentItem());
} else if (glayRoot.contentItems[0].isStack) {
glayRoot.contentItems[0].addChild(docContentConfig);
} else if (
@@ -203,32 +206,33 @@ export class CollectionDockingView extends CollectionSubView() {
else if (instance._goldenLayout.root.contentItems[0].isRow) { // if row
switch (pullSide) {
default:
- case "right": glayRoot.contentItems[0].addChild(newContentItem); break;
- case "left": glayRoot.contentItems[0].addChild(newContentItem, 0); break;
+ case "right": glayRoot.contentItems[0].addChild(newContentItem()); break;
+ case "left": glayRoot.contentItems[0].addChild(newContentItem(), 0); break;
case "top":
case "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);
+ const newItem = newContentItem();
instance._goldenLayout.saveScrollTops(rowlayout.element);
rowlayout.parent.replaceChild(rowlayout, newColumn);
if (pullSide === "top") {
newColumn.addChild(rowlayout, undefined, true);
- newColumn.addChild(newContentItem, 0, true);
+ newColumn.addChild(newItem, 0, true);
} else if (pullSide === "bottom") {
- newColumn.addChild(newContentItem, undefined, true);
+ newColumn.addChild(newItem, undefined, true);
newColumn.addChild(rowlayout, 0, true);
}
instance._goldenLayout.restoreScrollTops(rowlayout.element);
rowlayout.config.height = 50;
- newContentItem.config.height = 50;
+ newItem.config.height = 50;
}
} else {// if (instance._goldenLayout.root.contentItems[0].isColumn) { // if column
switch (pullSide) {
- case "top": glayRoot.contentItems[0].addChild(newContentItem, 0); break;
- case "bottom": glayRoot.contentItems[0].addChild(newContentItem); break;
+ case "top": glayRoot.contentItems[0].addChild(newContentItem(), 0); break;
+ case "bottom": glayRoot.contentItems[0].addChild(newContentItem()); break;
case "left":
case "right":
default:
@@ -236,23 +240,23 @@ export class CollectionDockingView extends CollectionSubView() {
const collayout = glayRoot.contentItems[0];
const newRow = collayout.layoutManager.createContentItem({ type: "row" }, instance._goldenLayout);
+ const newItem = newContentItem();
instance._goldenLayout.saveScrollTops(collayout.element);
collayout.parent.replaceChild(collayout, newRow);
if (pullSide === "left") {
newRow.addChild(collayout, undefined, true);
- newRow.addChild(newContentItem, 0, true);
+ newRow.addChild(newItem, 0, true);
} else {
- newRow.addChild(newContentItem, undefined, true);
+ newRow.addChild(newItem, undefined, true);
newRow.addChild(collayout, 0, true);
}
instance._goldenLayout.restoreScrollTops(collayout.element);
collayout.config.width = 50;
- newContentItem.config.width = 50;
+ newItem.config.width = 50;
}
}
instance._ignoreStateChange = JSON.stringify(instance._goldenLayout.toConfig());
- newContentItem.callDownwards('_$init');
}
return instance.layoutChanged();
@@ -364,7 +368,7 @@ export class CollectionDockingView extends CollectionSubView() {
}
}
if (!e.nativeEvent.cancelBubble && !InteractionUtils.IsType(e, InteractionUtils.TOUCHTYPE) && !InteractionUtils.IsType(e, InteractionUtils.PENTYPE) &&
- ![InkTool.Highlighter, InkTool.Pen, InkTool.Write].includes(CurrentUserUtils.SelectedTool)) {
+ ![InkTool.Highlighter, InkTool.Pen, InkTool.Write].includes(CurrentUserUtils.ActiveTool)) {
e.stopPropagation();
}
}
@@ -412,6 +416,10 @@ export class CollectionDockingView extends CollectionSubView() {
}
tabDestroyed = (tab: any) => {
+ if(tab.DashDoc?.type !== DocumentType.KVP) {
+ Doc.AddDocToList(CurrentUserUtils.MyHeaderBar, "data", tab.DashDoc);
+ Doc.AddDocToList(CurrentUserUtils.MyRecentlyClosed, "data", tab.DashDoc, undefined, true, true);
+ }
const dview = CollectionDockingView.Instance.props.Document;
const fieldKey = CollectionDockingView.Instance.props.fieldKey;
Doc.RemoveDocFromList(dview, fieldKey, tab.DashDoc);
@@ -427,11 +435,11 @@ export class CollectionDockingView extends CollectionSubView() {
stackCreated = (stack: any) => {
stack.header?.element.on('mousedown', (e: any) => {
- if (e.target === stack.header?.element[0] && e.button === 2) {
- const emptyPane = CurrentUserUtils.EmptyPane;
- emptyPane["dragFactory-count"] = NumCast(emptyPane["dragFactory-count"]) + 1;
+ const dashboard = CurrentUserUtils.ActiveDashboard;
+ if (dashboard && e.target === stack.header?.element[0] && e.button === 2) {
+ dashboard["pane-count"] = NumCast(dashboard["pane-count"]) + 1;
const docToAdd = Docs.Create.FreeformDocument([], {
- _width: this.props.PanelWidth(), _height: this.props.PanelHeight(), _backgroundGridShow: true, _fitWidth: true, title: `Untitled Tab ${NumCast(emptyPane["dragFactory-count"])}`,
+ _width: this.props.PanelWidth(), _height: this.props.PanelHeight(), _backgroundGridShow: true, _fitWidth: true, title: `Untitled Tab ${NumCast(dashboard["pane-count"])}`,
});
this.props.Document.isShared && inheritParentAcls(this.props.Document, docToAdd);
CollectionDockingView.AddSplit(docToAdd, "", stack);
@@ -455,13 +463,15 @@ export class CollectionDockingView extends CollectionSubView() {
.off('click') //unbind the current click handler
.click(action(() => {
// stack.config.fixed = !stack.config.fixed; // force the stack to have a fixed size
- const emptyPane = CurrentUserUtils.EmptyPane;
- emptyPane["dragFactory-count"] = NumCast(emptyPane["dragFactory-count"]) + 1;
- const docToAdd = Docs.Create.FreeformDocument([], {
- _width: this.props.PanelWidth(), _height: this.props.PanelHeight(), _fitWidth: true, _backgroundGridShow: true, title: `Untitled Tab ${NumCast(emptyPane["dragFactory-count"])}`
- });
- this.props.Document.isShared && inheritParentAcls(this.props.Document, docToAdd);
- CollectionDockingView.AddSplit(docToAdd, "", stack);
+ const dashboard = CurrentUserUtils.ActiveDashboard;
+ if (dashboard) {
+ dashboard["pane-count"] = NumCast(dashboard["pane-count"]) + 1;
+ const docToAdd = Docs.Create.FreeformDocument([], {
+ _width: this.props.PanelWidth(), _height: this.props.PanelHeight(), _fitWidth: true, _backgroundGridShow: true, title: `Untitled Tab ${NumCast(dashboard["pane-count"])}`
+ });
+ this.props.Document.isShared && inheritParentAcls(this.props.Document, docToAdd);
+ CollectionDockingView.AddSplit(docToAdd, "", stack);
+ }
}));
}
@@ -474,6 +484,6 @@ ScriptingGlobals.add(function openInLightbox(doc: any) { LightboxView.AddDocTab(
"opens up document in a lightbox", "(doc: any)");
ScriptingGlobals.add(function openOnRight(doc: any) { return CollectionDockingView.AddSplit(doc, "right"); },
"opens up document in tab on right side of the screen", "(doc: any)");
-ScriptingGlobals.add(function openInOverlay(doc: any) { return Doc.AddDocToList((Doc.UserDoc().myOverlayDocs as Doc), undefined, doc); },
+ScriptingGlobals.add(function openInOverlay(doc: any) { return Doc.AddDocToList(CurrentUserUtils.MyOverlayDocs, undefined, doc); },
"opens up document in screen overlay layer", "(doc: any)");
ScriptingGlobals.add(function useRightSplit(doc: any, shiftKey?: boolean) { CollectionDockingView.ReplaceTab(doc, "right", undefined, shiftKey); }); \ No newline at end of file