From 05b87c394731fbed21f9b358967c337ce294272d Mon Sep 17 00:00:00 2001 From: bobzel Date: Tue, 16 Feb 2021 20:48:29 -0500 Subject: added doubel tap on links button to enter portal for document + links --- .../views/collections/CollectionTimeView.tsx | 4 +-- .../collectionFreeForm/CollectionFreeFormView.tsx | 8 +++-- src/client/views/nodes/DocumentLinksButton.tsx | 35 ++++++++++++++++++++-- 3 files changed, 41 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/client/views/collections/CollectionTimeView.tsx b/src/client/views/collections/CollectionTimeView.tsx index 426eced1d..53eb6e0be 100644 --- a/src/client/views/collections/CollectionTimeView.tsx +++ b/src/client/views/collections/CollectionTimeView.tsx @@ -81,8 +81,8 @@ export class CollectionTimeView extends CollectionSubView(doc => doc) { } else if (anchor.pivotField !== undefined) { // otherwise set document's fields based on anchor view spec this.layoutDoc._prevFilterIndex = 1; this.layoutDoc._pivotField = StrCast(anchor.pivotField); - this.layoutDoc._docFilters = new List(this.pivotDocFilters()); - this.layoutDoc._docRangeFilters = new List(this.pivotDocRangeFilters()); + this.layoutDoc._docFilters = new List(StrListCast(anchor.docFilters)); + this.layoutDoc._docRangeFilters = new List(StrListCast(anchor.docRangeFilters)); } return 0; } diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx index c54596a9e..a5d7489bd 100644 --- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx +++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx @@ -116,6 +116,7 @@ export class CollectionFreeFormView extends CollectionSubView(); @observable _marqueeRef = React.createRef(); @observable _focusFilters: Opt; // fields that get overriden by focus anchor + @observable _focusRangeFilters: Opt; // fields that get overriden by focus anchor @computed get backgroundActive() { return this.props.layerProvider?.(this.layoutDoc) === false && (this.props.ContainingCollectionView?.active() || this.props.active()); } @computed get fitToContentVals() { @@ -1027,7 +1028,7 @@ export class CollectionFreeFormView extends CollectionSubView this._focusFilters || this.docFilters(); + freeformRangeDocFilters = () => this._focusRangeFilters || this.docRangeFilters(); @action setViewSpec = (anchor: Doc, preview: boolean) => { if (preview) { this._focusFilters = StrListCast(Doc.GetProto(anchor).docFilters); + this._focusRangeFilters = StrListCast(Doc.GetProto(anchor).docRangeFilters); } else if (anchor.pivotField !== undefined) { - this.layoutDoc._docFilters = ObjectField.MakeCopy(Doc.GetProto(anchor).docFilters as ObjectField); + this.layoutDoc._docFilters = new List(StrListCast(anchor.docFilters)); + this.layoutDoc._docRangeFilters = new List(StrListCast(anchor.docRangeFilters)); } return 0; } diff --git a/src/client/views/nodes/DocumentLinksButton.tsx b/src/client/views/nodes/DocumentLinksButton.tsx index 13a6c9df8..8a90d5d62 100644 --- a/src/client/views/nodes/DocumentLinksButton.tsx +++ b/src/client/views/nodes/DocumentLinksButton.tsx @@ -2,7 +2,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { Tooltip } from "@material-ui/core"; import { action, computed, observable, runInAction } from "mobx"; import { observer } from "mobx-react"; -import { Doc, DocListCast, Opt } from "../../../fields/Doc"; +import { Doc, DocListCast, Opt, WidthSym, DocListCastAsync } from "../../../fields/Doc"; import { emptyFunction, setupMoveUpEvents, returnFalse, Utils, emptyPath } from "../../../Utils"; import { TraceMobx } from "../../../fields/util"; import { DocUtils, Docs } from "../../documents/Documents"; @@ -17,6 +17,9 @@ import { Id } from "../../../fields/FieldSymbols"; import { TaskCompletionBox } from "./TaskCompletedBox"; import React = require("react"); import './DocumentLinksButton.scss'; +import { DocServer } from "../../DocServer"; +import { LightboxView } from "../LightboxView"; +import { cat } from "shelljs"; const higflyout = require("@hig/flyout"); export const { anchorPoints } = higflyout; @@ -83,7 +86,35 @@ export class DocumentLinksButton extends React.Component { + const rootAlias = () => { + const rootAlias = Doc.MakeAlias(rootDoc); + rootAlias.x = rootAlias.y = 0; + return rootAlias; + } + let wid = rootDoc[WidthSym](); + const target = ((docx instanceof Doc) && docx) || Docs.Create.FreeformDocument([rootAlias()], { title: this.props.View.Document.title + "-pivot", _width: 500, _height: 500, }, docid); + const docs = await DocListCastAsync(Doc.GetProto(target).data); + if (!target.pivotFocusish) (Doc.GetProto(target).pivotFocusish = target); + DocListCast(rootDoc.links).forEach(link => { + const other = LinkManager.getOppositeAnchor(link, rootDoc); + const otherdoc = !other ? undefined : other.annotationOn ? Cast(other.annotationOn, Doc, null) : other; + if (otherdoc && !docs?.some(d => Doc.AreProtosEqual(d, otherdoc))) { + const alias = Doc.MakeAlias(otherdoc); + alias.x = wid; + alias.y = 0; + alias.lockedPosition = false; + wid += otherdoc[WidthSym](); + Doc.AddDocToList(Doc.GetProto(target), "data", alias); + } + }); + LightboxView.SetLightboxDoc(target); + }); + } + else DocumentLinksButton.LinkEditorDocView = this.props.View; } })); } -- cgit v1.2.3-70-g09d2