From 59cc888c8bf0559c50e12fd2774ea5ac4ebb3059 Mon Sep 17 00:00:00 2001
From: yipstanley <stanley_yip@brown.edu>
Date: Tue, 26 Feb 2019 16:33:53 -0500
Subject: basic implementation of prototype/delegate stuff

---
 src/client/views/collections/CollectionViewBase.tsx | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

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

diff --git a/src/client/views/collections/CollectionViewBase.tsx b/src/client/views/collections/CollectionViewBase.tsx
index 7e269caf1..be3cb0d5f 100644
--- a/src/client/views/collections/CollectionViewBase.tsx
+++ b/src/client/views/collections/CollectionViewBase.tsx
@@ -43,11 +43,21 @@ export class CollectionViewBase extends React.Component<SubCollectionViewProps>
     @action
     protected drop(e: Event, de: DragManager.DropEvent) {
         const doc: DocumentView = de.data["document"];
+        if (de.data["alias"]) {
+            let newDoc = doc.props.Document.CreateAlias()
+            const xOffset = de.data["xOffset"] as number || 0
+            const yOffset = de.data["yOffset"] as number || 0
+            newDoc.SetNumber(KeyStore.X, de.x - xOffset)
+            newDoc.SetNumber(KeyStore.Y, de.y - yOffset)
+            newDoc.SetNumber(KeyStore.Width, doc.props.Document.GetNumber(KeyStore.Width, 100))
+            newDoc.SetNumber(KeyStore.Height, doc.props.Document.GetNumber(KeyStore.Height, 100))
+            this.props.addDocument(newDoc)
+        }
         if (doc.props.ContainingCollectionView && doc.props.ContainingCollectionView !== this.props.CollectionView) {
-            if (doc.props.RemoveDocument) {
+            if (!de.data["alias"] && doc.props.RemoveDocument) {
                 doc.props.RemoveDocument(doc.props.Document);
             }
-            this.props.addDocument(doc.props.Document);
+            this.props.addDocument(de.data["alias"] ? doc.props.Document.CreateAlias() : doc.props.Document);
         }
         e.stopPropagation();
     }
-- 
cgit v1.2.3-70-g09d2

