From d2a95b1aa144e8dd4e87338525922dae1f3d9e67 Mon Sep 17 00:00:00 2001
From: bob <bcz@cs.brown.edu>
Date: Wed, 24 Apr 2019 09:56:59 -0400
Subject: added blacklist to stop docs form linking to their parent collection.
  refactored drag threshold to Utils

---
 src/client/views/nodes/DocumentView.tsx | 43 ++++++++++++++++++---------------
 1 file changed, 23 insertions(+), 20 deletions(-)

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

diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index b3b9f6e51..252f4d039 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -148,7 +148,8 @@ export class DocumentView extends React.Component<DocumentViewProps> {
 
     onClick = (e: React.MouseEvent): void => {
         if (CurrentUserUtils.MainDocId != this.props.Document.Id &&
-            (Math.abs(e.clientX - this._downX) < MarqueeView.DRAG_THRESHOLD && Math.abs(e.clientY - this._downY) < MarqueeView.DRAG_THRESHOLD)) {
+            (Math.abs(e.clientX - this._downX) < Utils.DRAG_THRESHOLD &&
+                Math.abs(e.clientY - this._downY) < Utils.DRAG_THRESHOLD)) {
             SelectionManager.SelectDoc(this, e.ctrlKey);
         }
         e.stopPropagation();
@@ -230,25 +231,27 @@ export class DocumentView extends React.Component<DocumentViewProps> {
 
                         let dstTarg = protoDest ? protoDest : destDoc;
                         let srcTarg = protoSrc ? protoSrc : sourceDoc;
-                        linkDoc.Set(KeyStore.LinkedToDocs, dstTarg);
-                        linkDoc.Set(KeyStore.LinkedFromDocs, srcTarg);
-                        const prom1 = new Promise(resolve => dstTarg.GetOrCreateAsync(
-                            KeyStore.LinkedFromDocs,
-                            ListField,
-                            field => {
-                                (field as ListField<Document>).Data.push(linkDoc);
-                                resolve();
-                            }
-                        ));
-                        const prom2 = new Promise(resolve => srcTarg.GetOrCreateAsync(
-                            KeyStore.LinkedToDocs,
-                            ListField,
-                            field => {
-                                (field as ListField<Document>).Data.push(linkDoc);
-                                resolve();
-                            }
-                        ));
-                        Promise.all([prom1, prom2]).finally(() => batch.end());
+                        if ((de.data as DragManager.LinkDragData).blacklist.indexOf(dstTarg) === -1) {
+                            linkDoc.Set(KeyStore.LinkedToDocs, dstTarg);
+                            linkDoc.Set(KeyStore.LinkedFromDocs, srcTarg);
+                            const prom1 = new Promise(resolve => dstTarg.GetOrCreateAsync(
+                                KeyStore.LinkedFromDocs,
+                                ListField,
+                                field => {
+                                    (field as ListField<Document>).Data.push(linkDoc);
+                                    resolve();
+                                }
+                            ));
+                            const prom2 = new Promise(resolve => srcTarg.GetOrCreateAsync(
+                                KeyStore.LinkedToDocs,
+                                ListField,
+                                field => {
+                                    (field as ListField<Document>).Data.push(linkDoc);
+                                    resolve();
+                                }
+                            ));
+                            Promise.all([prom1, prom2]).finally(() => batch.end());
+                        }
                     })
                 )
             );
-- 
cgit v1.2.3-70-g09d2

