aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections
diff options
context:
space:
mode:
authorTyler Schicke <tyler_schicke@brown.edu>2019-03-18 03:42:06 -0400
committerTyler Schicke <tyler_schicke@brown.edu>2019-03-18 03:42:06 -0400
commit1a81b9f6255b2b2941e21da3662b9c5e71209989 (patch)
tree2d0bbc5d258c59148bf56533ef32723af8c8eb5f /src/client/views/collections
parenta300c4e5040e975cdcd7367a1345335d52ff6aad (diff)
parent6d5236bf6440157ad4d489acd1420554b77be577 (diff)
Merge branch 'master' of github-tsch-brown:browngraphicslab/Dash-Web into server_dev
Diffstat (limited to 'src/client/views/collections')
-rw-r--r--src/client/views/collections/CollectionFreeFormView.tsx9
-rw-r--r--src/client/views/collections/CollectionSchemaView.tsx10
-rw-r--r--src/client/views/collections/CollectionView.tsx2
-rw-r--r--src/client/views/collections/CollectionViewBase.tsx29
4 files changed, 30 insertions, 20 deletions
diff --git a/src/client/views/collections/CollectionFreeFormView.tsx b/src/client/views/collections/CollectionFreeFormView.tsx
index cca57912c..808a22a5d 100644
--- a/src/client/views/collections/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/CollectionFreeFormView.tsx
@@ -76,12 +76,11 @@ export class CollectionFreeFormView extends CollectionViewBase {
@action
drop = (e: Event, de: DragManager.DropEvent) => {
super.drop(e, de);
- const docView: DocumentView = de.data["documentView"];
- let doc: Document = docView ? docView.props.Document : de.data["document"];
+ let screenX = de.x - (de.data["xOffset"] as number || 0);
+ let screenY = de.y - (de.data["yOffset"] as number || 0);
+ const [x, y] = this.getTransform().transformPoint(screenX, screenY);
+ let doc: Document = de.data["document"];
if (doc) {
- let screenX = de.x - (de.data["xOffset"] as number || 0);
- let screenY = de.y - (de.data["yOffset"] as number || 0);
- const [x, y] = this.getTransform().transformPoint(screenX, screenY);
doc.SetNumber(KeyStore.X, x);
doc.SetNumber(KeyStore.Y, y);
this.bringToFront(doc);
diff --git a/src/client/views/collections/CollectionSchemaView.tsx b/src/client/views/collections/CollectionSchemaView.tsx
index 8c1aeef2c..f88a62a0f 100644
--- a/src/client/views/collections/CollectionSchemaView.tsx
+++ b/src/client/views/collections/CollectionSchemaView.tsx
@@ -153,11 +153,11 @@ export class CollectionSchemaView extends CollectionViewBase {
// e.preventDefault();
// } else
{
- if (e.buttons === 1) {
- if (this.props.isSelected()) {
- e.stopPropagation();
- }
- }
+ // if (e.buttons === 1) {
+ // if (this.props.isSelected()) {
+ // e.stopPropagation();
+ // }
+ // }
}
}
diff --git a/src/client/views/collections/CollectionView.tsx b/src/client/views/collections/CollectionView.tsx
index d9b2722a6..40acf466e 100644
--- a/src/client/views/collections/CollectionView.tsx
+++ b/src/client/views/collections/CollectionView.tsx
@@ -55,7 +55,7 @@ export class CollectionView extends React.Component<CollectionViewProps> {
const value = props.Document.GetData(props.fieldKey, ListField, new Array<Document>())
value.push(doc);
} else {
- props.Document.SetData(props.fieldKey, [doc], ListField);
+ props.Document.SetOnPrototype(props.fieldKey, new ListField([doc]));
}
}
diff --git a/src/client/views/collections/CollectionViewBase.tsx b/src/client/views/collections/CollectionViewBase.tsx
index d9598aa72..fd0e84fb1 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,16 +46,26 @@ 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 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 =>
+ docToAlias.GetTAsync(key, NumberField, (f: Opt<NumberField>) => {
+ if (f) {
+ doc.SetNumber(key, f.Data)
+ }
+ })
+ );
+ this.props.addDocument(doc);
+ } else if (docView) {
+ if (doc && docView.props.RemoveDocument && docView.props.ContainingCollectionView !== this.props.CollectionView) {
+ docView.props.RemoveDocument(doc);
+ this.props.removeDocument(doc); // bcz: not good -- want to check if it's there and then add if it isn't
+ this.props.addDocument(doc);
}
- this.props.addDocument(docView.props.Document);
} else if (doc) {
- this.props.removeDocument(doc);
+ this.props.removeDocument(doc); // bcz: not good -- want to check if it's there and then add if it isn't
this.props.addDocument(doc);
}
e.stopPropagation();