diff options
author | Vellichora <fangrui_tong@brown.edu> | 2019-06-07 17:52:31 -0400 |
---|---|---|
committer | Vellichora <fangrui_tong@brown.edu> | 2019-06-07 17:52:31 -0400 |
commit | 70996f3f19d408e819e081ed03bd7ccf0de44503 (patch) | |
tree | a491c5d4ecfd087729a2f297d53ad7fa7812a239 /src/client/views/nodes/LinkManager.tsx | |
parent | 972f76a34e3c1a1aa5f0be59639fbd5763c9c16f (diff) |
links can be categorized under a group
Diffstat (limited to 'src/client/views/nodes/LinkManager.tsx')
-rw-r--r-- | src/client/views/nodes/LinkManager.tsx | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/src/client/views/nodes/LinkManager.tsx b/src/client/views/nodes/LinkManager.tsx deleted file mode 100644 index 1064eaa22..000000000 --- a/src/client/views/nodes/LinkManager.tsx +++ /dev/null @@ -1,51 +0,0 @@ -import { observable, computed, action } from "mobx"; -import React = require("react"); -import { SelectionManager } from "../../util/SelectionManager"; -import { observer } from "mobx-react"; -import './LinkEditor.scss'; -import { props } from "bluebird"; -import { DocumentView } from "./DocumentView"; -import { link } from "fs"; -import { StrCast, Cast } from "../../../new_fields/Types"; -import { Doc } from "../../../new_fields/Doc"; -import { listSpec } from "../../../new_fields/Schema"; - - -export class LinkManager { - private static _instance: LinkManager; - public static get Instance(): LinkManager { - return this._instance || (this._instance = new this()); - } - private constructor() { - } - - @observable - public allLinks: Array<Doc> = []; - - public findAllRelatedLinks(source: Doc): Array<Doc> { - let related = LinkManager.Instance.allLinks.filter( - link => Doc.AreProtosEqual(source, Cast(link.linkedFrom, Doc, new Doc)) || Doc.AreProtosEqual(source, Cast(link.linkedTo, Doc, new Doc))); - return related; - } - - public findRelatedGroupedLinks(source: Doc): Map<string, Array<Doc>> { - let related = this.findAllRelatedLinks(source); - let categories = new Map(); - related.forEach(link => { - let group = categories.get(link.linkTags); - if (group) group.push(link); - else group = [link]; - categories.set(link.linkTags, group); - }) - return categories; - } - - public findOppositeAnchor(link: Doc, source: Doc): Doc { - if (Doc.AreProtosEqual(source, Cast(link.linkedFrom, Doc, new Doc))) { - return Cast(link.linkedTo, Doc, new Doc); - } else { - return Cast(link.linkedFrom, Doc, new Doc); - } - } - -}
\ No newline at end of file |