aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/PropertiesDocBacklinksSelector.tsx
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2022-04-06 10:42:36 -0400
committerbobzel <zzzman@gmail.com>2022-04-06 10:42:36 -0400
commitaf8df1fc1af11318cadf1b71373bef776461a5cc (patch)
tree35cc41509dab9032c35708c561c0b341e4ece907 /src/client/views/PropertiesDocBacklinksSelector.tsx
parent8f6a065c192c091393e654bdac682c285a63ad8f (diff)
uses linkMenu in propertiesWindow now. updated linkMenu api, changed layout, made groups collapsible
Diffstat (limited to 'src/client/views/PropertiesDocBacklinksSelector.tsx')
-rw-r--r--src/client/views/PropertiesDocBacklinksSelector.tsx25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/client/views/PropertiesDocBacklinksSelector.tsx b/src/client/views/PropertiesDocBacklinksSelector.tsx
index ea0d90e04..082492671 100644
--- a/src/client/views/PropertiesDocBacklinksSelector.tsx
+++ b/src/client/views/PropertiesDocBacklinksSelector.tsx
@@ -2,10 +2,12 @@ import { computed } from "mobx";
import { observer } from "mobx-react";
import * as React from "react";
import { Doc, DocListCast } from "../../fields/Doc";
-import { Id } from "../../fields/FieldSymbols";
-import { Cast, NumCast, StrCast } from "../../fields/Types";
+import { Cast } from "../../fields/Types";
+import { DocumentType } from "../documents/DocumentTypes";
import { LinkManager } from "../util/LinkManager";
-import './PropertiesDocContextSelector.scss';
+import { SelectionManager } from "../util/SelectionManager";
+import { LinkMenu } from "./linking/LinkMenu";
+import './PropertiesDocBacklinksSelector.scss';
type PropertiesDocBacklinksSelectorProps = {
Document: Doc,
@@ -22,7 +24,7 @@ export class PropertiesDocBacklinksSelector extends React.Component<PropertiesDo
const collectedLinks = [] as Doc[];
links.map(link => {
const other = LinkManager.getOppositeAnchor(link, linkSource);
- const otherdoc = !other ? undefined : other.annotationOn ? Cast(other.annotationOn, Doc, null) : other;
+ const otherdoc = !other ? undefined : other.annotationOn && other.type !== DocumentType.RTF ? Cast(other.annotationOn, Doc, null) : other;
if (otherdoc && !collectedLinks.some(d => Doc.AreProtosEqual(d, otherdoc))) {
collectedLinks.push(otherdoc);
}
@@ -30,15 +32,20 @@ export class PropertiesDocBacklinksSelector extends React.Component<PropertiesDo
return collectedLinks;
}
- getOnClick = (col: Doc) => {
- col = Doc.IsPrototype(col) ? Doc.MakeDelegate(col) : col;
- this.props.addDocTab(col, "toggle:right");
+ getOnClick = (link: Doc) => {
+ const linkSource = this.props.Document;
+ const other = LinkManager.getOppositeAnchor(link, linkSource);
+ const otherdoc = !other ? undefined : other.annotationOn && other.type !== DocumentType.RTF ? Cast(other.annotationOn, Doc, null) : other;
+
+ if (otherdoc) {
+ this.props.addDocTab(Doc.IsPrototype(otherdoc) ? Doc.MakeDelegate(otherdoc) : otherdoc, "toggle:right");
+ }
}
render() {
- return <div>
+ return !SelectionManager.Views().length ? (null) : <div>
{this.props.hideTitle ? (null) : <p key="contexts">Contexts:</p>}
- {this._docs.map(doc => <p key={doc[Id]}><a onClick={() => this.getOnClick(doc)}>{StrCast(doc.title)}</a></p>)}
+ <LinkMenu docView={SelectionManager.Views().lastElement()} itemHandler={this.getOnClick} position={{ x: 0 }} />
</div>;
}
} \ No newline at end of file