diff options
author | bob <bcz@cs.brown.edu> | 2019-02-19 12:43:46 -0500 |
---|---|---|
committer | bob <bcz@cs.brown.edu> | 2019-02-19 12:43:46 -0500 |
commit | 260e0a361fefea686807d5b1cf8445ddc3f3045c (patch) | |
tree | 842f14532aee5dbf52b804b317838559296daf9e /src/client/views/Main.tsx | |
parent | 98f5f8200ad98f93f14eb97af9fdc6619dabe442 (diff) | |
parent | 39c6ba3292467979e310f3b577041c2f5e38273f (diff) |
converting main to use a DockingView
Diffstat (limited to 'src/client/views/Main.tsx')
-rw-r--r-- | src/client/views/Main.tsx | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/src/client/views/Main.tsx b/src/client/views/Main.tsx index cc4b03f57..f44ad0a74 100644 --- a/src/client/views/Main.tsx +++ b/src/client/views/Main.tsx @@ -1,4 +1,4 @@ -import { action, configure } from 'mobx'; +import { action, configure, reaction, computed } from 'mobx'; import "normalize.css"; import * as React from 'react'; import * as ReactDOM from 'react-dom'; @@ -14,17 +14,13 @@ import { Utils } from '../../Utils'; import { ServerUtils } from '../../server/ServerUtil'; import { MessageStore, DocumentTransfer } from '../../server/Message'; import { Transform } from '../util/Transform'; +import { CollectionDockingView } from './collections/CollectionDockingView'; +import { FieldWaiting } from '../../fields/Field'; configure({ enforceActions: "observed" }); - -// const mainNodeCollection = new Array<Document>(); -// let mainContainer = Documents.DockDocument(mainNodeCollection, { -// x: 0, y: 0, title: "main container" -// }) - window.addEventListener("drop", function (e) { e.preventDefault(); }, false) @@ -61,29 +57,40 @@ Documents.initProtos(() => { console.log("HELLO WORLD") console.log("RESPONSE: " + res) let mainContainer: Document; + let mainfreeform: Document; if (res) { - let obj = ServerUtils.FromJson(res) as Document - mainContainer = obj + mainContainer = ServerUtils.FromJson(res) as Document; + var mainfreeformid = mainContainer._proxies.get(KeyStore.ActiveFrame.Id)!; + Server.GetField(mainfreeformid, (field) => { + if (field) { + mainfreeform = field as Document; + } + }) + mainfreeform = mainContainer.Get(KeyStore.ActiveFrame) as Document; } else { - const docset: Document[] = []; - mainContainer = Documents.CollectionDocument(docset, { x: 0, y: 400, title: "mini collection" }, mainDocId); - let args = new DocumentTransfer(mainContainer.ToJson()) - Utils.Emit(Server.Socket, MessageStore.AddDocument, args) + mainfreeform = Documents.CollectionDocument([], { x: 0, y: 400, title: "mini collection" }); + Utils.Emit(Server.Socket, MessageStore.AddDocument, new DocumentTransfer(mainfreeform.ToJson())); + + var docs = [mainfreeform].map(doc => CollectionDockingView.makeDocumentConfig(doc)); + var config = { settings: { selectionEnabled: false }, content: [{ type: 'row', content: docs }] }; + mainContainer = Documents.DockDocument(JSON.stringify(config), { title: "main container" }, mainDocId); + Utils.Emit(Server.Socket, MessageStore.AddDocument, new DocumentTransfer(mainContainer.ToJson())) + mainContainer.Set(KeyStore.ActiveFrame, mainfreeform); } let addImageNode = action(() => { - mainContainer.GetList<Document>(KeyStore.Data, []).push(Documents.ImageDocument("https://upload.wikimedia.org/wikipedia/commons/thumb/3/3a/Cat03.jpg/1200px-Cat03.jpg", { + mainfreeform.GetList<Document>(KeyStore.Data, []).push(Documents.ImageDocument("https://upload.wikimedia.org/wikipedia/commons/thumb/3/3a/Cat03.jpg/1200px-Cat03.jpg", { x: 0, y: 300, width: 200, height: 200, title: "added note" })); }) let addTextNode = action(() => { - mainContainer.GetList<Document>(KeyStore.Data, []).push(Documents.TextDocument({ + mainfreeform.GetList<Document>(KeyStore.Data, []).push(Documents.TextDocument({ x: 0, y: 300, width: 200, height: 200, title: "added note" })); }) let addColNode = action(() => { - mainContainer.GetList<Document>(KeyStore.Data, []).push(Documents.CollectionDocument([], { + mainfreeform.GetList<Document>(KeyStore.Data, []).push(Documents.CollectionDocument([], { x: 0, y: 300, width: 200, height: 200, title: "added note" })); }) |