diff options
| author | Bob Zeleznik <zzzman@gmail.com> | 2019-03-17 23:11:02 -0400 |
|---|---|---|
| committer | Bob Zeleznik <zzzman@gmail.com> | 2019-03-17 23:11:02 -0400 |
| commit | deb800519c2bf060d1d39056120305de2d30a4bb (patch) | |
| tree | 8d9cc83a807b99637302d75c87e9224094146fc4 /src/client/views/collections/CollectionViewBase.tsx | |
| parent | 196c991ac857c8df4ddc5458c58c2f69169d5768 (diff) | |
| parent | 405a47781d73a64b8e452ed5cae6e8fbd0e3cf0e (diff) | |
Merge branch 'master' into schema_columns
Diffstat (limited to 'src/client/views/collections/CollectionViewBase.tsx')
| -rw-r--r-- | src/client/views/collections/CollectionViewBase.tsx | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/src/client/views/collections/CollectionViewBase.tsx b/src/client/views/collections/CollectionViewBase.tsx index d9598aa72..37ec203b5 100644 --- a/src/client/views/collections/CollectionViewBase.tsx +++ b/src/client/views/collections/CollectionViewBase.tsx @@ -3,7 +3,7 @@ import { Document } from "../../../fields/Document"; import { ListField } from "../../../fields/ListField"; import React = require("react"); import { KeyStore } from "../../../fields/KeyStore"; -import { FieldWaiting } from "../../../fields/Field"; +import { FieldWaiting, Field, Opt } from "../../../fields/Field"; import { undoBatch } from "../../util/UndoManager"; import { DragManager } from "../../util/DragManager"; import { DocumentView } from "../nodes/DocumentView"; @@ -11,6 +11,7 @@ import { Documents, DocumentOptions } from "../../documents/Documents"; import { Key } from "../../../fields/Key"; import { Transform } from "../../util/Transform"; import { CollectionView } from "./CollectionView"; +import { NumberField } from "../../../fields/NumberField"; export interface CollectionViewProps { fieldKey: Key; @@ -45,17 +46,27 @@ export class CollectionViewBase extends React.Component<SubCollectionViewProps> @undoBatch @action protected drop(e: Event, de: DragManager.DropEvent) { - const docView: DocumentView = de.data["documentView"]; - const doc: Document = de.data["document"]; - - if (docView && (!docView.props.ContainingCollectionView || docView.props.ContainingCollectionView !== this.props.CollectionView)) { - if (docView.props.RemoveDocument) { - docView.props.RemoveDocument(docView.props.Document); + let dropDoc: Document = de.data["document"]; + if (de.data["alias"] && dropDoc) { + let oldDoc = dropDoc; + de.data["document"] = dropDoc = oldDoc.CreateAlias(); + [KeyStore.Width, KeyStore.Height].map(key => + oldDoc.GetTAsync(key, NumberField, (f: Opt<NumberField>) => { + if (f) { + dropDoc.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(docView.props.Document); - } else if (doc) { - this.props.removeDocument(doc); - this.props.addDocument(doc); + } + if (dropDoc) { + this.props.addDocument(dropDoc); } e.stopPropagation(); } |
