diff options
author | tschicke-brown <tyler_schicke@brown.edu> | 2019-06-27 12:04:40 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-27 12:04:40 -0400 |
commit | c0bbdabe7d2e1eb422a12697848ada7127c6e2dc (patch) | |
tree | a4e335659205be8e3ed339c9a8f226e4f4bbc378 /src | |
parent | c5c181aea773eaf2cfb5cf1f6fc186e753665a81 (diff) | |
parent | 3fe6ec528a81e028bd0a72e87a67304f255ee702 (diff) |
Merge pull request #174 from browngraphicslab/monika_temp
search fixed for merge
Diffstat (limited to 'src')
-rw-r--r-- | src/client/documents/Documents.ts | 3 | ||||
-rw-r--r-- | src/client/views/search/SearchItem.tsx | 39 |
2 files changed, 32 insertions, 10 deletions
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts index 6dc98dbbc..7d7a1f02a 100644 --- a/src/client/documents/Documents.ts +++ b/src/client/documents/Documents.ts @@ -97,9 +97,10 @@ export namespace DocUtils { let linkDocProto = Doc.GetProto(linkDoc); linkDocProto.context = targetContext; - linkDocProto.title = title; //=== "" ? source.title + " to " + target.title : title; + linkDocProto.title = title === "" ? source.title + " to " + target.title : title; linkDocProto.linkDescription = description; linkDocProto.linkTags = tags; + linkDocProto.type = DocTypes.LINK; linkDocProto.anchor1 = source; linkDocProto.anchor1Page = source.curPage; diff --git a/src/client/views/search/SearchItem.tsx b/src/client/views/search/SearchItem.tsx index 5160d9469..b495975cb 100644 --- a/src/client/views/search/SearchItem.tsx +++ b/src/client/views/search/SearchItem.tsx @@ -19,6 +19,7 @@ import { FilterBox } from "./FilterBox"; import { DocumentView } from "../nodes/DocumentView"; import "./SelectorContextMenu.scss"; import { SearchBox } from "./SearchBox"; +import { LinkManager } from "../../util/LinkManager"; export interface SearchItemProps { doc: Doc; @@ -119,7 +120,7 @@ export class SearchItem extends React.Component<SearchItemProps> { } @computed - get linkCount() { return Cast(this.props.doc.linkedToDocs, listSpec(Doc), []).length + Cast(this.props.doc.linkedFromDocs, listSpec(Doc), []).length; } + get linkCount() { return LinkManager.Instance.getAllRelatedLinks(this.props.doc).length; } @computed get linkString(): string { @@ -133,17 +134,37 @@ export class SearchItem extends React.Component<SearchItemProps> { pointerDown = (e: React.PointerEvent) => { SearchBox.Instance.openSearch(e); }; highlightDoc = (e: React.PointerEvent) => { - let docViews: DocumentView[] = DocumentManager.Instance.getAllDocumentViews(this.props.doc); - docViews.forEach(element => { - element.props.Document.libraryBrush = true; - }); + if (this.props.doc.type === DocTypes.LINK) { + if (this.props.doc.anchor1 && this.props.doc.anchor2) { + + let doc1 = Cast(this.props.doc.anchor1, Doc, new Doc()); + let doc2 = Cast(this.props.doc.anchor2, Doc, new Doc()); + doc1.libraryBrush = true; + doc2.libraryBrush = true; + } + } else { + let docViews: DocumentView[] = DocumentManager.Instance.getAllDocumentViews(this.props.doc); + docViews.forEach(element => { + element.props.Document.libraryBrush = true; + }); + } } unHighlightDoc = (e: React.PointerEvent) => { - let docViews: DocumentView[] = DocumentManager.Instance.getAllDocumentViews(this.props.doc); - docViews.forEach(element => { - element.props.Document.libraryBrush = false; - }); + if (this.props.doc.type === DocTypes.LINK) { + if (this.props.doc.anchor1 && this.props.doc.anchor2) { + + let doc1 = Cast(this.props.doc.anchor1, Doc, new Doc()); + let doc2 = Cast(this.props.doc.anchor2, Doc, new Doc()); + doc1.libraryBrush = false; + doc2.libraryBrush = false; + } + } else { + let docViews: DocumentView[] = DocumentManager.Instance.getAllDocumentViews(this.props.doc); + docViews.forEach(element => { + element.props.Document.libraryBrush = false; + }); + } } render() { |