diff options
Diffstat (limited to 'src/client/util/DocumentManager.ts')
| -rw-r--r-- | src/client/util/DocumentManager.ts | 60 | 
1 files changed, 26 insertions, 34 deletions
| diff --git a/src/client/util/DocumentManager.ts b/src/client/util/DocumentManager.ts index 1ba6f0248..67f2f244c 100644 --- a/src/client/util/DocumentManager.ts +++ b/src/client/util/DocumentManager.ts @@ -1,7 +1,7 @@  import { action, computed, observable } from 'mobx'; -import { Doc, DocListCastAsync, DocListCast, Opt } from '../../new_fields/Doc'; -import { Id } from '../../new_fields/FieldSymbols'; -import { Cast, NumCast, StrCast } from '../../new_fields/Types'; +import { Doc, DocListCastAsync, DocListCast, Opt } from '../../fields/Doc'; +import { Id } from '../../fields/FieldSymbols'; +import { Cast, NumCast, StrCast } from '../../fields/Types';  import { CollectionDockingView } from '../views/collections/CollectionDockingView';  import { CollectionView } from '../views/collections/CollectionView';  import { DocumentView, DocFocusFunc } from '../views/nodes/DocumentView'; @@ -94,37 +94,29 @@ export class DocumentManager {          // heuristic to return the "best" documents first:          //   choose an exact match over an alias match          //   choose documents that have a PanelWidth() over those that don't (the treeview documents have no panelWidth) -        docViews.map(view => !view.props.Document.presBox && view.props.PanelWidth() > 1 && view.props.Document === toFind && toReturn.push(view)); -        docViews.map(view => !view.props.Document.presBox && view.props.PanelWidth() <= 1 && view.props.Document === toFind && toReturn.push(view)); -        docViews.map(view => !view.props.Document.presBox && view.props.PanelWidth() > 1 && view.props.Document !== toFind && Doc.AreProtosEqual(view.props.Document, toFind) && toReturn.push(view)); -        docViews.map(view => !view.props.Document.presBox && view.props.PanelWidth() <= 1 && view.props.Document !== toFind && Doc.AreProtosEqual(view.props.Document, toFind) && toReturn.push(view)); +        docViews.map(view => view.props.PanelWidth() > 1 && view.props.Document === toFind && toReturn.push(view)); +        docViews.map(view => view.props.PanelWidth() <= 1 && view.props.Document === toFind && toReturn.push(view)); +        docViews.map(view => view.props.PanelWidth() > 1 && view.props.Document !== toFind && Doc.AreProtosEqual(view.props.Document, toFind) && toReturn.push(view)); +        docViews.map(view => view.props.PanelWidth() <= 1 && view.props.Document !== toFind && Doc.AreProtosEqual(view.props.Document, toFind) && toReturn.push(view));          return toReturn;      }      @computed      public get LinkedDocumentViews() { -        const pairs = DocumentManager.Instance.DocumentViews -            //.filter(dv => (dv.isSelected() || Doc.IsBrushed(dv.props.Document))) // draw links from DocumentViews that are selected or brushed OR -            // || DocumentManager.Instance.DocumentViews.some(dv2 => {                                                  // Documentviews which -            //     const rest = DocListCast(dv2.props.Document.links).some(l => Doc.AreProtosEqual(l, dv.props.Document));// are link doc anchors  -            //     const init = (dv2.isSelected() || Doc.IsBrushed(dv2.props.Document)) && dv2.Document.type !== DocumentType.AUDIO;  // on a view that is selected or brushed -            //     return init && rest; -            // } -            // ) -            .reduce((pairs, dv) => { -                const linksList = LinkManager.Instance.getAllRelatedLinks(dv.props.Document); -                pairs.push(...linksList.reduce((pairs, link) => { -                    const linkToDoc = link && LinkManager.Instance.getOppositeAnchor(link, dv.props.Document); -                    linkToDoc && DocumentManager.Instance.getDocumentViews(linkToDoc).map(docView1 => { -                        if (dv.props.Document.type !== DocumentType.LINK || dv.props.LayoutTemplateString !== docView1.props.LayoutTemplateString) { -                            pairs.push({ a: dv, b: docView1, l: link }); -                        } -                    }); -                    return pairs; -                }, [] as { a: DocumentView, b: DocumentView, l: Doc }[])); +        const pairs = DocumentManager.Instance.DocumentViews.reduce((pairs, dv) => { +            const linksList = LinkManager.Instance.getAllRelatedLinks(dv.props.Document); +            pairs.push(...linksList.reduce((pairs, link) => { +                const linkToDoc = link && LinkManager.Instance.getOppositeAnchor(link, dv.props.Document); +                linkToDoc && DocumentManager.Instance.getDocumentViews(linkToDoc).map(docView1 => { +                    if (dv.props.Document.type !== DocumentType.LINK || dv.props.LayoutTemplateString !== docView1.props.LayoutTemplateString) { +                        pairs.push({ a: dv, b: docView1, l: link }); +                    } +                });                  return pairs; -            }, [] as { a: DocumentView, b: DocumentView, l: Doc }[]); +            }, [] as { a: DocumentView, b: DocumentView, l: Doc }[])); +            return pairs; +        }, [] as { a: DocumentView, b: DocumentView, l: Doc }[]);          return pairs;      } @@ -134,13 +126,13 @@ export class DocumentManager {          finished?.();      }      public jumpToDocument = async ( -        targetDoc: Doc, -        willZoom: boolean, -        createViewFunc = DocumentManager.addRightSplit, -        docContext?: Doc, -        linkId?: string, -        closeContextIfNotFound: boolean = false, -        originatingDoc: Opt<Doc> = undefined, +        targetDoc: Doc,        // document to display +        willZoom: boolean,     // whether to zoom doc to take up most of screen +        createViewFunc = DocumentManager.addRightSplit, // how to create a view of the doc if it doesn't exist +        docContext?: Doc,  // context to load that should contain the target +        linkId?: string,   // link that's being followed +        closeContextIfNotFound: boolean = false, // after opening a context where the document should be, this determines whether the context should be closed if the Doc isn't actually there +        originatingDoc: Opt<Doc> = undefined, // doc that initiated the display of the target odoc          finished?: () => void      ): Promise<void> => {          const getFirstDocView = DocumentManager.Instance.getFirstDocumentView; | 
