From f3a3536ea4b31cf93748490f4b46a56c4775565f Mon Sep 17 00:00:00 2001 From: bobzel Date: Wed, 1 Sep 2021 15:19:38 -0400 Subject: fixed toggleDetail() func to work. --- src/client/views/nodes/DocumentView.tsx | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src/client/views/nodes/DocumentView.tsx') diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx index 6b9513b8b..20d7a650f 100644 --- a/src/client/views/nodes/DocumentView.tsx +++ b/src/client/views/nodes/DocumentView.tsx @@ -208,7 +208,7 @@ export class DocumentViewInternal extends DocComponent this.props.removeDocument?.(this.props.Document); - @undoBatch toggleDetail = () => this.Document.onClick = ScriptField.MakeScript(`toggleDetail(self, "${this.Document.layoutKey}")`); + @undoBatch setToggleDetail = () => this.Document.onClick = ScriptField.MakeScript(`toggleDetail(documentView, "${this.Document.layoutKey}")`, { documentView: "any" }); @undoBatch @action drop = async (e: Event, de: DragManager.DropEvent) => { @@ -709,7 +709,7 @@ export class DocumentViewInternal extends DocComponent this.Document.onClick = ScriptField.MakeScript(`toggleDetail(self, "${this.Document.layoutKey}")`), icon: "concierge-bell" }); + onClicks.push({ description: "Toggle Detail", event: () => this.Document.onClick = ScriptField.MakeScript(`toggleDetail(documentView, "${this.Document.layoutKey}")`, { documentView: "any" }), icon: "concierge-bell" }); onClicks.push({ description: (this.Document.followLinkZoom ? "Don't" : "") + " zoom following link", event: () => this.Document.followLinkZoom = !this.Document.followLinkZoom, icon: this.Document.ignoreClick ? "unlock" : "lock" }); if (!this.Document.annotationOn) { @@ -1189,8 +1189,7 @@ export class DocumentView extends React.Component { } } -Scripting.addGlobal(function toggleDetail(doc: any, layoutKey: string, otherKey: string = "layout") { - const dv = DocumentManager.Instance.getDocumentView(doc); - if (dv?.props.Document.layoutKey === layoutKey) dv?.switchViews(otherKey !== "layout", otherKey.replace("layout_", "")); - else dv?.switchViews(true, layoutKey.replace("layout_", "")); +Scripting.addGlobal(function toggleDetail(dv: DocumentView, detailLayoutKey: string, primaryLayoutKey: string = "layout") { + if (dv.Document.layoutKey === detailLayoutKey) dv.switchViews(primaryLayoutKey !== "layout", primaryLayoutKey.replace("layout_", "")); + else dv.switchViews(true, detailLayoutKey.replace("layout_", "")); }); \ No newline at end of file -- cgit v1.2.3-70-g09d2