diff options
-rw-r--r-- | src/client/views/collections/CollectionViewBase.tsx | 29 | ||||
-rw-r--r-- | src/client/views/nodes/DocumentView.tsx | 3 |
2 files changed, 15 insertions, 17 deletions
diff --git a/src/client/views/collections/CollectionViewBase.tsx b/src/client/views/collections/CollectionViewBase.tsx index 37ec203b5..3a6d1c141 100644 --- a/src/client/views/collections/CollectionViewBase.tsx +++ b/src/client/views/collections/CollectionViewBase.tsx @@ -46,27 +46,26 @@ export class CollectionViewBase extends React.Component<SubCollectionViewProps> @undoBatch @action protected drop(e: Event, de: DragManager.DropEvent) { - let dropDoc: Document = de.data["document"]; - if (de.data["alias"] && dropDoc) { - let oldDoc = dropDoc; - de.data["document"] = dropDoc = oldDoc.CreateAlias(); + let docToAlias = de.data["documentToAlias"]; + let docView = de.data["documentView"]; + let doc = docToAlias ? docToAlias.CreateAlias() : de.data["document"]; + if (docToAlias) { [KeyStore.Width, KeyStore.Height].map(key => - oldDoc.GetTAsync(key, NumberField, (f: Opt<NumberField>) => { + docToAlias.GetTAsync(key, NumberField, (f: Opt<NumberField>) => { if (f) { - dropDoc.SetNumber(key, f.Data) + doc.SetNumber(key, f.Data) } }) ); - } else { - const docView: DocumentView = de.data["documentView"]; - if (docView && docView.props.RemoveDocument && docView.props.ContainingCollectionView !== this.props.CollectionView) { - docView.props.RemoveDocument(dropDoc); - } else if (dropDoc) { - this.props.removeDocument(dropDoc); + this.props.addDocument(doc); + } else if (docView) { + if (doc && docView.props.RemoveDocument && docView.props.ContainingCollectionView !== this.props.CollectionView) { + docView.props.RemoveDocument(doc); + this.props.addDocument(doc); } - } - if (dropDoc) { - this.props.addDocument(dropDoc); + } else if (doc) { + // this.props.removeDocument(doc); bcz: causes an exception + this.props.addDocument(doc); } e.stopPropagation(); } diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx index 981cabe71..5d2f6293d 100644 --- a/src/client/views/nodes/DocumentView.tsx +++ b/src/client/views/nodes/DocumentView.tsx @@ -165,10 +165,9 @@ export class DocumentView extends React.Component<DocumentViewProps> { const [left, top] = this.props.ScreenToLocalTransform().inverse().transformPoint(0, 0); let dragData: { [id: string]: any } = {}; dragData["documentView"] = this; - dragData["document"] = this.props.Document; + dragData[dropAliasOfDraggedDoc ? "documentToAlias" : "document"] = this.props.Document; dragData["xOffset"] = x - left; dragData["yOffset"] = y - top; - dragData["alias"] = dropAliasOfDraggedDoc; DragManager.StartDrag(this._mainCont.current, dragData, { handlers: { dragComplete: action(() => { }), |