aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/CollectionViewBase.tsx
diff options
context:
space:
mode:
authorBob Zeleznik <zzzman@gmail.com>2019-03-17 23:04:18 -0400
committerBob Zeleznik <zzzman@gmail.com>2019-03-17 23:04:18 -0400
commita6ca5db7f43ee31965169ff8d6d0aaffa86dc74e (patch)
tree39e234e20df85c7b85d3ae4928fd596a025bcf09 /src/client/views/collections/CollectionViewBase.tsx
parenta39945779d1f81444bc9639604594b03821a3be5 (diff)
tweaked drop code
Diffstat (limited to 'src/client/views/collections/CollectionViewBase.tsx')
-rw-r--r--src/client/views/collections/CollectionViewBase.tsx34
1 files changed, 15 insertions, 19 deletions
diff --git a/src/client/views/collections/CollectionViewBase.tsx b/src/client/views/collections/CollectionViewBase.tsx
index 6725fc2d1..304c44788 100644
--- a/src/client/views/collections/CollectionViewBase.tsx
+++ b/src/client/views/collections/CollectionViewBase.tsx
@@ -46,34 +46,30 @@ 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 (de.data["alias"]) {
- let newDoc = docView ? docView.props.Document.CreateAlias() : doc.CreateAlias()
- de.data["newDoc"] = newDoc
- let oldDoc = docView ? docView.props.Document : doc
+ let dropDoc: Document = de.data["document"];
+ if (de.data["alias"] && dropDoc) {
+ let oldDoc = dropDoc;
+ de.data["document"] = dropDoc = oldDoc.CreateAlias();
oldDoc.GetTAsync(KeyStore.Width, NumberField, (f: Opt<NumberField>) => {
if (f) {
- newDoc.SetNumber(KeyStore.Width, f.Data)
+ dropDoc.SetNumber(KeyStore.Width, f.Data)
}
})
oldDoc.GetTAsync(KeyStore.Height, NumberField, (f: Opt<NumberField>) => {
if (f) {
- newDoc.SetNumber(KeyStore.Height, f.Data)
+ dropDoc.SetNumber(KeyStore.Height, f.Data)
}
})
- }
-
- if (docView && docView.props.ContainingCollectionView && docView.props.ContainingCollectionView !== this.props.CollectionView) {
- if (docView.props.RemoveDocument && !de.data["alias"]) {
- docView.props.RemoveDocument(docView.props.Document)
+ } 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(de.data["alias"] ? de.data["newDoc"] : docView.props.Document)
- } else if (doc) {
- if (!de.data["alias"]) {
- this.props.removeDocument(doc)
- }
- this.props.addDocument(de.data["alias"] ? de.data["newDoc"] : doc)
+ }
+ if (dropDoc) {
+ this.props.addDocument(dropDoc);
}
e.stopPropagation();
}