aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2022-04-01 10:34:09 -0400
committerbobzel <zzzman@gmail.com>2022-04-01 10:34:09 -0400
commit19366220aabeeb6fcdac6fa056b9b0e9585e8e6b (patch)
treec1ec26a515c77725f628c92b601647bca8946e8e
parentd5d472521229f006f4a95d5c019276ec0281ac57 (diff)
fixed up document focus to take a collectkon so that the treeView can focus on the matching alias when multiple aliases are shown in different collections.
-rw-r--r--src/client/util/DocumentManager.ts13
-rw-r--r--src/client/views/PropertiesDocContextSelector.tsx3
-rw-r--r--src/client/views/StyleProvider.tsx8
-rw-r--r--src/client/views/collections/TreeView.tsx2
4 files changed, 19 insertions, 7 deletions
diff --git a/src/client/util/DocumentManager.ts b/src/client/util/DocumentManager.ts
index 0a00ab6e0..ad6d90bc3 100644
--- a/src/client/util/DocumentManager.ts
+++ b/src/client/util/DocumentManager.ts
@@ -5,6 +5,7 @@ import { Cast } from '../../fields/Types';
import { returnFalse } from '../../Utils';
import { DocumentType } from '../documents/DocumentTypes';
import { CollectionDockingView } from '../views/collections/CollectionDockingView';
+import { CollectionFreeFormView } from '../views/collections/collectionFreeForm';
import { CollectionView } from '../views/collections/CollectionView';
import { LightboxView } from '../views/LightboxView';
import { DocumentView, ViewAdjustment } from '../views/nodes/DocumentView';
@@ -252,10 +253,11 @@ export class DocumentManager {
}
}
-ScriptingGlobals.add(function DocFocusOrOpen(doc: any) {
- const dv = DocumentManager.Instance.getDocumentView(doc);
- if (dv && dv.props.Document === doc) {
- dv.props.focus(doc, { willZoom: true });
+export function DocFocusOrOpen(doc: any, collectionDoc?: Doc) {
+ const cv = collectionDoc && DocumentManager.Instance.getDocumentView(collectionDoc);
+ const dv = DocumentManager.Instance.getDocumentView(doc, (cv?.ComponentView as CollectionFreeFormView)?.props.CollectionView);
+ if (dv && Doc.AreProtosEqual(dv.props.Document, doc)) {
+ dv.props.focus(dv.props.Document, { willZoom: true });
Doc.linkFollowHighlight(dv?.props.Document, false);
}
else {
@@ -264,4 +266,5 @@ ScriptingGlobals.add(function DocFocusOrOpen(doc: any) {
CollectionDockingView.AddSplit(showDoc === Doc.GetProto(showDoc) ? Doc.MakeAlias(showDoc) : showDoc, "right") && context &&
setTimeout(() => DocumentManager.Instance.getDocumentView(Doc.GetProto(doc))?.focus(doc));
}
-}); \ No newline at end of file
+}
+ScriptingGlobals.add(DocFocusOrOpen); \ No newline at end of file
diff --git a/src/client/views/PropertiesDocContextSelector.tsx b/src/client/views/PropertiesDocContextSelector.tsx
index 4d803f992..015e0c8ee 100644
--- a/src/client/views/PropertiesDocContextSelector.tsx
+++ b/src/client/views/PropertiesDocContextSelector.tsx
@@ -4,6 +4,7 @@ import * as React from "react";
import { Doc, DocListCast } from "../../fields/Doc";
import { Id } from "../../fields/FieldSymbols";
import { Cast, NumCast, StrCast } from "../../fields/Types";
+import { DocFocusOrOpen } from "../util/DocumentManager";
import { CollectionDockingView } from "./collections/CollectionDockingView";
import { CollectionViewType } from "./collections/CollectionView";
import { DocumentView } from "./nodes/DocumentView";
@@ -32,12 +33,14 @@ export class PropertiesDocContextSelector extends React.Component<PropertiesDocC
}
getOnClick = (col: Doc, target: Doc) => {
+ if (!this.props.DocView) return;
col = Doc.IsPrototype(col) ? Doc.MakeDelegate(col) : col;
if (col._viewType === CollectionViewType.Freeform) {
col._panX = NumCast(target.x) + NumCast(target._width) / 2;
col._panY = NumCast(target.y) + NumCast(target._height) / 2;
}
this.props.addDocTab(col, "toggle:right");
+ setTimeout(() => DocFocusOrOpen(Doc.GetProto(this.props.DocView!.props.Document), col), 100);
}
render() {
diff --git a/src/client/views/StyleProvider.tsx b/src/client/views/StyleProvider.tsx
index 2782574c5..649ee8394 100644
--- a/src/client/views/StyleProvider.tsx
+++ b/src/client/views/StyleProvider.tsx
@@ -10,6 +10,7 @@ import { BoolCast, Cast, NumCast, StrCast } from "../../fields/Types";
import { DashColor, lightOrDark } from '../../Utils';
import { DocumentType } from '../documents/DocumentTypes';
import { CurrentUserUtils } from '../util/CurrentUserUtils';
+import { DocFocusOrOpen } from '../util/DocumentManager';
import { ColorScheme } from '../util/SettingsManager';
import { SnappingManager } from '../util/SnappingManager';
import { undoBatch, UndoManager } from '../util/UndoManager';
@@ -212,7 +213,12 @@ export function DashboardStyleProvider(doc: Opt<Doc>, props: Opt<FieldViewProps
if (doc && property.split(":")[0] === StyleProp.Decorations) {
return doc._viewType === CollectionViewType.Docking ? (null) :
<>
- {DashboardToggleButton(doc, "hidden", "eye-slash", "eye")}
+ {DashboardToggleButton(doc, "hidden", "eye-slash", "eye", () => {
+ doc.hidden = doc.hidden ? undefined : true;
+ if (!doc.hidden) {
+ DocFocusOrOpen(doc, props?.ContainingCollectionDoc);
+ }
+ })}
{DashboardToggleButton(doc, "lockedPosition", "lock", "unlock")}
</>;
}
diff --git a/src/client/views/collections/TreeView.tsx b/src/client/views/collections/TreeView.tsx
index eedb353e3..ff5c4bab1 100644
--- a/src/client/views/collections/TreeView.tsx
+++ b/src/client/views/collections/TreeView.tsx
@@ -669,7 +669,7 @@ export class TreeView extends React.Component<TreeViewProps> {
ContentScaling={returnOne}
/>;
- const buttons = this.props.styleProvider?.(this.doc, this.props.treeView.props, StyleProp.Decorations + (Doc.IsSystem(this.props.containerCollection) ? ":afterHeader" : ""));
+ const buttons = this.props.styleProvider?.(this.doc, { ...this.props.treeView.props, ContainingCollectionDoc: this.props.parentTreeView?.doc }, StyleProp.Decorations + (Doc.IsSystem(this.props.containerCollection) ? ":afterHeader" : ""));
return <>
<div className={`docContainer${Doc.IsSystem(this.props.document) || this.props.document.isFolder ? "-system" : ""}`} ref={this._tref} title="click to edit title. Double Click or Drag to Open"
style={{