From d784ff45113517d9c3ebcfa6ef50cd01efdfc3f6 Mon Sep 17 00:00:00 2001
From: Hannah Chow <hannah_chow@brown.edu>
Date: Mon, 11 Mar 2019 00:32:17 -0400
Subject: DONE

---
 src/client/views/nodes/LinkMenu.tsx | 64 +++++++++++++++++++++----------------
 1 file changed, 37 insertions(+), 27 deletions(-)

(limited to 'src/client/views/nodes/LinkMenu.tsx')

diff --git a/src/client/views/nodes/LinkMenu.tsx b/src/client/views/nodes/LinkMenu.tsx
index 577aba398..9a95a4f09 100644
--- a/src/client/views/nodes/LinkMenu.tsx
+++ b/src/client/views/nodes/LinkMenu.tsx
@@ -11,6 +11,7 @@ import { Document } from "../../../fields/Document";
 import { ListField } from "../../../fields/ListField";
 import { TextField } from "../../../fields/TextField";
 import { FieldWaiting } from "../../../fields/Field";
+import { LinkEditor } from "./LinkEditor";
 
 interface Props {
     docView: DocumentView;
@@ -20,39 +21,48 @@ interface Props {
 @observer
 export class LinkMenu extends React.Component<Props> {
 
+    @observable private _editingLink?: Document;
+
     render() {
         //get list of links from document
         let linkFrom: Document[] = this.props.docView.props.Document.GetData(KeyStore.LinkedFromDocs, ListField, []);
         let linkTo: Document[] = this.props.docView.props.Document.GetData(KeyStore.LinkedToDocs, ListField, []);
+        if (this._editingLink === undefined) {
+            return (
+
+                <div id="menu-container">
+                    <input id="search-bar" type="text" placeholder="Search..."></input>
+                    <div id="link-list">
+
+                        {linkTo.map(link => {
+                            let name = link.GetData(KeyStore.Title, TextField, new String);
+                            let doc = link.GetT(KeyStore.LinkedToDocs, Document);
+                            if (doc && doc != FieldWaiting) {
+                                return <LinkBox linkDoc={link} linkName={name} pairedDoc={doc} showEditor={action(() => this._editingLink = link)} type={"Destination: "} />
+                            } else {
+                                return <div></div>
+                            }
+
+                        })}
+
+                        {linkFrom.map(link => {
+                            let name = link.GetData(KeyStore.Title, TextField, new String);
+                            let doc = link.GetT(KeyStore.LinkedFromDocs, Document);
+                            if (doc && doc != FieldWaiting) {
+                                return <LinkBox linkDoc={link} linkName={name} pairedDoc={doc} showEditor={action(() => this._editingLink = link)} type={"Source: "} />
+                            } else {
+                                return <div></div>
+                            }
+                        })}
+                    </div>
 
-        return (
-            <div id="menu-container">
-                <input id="search-bar" type="text" placeholder="Search..."></input>
-                <div id="link-list">
-
-                    {linkTo.map(link => {
-                        let name = link.GetData(KeyStore.Title, TextField, new String);
-                        let doc = link.GetT(KeyStore.LinkedToDocs, Document);
-                        if (doc && doc != FieldWaiting) {
-                            return <LinkBox linkDoc={link} linkName={name} pairedDoc={doc} type={"Destination: "} />
-                        } else {
-                            return <div></div>
-                        }
-
-                    })}
-
-                    {linkFrom.map(link => {
-                        let name = link.GetData(KeyStore.Title, TextField, new String);
-                        let doc = link.GetT(KeyStore.LinkedFromDocs, Document);
-                        if (doc && doc != FieldWaiting) {
-                            return <LinkBox linkDoc={link} linkName={name} pairedDoc={doc} type={"Source: "} />
-                        } else {
-                            return <div></div>
-                        }
-                    })}
                 </div>
+            )
+        } else {
+            return (
+                <LinkEditor linkDoc={this._editingLink} showLinks={action(() => this._editingLink = undefined)}></LinkEditor>
+            )
+        }
 
-            </div>
-        )
     }
 }
\ No newline at end of file
-- 
cgit v1.2.3-70-g09d2

