diff options
| author | Monika Hedman <monika_hedman@brown.edu> | 2019-03-09 19:06:39 -0500 |
|---|---|---|
| committer | Monika Hedman <monika_hedman@brown.edu> | 2019-03-09 19:06:39 -0500 |
| commit | 1183f65cea62078cfa1df615da20b72f5b60433e (patch) | |
| tree | d86c1547579739f751023b1c0d2b3fcca0e1801d /src/client/views/collections/CollectionViewBase.tsx | |
| parent | 46948b5eee468f45f2ff67b1915a97950eb495a1 (diff) | |
image uploading
Diffstat (limited to 'src/client/views/collections/CollectionViewBase.tsx')
| -rw-r--r-- | src/client/views/collections/CollectionViewBase.tsx | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/src/client/views/collections/CollectionViewBase.tsx b/src/client/views/collections/CollectionViewBase.tsx index 47c9e0986..661cec8ae 100644 --- a/src/client/views/collections/CollectionViewBase.tsx +++ b/src/client/views/collections/CollectionViewBase.tsx @@ -1,4 +1,4 @@ -import { action } from "mobx"; +import { action, runInAction } from "mobx"; import { Document } from "../../../fields/Document"; import { ListField } from "../../../fields/ListField"; import React = require("react"); @@ -62,7 +62,6 @@ export class CollectionViewBase extends React.Component<SubCollectionViewProps> @action protected onDrop(e: React.DragEvent, options: DocumentOptions): void { - console.log("DRRRRROOOOPPPPPP"); e.stopPropagation() e.preventDefault() let that = this; @@ -112,6 +111,31 @@ export class CollectionViewBase extends React.Component<SubCollectionViewProps> method: 'POST', body: formData }) + .then((res: Response) => { + return res.json() + }).then(json => { + + json.map((file: any) => { + console.log(file) + console.log(typeof file) + let path = window.location.origin + file + console.log(path) + runInAction(() => { + var img = Documents.ImageDocument(path, { ...options, nativeWidth: 300, width: 300, }) + let docs = that.props.Document.GetT(KeyStore.Data, ListField); + if (docs != FieldWaiting) { + if (!docs) { + docs = new ListField<Document>(); + that.props.Document.Set(KeyStore.Data, docs) + } + docs.Data.push(img); + + } + }) + + + }) + }) // fReader.addEventListener("load", action("drop", () => { // if (fReader.result) { // let form = request.post(upload).form(); |
