diff options
| author | bobzel <zzzman@gmail.com> | 2019-03-17 23:10:31 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-03-17 23:10:31 -0400 |
| commit | 405a47781d73a64b8e452ed5cae6e8fbd0e3cf0e (patch) | |
| tree | 0357c8a2beca18f522e9b150e5e2e5e3ad2863fc /src/client/views/collections/CollectionViewBase.tsx | |
| parent | 8433cc2b1c4d838930c3812d140678011b06e728 (diff) | |
| parent | 54371ab69c87eb6b802f83cc311e3ef7900c4d65 (diff) | |
Merge pull request #61 from browngraphicslab/view_doc_impl
view doc stuff
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(); } |
