From 4737b47badd10d4209eaf4164ee119f5fd4083ca Mon Sep 17 00:00:00 2001
From: Tyler Schicke <tyler_schicke@brown.edu>
Date: Tue, 29 Jan 2019 17:21:56 -0500
Subject: added some functions to document

---
 src/views/nodes/DocumentView.tsx | 62 ++++++++++++++++++++--------------------
 1 file changed, 31 insertions(+), 31 deletions(-)

(limited to 'src/views/nodes/DocumentView.tsx')

diff --git a/src/views/nodes/DocumentView.tsx b/src/views/nodes/DocumentView.tsx
index 19feefa70..be072a458 100644
--- a/src/views/nodes/DocumentView.tsx
+++ b/src/views/nodes/DocumentView.tsx
@@ -1,20 +1,20 @@
-import {observer} from "mobx-react";
+import { observer } from "mobx-react";
 import React = require("react");
-import {computed, observable, action} from "mobx";
-import {KeyStore, Key} from "../../fields/Key";
-import {NumberField} from "../../fields/NumberField";
-import {TextField} from "../../fields/TextField";
-import {DocumentViewModel} from "../../viewmodels/DocumentViewModel";
-import {ListField} from "../../fields/ListField";
-import {FieldTextBox} from "../nodes/FieldTextBox"
-import {Document} from "../../fields/Document";
-import {CollectionFreeFormView} from "../freeformcanvas/CollectionFreeFormView"
+import { computed, observable, action } from "mobx";
+import { KeyStore, Key } from "../../fields/Key";
+import { NumberField } from "../../fields/NumberField";
+import { TextField } from "../../fields/TextField";
+import { DocumentViewModel } from "../../viewmodels/DocumentViewModel";
+import { ListField } from "../../fields/ListField";
+import { FieldTextBox } from "../nodes/FieldTextBox"
+import { Document } from "../../fields/Document";
+import { CollectionFreeFormView } from "../freeformcanvas/CollectionFreeFormView"
 import "./NodeView.scss"
