aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/collectionFreeForm/CollectionFreeFormLinksView.tsx
diff options
context:
space:
mode:
authorFawn <fangrui_tong@brown.edu>2019-06-19 22:27:21 -0400
committerFawn <fangrui_tong@brown.edu>2019-06-19 22:27:21 -0400
commitc5e401cb0a7fec2279ceecbc8d1429dcdd2f04b9 (patch)
treed7e3b77890c3c4f3be0dca1da9c4aae71ecaead7 /src/client/views/collections/collectionFreeForm/CollectionFreeFormLinksView.tsx
parentf362dbfc237536c6c4a8c6d088c3dc818080f7c2 (diff)
buttons on cut links functional except for when dragged from link menu
Diffstat (limited to 'src/client/views/collections/collectionFreeForm/CollectionFreeFormLinksView.tsx')
-rw-r--r--src/client/views/collections/collectionFreeForm/CollectionFreeFormLinksView.tsx42
1 files changed, 29 insertions, 13 deletions
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormLinksView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormLinksView.tsx
index eaef1f32a..bde68001b 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormLinksView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormLinksView.tsx
@@ -1,4 +1,4 @@
-import { computed, IReactionDisposer, reaction } from "mobx";
+import { computed, IReactionDisposer, reaction, action } from "mobx";
import { observer } from "mobx-react";
import { Doc, DocListCast } from "../../../../new_fields/Doc";
import { Id } from "../../../../new_fields/FieldSymbols";
@@ -13,6 +13,8 @@ import { CollectionFreeFormLinkView } from "./CollectionFreeFormLinkView";
import React = require("react");
import { CollectionFreeFormLinkWithProxyView } from "./CollectionFreeFormLinkWithProxyView";
import { Docs } from "../../../documents/Documents";
+import { LinkButtonField } from "../../../../new_fields/LinkButtonField";
+import { LinkManager } from "../../../util/LinkManager";
@observer
export class CollectionFreeFormLinksView extends React.Component<CollectionViewProps> {
@@ -195,18 +197,32 @@ export class CollectionFreeFormLinksView extends React.Component<CollectionViewP
if (sameContext) {
uniqueList.push(<CollectionFreeFormLinkView key={key} sourceView={u.sourceView} targetView={u.targetView} />);
} else {
- let proxyKey = Doc.AreProtosEqual(u.sourceView.Document, Cast(u.linkDoc.anchor1, Doc, new Doc)) ? "proxy1" : "proxy2";
- let proxy = Cast(u.linkDoc[proxyKey], Doc, new Doc);
-
- let context = u.targetView.props.ContainingCollectionView ? (" in the context of " + StrCast(u.targetView.props.ContainingCollectionView.props.Document.title)) : "";
- let text = proxyKey + " link to " + StrCast(u.targetView.props.Document.title) + context;
-
- let proxyProto = Doc.GetProto(proxy);
- proxyProto.data = text;
-
- this.props.addDocument(proxy, false);
- uniqueList.push(<CollectionFreeFormLinkWithProxyView key={key} sourceView={u.sourceView} targetView={u.targetView}
- proxyDoc={proxy} addDocTab={this.props.addDocTab} />);
+ let proxy = LinkManager.Instance.findLinkProxy(StrCast(u.sourceView.props.Document[Id]), StrCast(u.targetView.props.Document[Id]));
+ if (!proxy) {
+ proxy = Docs.LinkButtonDocument(
+ { sourceViewId: StrCast(u.sourceView.props.Document[Id]), targetViewId: StrCast(u.targetView.props.Document[Id]) },
+ { width: 200, height: 100, borderRounding: 0 });
+ let proxy1Proto = Doc.GetProto(proxy);
+ proxy1Proto.sourceViewId = StrCast(u.sourceView.props.Document[Id]);
+ proxy1Proto.targetViewId = StrCast(u.targetView.props.Document[Id]);
+ proxy1Proto.isLinkButton = true;
+
+ // LinkManager.Instance.linkProxies.push(proxy);
+ LinkManager.Instance.addLinkProxy(proxy);
+ }
+ uniqueList.push(<CollectionFreeFormLinkWithProxyView key={key} sourceView={u.sourceView} targetView={u.targetView} proxyDoc={proxy} />);
+
+ // let proxy = LinkManager.Instance.findLinkProxy(StrCast(u.sourceView.props.Document[Id]), StrCast(u.targetView.props.Document[Id]));
+ // if (proxy) {
+ // this.props.addDocument(proxy, false);
+ // uniqueList.push(<CollectionFreeFormLinkWithProxyView key={key} sourceView={u.sourceView} targetView={u.targetView} />);
+ // }
+ // let proxyKey = Doc.AreProtosEqual(u.sourceView.Document, Cast(u.linkDoc.anchor1, Doc, new Doc)) ? "proxy1" : "proxy2";
+ // let proxy = Cast(u.linkDoc[proxyKey], Doc, new Doc);
+ // this.props.addDocument(proxy, false);
+
+ // uniqueList.push(<CollectionFreeFormLinkWithProxyView key={key} sourceView={u.sourceView} targetView={u.targetView}
+ // proxyDoc={proxy} addDocTab={this.props.addDocTab} />);
}
}
});