aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/CollectionViewBase.tsx
diff options
context:
space:
mode:
authorTyler Schicke <tyler_schicke@brown.edu>2019-03-18 06:40:43 -0400
committerTyler Schicke <tyler_schicke@brown.edu>2019-03-18 06:40:43 -0400
commit7859d3c9902d6d15666cce6a93a24cfba6ffdf32 (patch)
tree0ef35c3231cdcf3208ea7111fad55cb472b1f624 /src/client/views/collections/CollectionViewBase.tsx
parent5a2551c83e451823c7d3176a5dbac9adca34dea1 (diff)
parent6df4833c13921dd6d69d05fa979398356d438c71 (diff)
Merged, added delete all route, and added history to workspaces
Diffstat (limited to 'src/client/views/collections/CollectionViewBase.tsx')
-rw-r--r--src/client/views/collections/CollectionViewBase.tsx34
1 files changed, 21 insertions, 13 deletions
diff --git a/src/client/views/collections/CollectionViewBase.tsx b/src/client/views/collections/CollectionViewBase.tsx
index c3f7e4951..f3a75dad5 100644
--- a/src/client/views/collections/CollectionViewBase.tsx
+++ b/src/client/views/collections/CollectionViewBase.tsx
@@ -1,20 +1,19 @@
-import { action, runInAction, observable, computed } from "mobx";
+import { action, runInAction } from "mobx";
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, Opt } from "../../../fields/Field";
import { undoBatch } from "../../util/UndoManager";
import { DragManager } from "../../util/DragManager";
-import { DocumentView } from "../nodes/DocumentView";
import { Documents, DocumentOptions } from "../../documents/Documents";
import { Key } from "../../../fields/Key";
import { Transform } from "../../util/Transform";
import { CollectionView } from "./CollectionView";
import { RouteStore } from "../../../server/RouteStore";
import { TupleField } from "../../../fields/TupleField";
-import { DashUserModel } from "../../../server/authentication/models/user_model";
import { CurrentUserUtils } from "../../../server/authentication/models/current_user_utils";
+import { NumberField } from "../../../fields/NumberField";
export interface CollectionViewProps {
fieldKey: Key;
@@ -82,16 +81,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();
@@ -129,7 +138,6 @@ export class CollectionViewBase extends React.Component<SubCollectionViewProps>
let type = item.type
console.log(type)
if (item.kind == "file") {
- let fReader = new FileReader()
let file = item.getAsFile();
let formData = new FormData()