-import {SelectionManager} from "../../util/SelectionManager";
-import {DocumentDecorations} from "../../DocumentDecorations";
-import {ContextMenu} from "../ContextMenu";
-import {Opt} from "../../fields/Field";
-import {DragManager} from "../../util/DragManager";
+import { SelectionManager } from "../../util/SelectionManager";
+import { DocumentDecorations } from "../../DocumentDecorations";
+import { ContextMenu } from "../ContextMenu";
+import { Opt } from "../../fields/Field";
+import { DragManager } from "../../util/DragManager";
 const JsxParser = require('react-jsx-parser').default;//TODO Why does this need to be imported like this?
 
 interface IProps {
@@ -42,22 +42,22 @@ class DocumentContents extends React.Component<IProps> {
     }
     render() {
         let doc = this.props.Document;
-        let bindings = {...this.props} as any;
+        let bindings = { ...this.props } as any;
         for (const key of this.layoutKeys) {
-            bindings[ key.Name + "Key" ] = key;
+            bindings[key.Name + "Key"] = key;
         }
         for (const key of this.layoutFields) {
             let field = doc.GetField(key);
             if (field) {
-                bindings[ key.Name ] = field.GetValue();
+                bindings[key.Name] = field.GetValue();
             }
         }
         return <JsxParser
-            components={{FieldTextBox, CollectionFreeFormView}}
+            components={{ FieldTextBox, CollectionFreeFormView }}
             bindings={bindings}
             jsx={this.layout}
             showWarnings={true}
-            onError={(test: any) => {console.log(test)}}
+            onError={(test: any) => { console.log(test) }}
         />
 
 
@@ -153,7 +153,7 @@ export class DocumentView extends React.Component<IProps> {
         // if this collection view is nested within another collection view, then 
         // first transform the screen point into the parent collection's coordinate space.
         if (this.props.ContainingDocumentView != undefined) {
-            let {LocalX, LocalY} = this.props.ContainingDocumentView!.TransformToLocalPoint(screenX, screenY);
+            let { LocalX, LocalY } = this.props.ContainingDocumentView!.TransformToLocalPoint(screenX, screenY);
             ContainerX = LocalX - CollectionFreeFormView.BORDER_WIDTH;
             ContainerY = LocalY - CollectionFreeFormView.BORDER_WIDTH;
         }
@@ -167,13 +167,13 @@ export class DocumentView extends React.Component<IProps> {
         let LocalX = (ContainerX - (Xx + Panxx) - W / 2) / Ss + W / 2;
         let LocalY = (ContainerY - (Yy + Panyy)) / Ss;
 
-        return {LocalX, Ss, W, Panxx, Xx, LocalY, Panyy, Yy, ContainerX, ContainerY};
+        return { LocalX, Ss, W, Panxx, Xx, LocalY, Panyy, Yy, ContainerX, ContainerY };
     }
 
     //
     // Converts a point in the coordinate space of a document to a screen space coordinate.
     //
-    public TransformToScreenPoint(localX: number, localY: number, Ss: number = 1, Panxx: number = 0, Panyy: number = 0): {ScreenX: number, ScreenY: number} {
+    public TransformToScreenPoint(localX: number, localY: number, Ss: number = 1, Panxx: number = 0, Panyy: number = 0): { ScreenX: number, ScreenY: number } {
 
         let W = this.props.Document.GetFieldValue(KeyStore.Width, NumberField, Number(0));
         let H = CollectionFreeFormView.BORDER_WIDTH;
@@ -189,11 +189,11 @@ export class DocumentView extends React.Component<IProps> {
             let ss = containingDocView.props.Document.GetFieldValue(KeyStore.Scale, NumberField, Number(1));
             let panxx = containingDocView.props.Document.GetFieldValue(KeyStore.PanX, NumberField, Number(0)) + CollectionFreeFormView.BORDER_WIDTH * ss;
             let panyy = containingDocView.props.Document.GetFieldValue(KeyStore.PanY, NumberField, Number(0)) + CollectionFreeFormView.BORDER_WIDTH * ss;
-            let {ScreenX, ScreenY} = containingDocView.TransformToScreenPoint(parentX, parentY, ss, panxx, panyy);
+            let { ScreenX, ScreenY } = containingDocView.TransformToScreenPoint(parentX, parentY, ss, panxx, panyy);
             parentX = ScreenX;
             parentY = ScreenY;
         }
-        return {ScreenX: parentX, ScreenY: parentY};
+        return { ScreenX: parentX, ScreenY: parentY };
     }
 
     onPointerDown = (e: React.PointerEvent): void => {
@@ -202,7 +202,7 @@ export class DocumentView extends React.Component<IProps> {
         this._contextMenuCanOpen = e.button == 2;
         if (this.active) {
             e.stopPropagation();
-            e.preventDefault();
+            // e.preventDefault();
             document.removeEventListener("pointermove", this.onPointerMove)
             document.addEventListener("pointermove", this.onPointerMove);
             document.removeEventListener("pointerup", this.onPointerUp)
@@ -215,10 +215,10 @@ export class DocumentView extends React.Component<IProps> {
             if (this._mainCont.current != null && this.props.ContainingCollectionView != null) {
                 this._contextMenuCanOpen = false;
                 const rect = this.screenRect;
-                let dragData: {[ id: string ]: any} = {};
-                dragData[ "document" ] = this;
-                dragData[ "xOffset" ] = e.x - rect.left;
-                dragData[ "yOffset" ] = e.y - rect.top;
+                let dragData: { [id: string]: any } = {};
+                dragData["document"] = this;
+                dragData["xOffset"] = e.x - rect.left;
+                dragData["yOffset"] = e.y - rect.top;
                 DragManager.StartDrag(this._mainCont.current, dragData, {
                     handlers: {
                         dragComplete: this.dragComplete,
@@ -266,7 +266,7 @@ export class DocumentView extends React.Component<IProps> {
             e.stopPropagation();
 
             ContextMenu.Instance.clearItems();
-            ContextMenu.Instance.addItem({description: "Delete", event: this.deleteClicked})
+            ContextMenu.Instance.addItem({ description: "Delete", event: this.deleteClicked })
             ContextMenu.Instance.displayMenu(e.pageX, e.pageY)
             SelectionManager.SelectDoc(this, e.ctrlKey);
         }
-- 
cgit v1.2.3-70-g09d2

