From 4c8d0e0cf2422bffe26fcddd91eca9e8f3145e1a Mon Sep 17 00:00:00 2001
From: Fawn <fangrui_tong@brown.edu>
Date: Fri, 26 Jul 2019 18:08:26 -0400
Subject: collection cannot be moved to inside itself in schema

---
 src/client/views/collections/CollectionSchemaMovableTableHOC.tsx | 9 +++++++++
 1 file changed, 9 insertions(+)

(limited to 'src/client/views/collections/CollectionSchemaMovableTableHOC.tsx')

diff --git a/src/client/views/collections/CollectionSchemaMovableTableHOC.tsx b/src/client/views/collections/CollectionSchemaMovableTableHOC.tsx
index f45575143..0ddd56180 100644
--- a/src/client/views/collections/CollectionSchemaMovableTableHOC.tsx
+++ b/src/client/views/collections/CollectionSchemaMovableTableHOC.tsx
@@ -11,6 +11,7 @@ import { action } from "mobx";
 import { library } from '@fortawesome/fontawesome-svg-core';
 import { faGripVertical, faTrash } from '@fortawesome/free-solid-svg-icons';
 import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
+import { DocumentManager } from "../../util/DocumentManager";
 
 library.add(faGripVertical, faTrash);
 
@@ -183,6 +184,14 @@ export class MovableRow extends React.Component<MovableRowProps> {
 
     @action
     move: DragManager.MoveFunction = (doc: Doc, target: Doc, addDoc) => {
+        let targetView = DocumentManager.Instance.getDocumentView(target);
+        if (targetView) {
+            let targetContainingColl = targetView.props.ContainingCollectionView; //.props.ContainingCollectionView.props.Document;
+            if (targetContainingColl) {
+                let targetContCollDoc = targetContainingColl.props.Document;
+                return doc !== target && doc !== targetContCollDoc && this.props.removeDoc(doc) && addDoc(doc);
+            }
+        }
         return doc !== target && this.props.removeDoc(doc) && addDoc(doc);
     }
 
-- 
cgit v1.2.3-70-g09d2

