aboutsummaryrefslogtreecommitdiff
path: root/src/views
diff options
context:
space:
mode:
authorbob <bcz@cs.brown.edu>2019-02-06 16:11:42 -0500
committerbob <bcz@cs.brown.edu>2019-02-06 16:11:42 -0500
commit59d5992f2a101eff7743328c3fdefe6a0006ada9 (patch)
treeb28dbb2e06f1fffeafcd2b43845072f9f3f6f1fc /src/views
parent7598b88bbad9690c59f8b164144aa0d02a0a211f (diff)
parent84eea14a86265ce0585342d9f3a3c4107c02df17 (diff)
woring db stub.
Diffstat (limited to 'src/views')
-rw-r--r--src/views/collections/CollectionDockingView.tsx20
-rw-r--r--src/views/collections/CollectionFreeFormView.tsx63
-rw-r--r--src/views/collections/CollectionSchemaView.tsx5
-rw-r--r--src/views/collections/CollectionViewBase.tsx8
-rw-r--r--src/views/nodes/CollectionFreeFormDocumentView.tsx25
-rw-r--r--src/views/nodes/DocumentView.tsx46
-rw-r--r--src/views/nodes/FieldView.tsx6
-rw-r--r--src/views/nodes/FormattedTextBox.tsx22
-rw-r--r--src/views/nodes/ImageBox.tsx8
9 files changed, 96 insertions, 107 deletions
diff --git a/src/views/collections/CollectionDockingView.tsx b/src/views/collections/CollectionDockingView.tsx
index 4bbbeeecd..e489e319a 100644
--- a/src/views/collections/CollectionDockingView.tsx
+++ b/src/views/collections/CollectionDockingView.tsx
@@ -15,7 +15,7 @@ import * as GoldenLayout from "golden-layout";
import * as ReactDOM from 'react-dom';
import { DragManager } from "../../util/DragManager";
import { CollectionViewBase, CollectionViewProps, COLLECTION_BORDER_WIDTH } from "./CollectionViewBase";
-import { WAITING } from "../../fields/Field";
+import { FieldWaiting } from "../../fields/Field";
@observer
export class CollectionDockingView extends CollectionViewBase {
@@ -26,7 +26,7 @@ export class CollectionDockingView extends CollectionViewBase {
@computed
private get modelForFlexLayout() {
const { CollectionFieldKey: fieldKey, DocumentForCollection: Document } = this.props;
- const value: Document[] = Document.GetFieldValue(fieldKey, ListField, []);
+ const value: Document[] = Document.GetData(fieldKey, ListField, []);
var docs = value.map(doc => {
return { type: 'tabset', weight: 50, selected: 0, children: [{ type: "tab", name: doc.Title, component: doc.Id }] };
});
@@ -42,7 +42,7 @@ export class CollectionDockingView extends CollectionViewBase {
@computed
private get modelForGoldenLayout(): any {
const { CollectionFieldKey: fieldKey, DocumentForCollection: Document } = this.props;
- const value: Document[] = Document.GetFieldValue(fieldKey, ListField, []);
+ const value: Document[] = Document.GetData(fieldKey, ListField, []);
var docs = value.map(doc => {
return { type: 'component', componentName: 'documentViewComponent', componentState: { doc: doc } };
});
@@ -70,7 +70,7 @@ export class CollectionDockingView extends CollectionViewBase {
@action
onResize = (event: any) => {
- if (this.props.ContainingDocumentView == WAITING)
+ if (this.props.ContainingDocumentView == FieldWaiting)
return;
var cur = this.props.ContainingDocumentView!.MainContent.current;
@@ -96,10 +96,9 @@ export class CollectionDockingView extends CollectionViewBase {
return <button>{node.getName()}</button>;
}
const { CollectionFieldKey: fieldKey, DocumentForCollection: Document } = this.props;
- const value: Document[] = Document.GetFieldValue(fieldKey, ListField, []);
+ const value: Document[] = Document.GetData(fieldKey, ListField, []);
for (var i: number = 0; i < value.length; i++) {
if (value[i].Id === component) {
- var data = value[i].GetField(KeyStore.Data);
return (<DocumentView key={value[i].Id} ContainingCollectionView={this} Document={value[i]} DocumentView={undefined} />);
}
}
@@ -240,7 +239,6 @@ export class CollectionDockingView extends CollectionViewBase {
var containingDiv = "component_" + me.nextId();
container.getElement().html("<div id='" + containingDiv + "'></div>");
setTimeout(function () {
- var data = state.doc.GetField(KeyStore.Data);
ReactDOM.render((
<DocumentView key={state.doc.Id} Document={state.doc} ContainingCollectionView={me} DocumentView={undefined} />
),
@@ -257,14 +255,14 @@ export class CollectionDockingView extends CollectionViewBase {
render() {
- if (this.props.ContainingDocumentView == WAITING)
+ if (this.props.ContainingDocumentView == FieldWaiting)
return;
const { CollectionFieldKey: fieldKey, DocumentForCollection: Document } = this.props;
- const value: Document[] = Document.GetFieldValue(fieldKey, ListField, []);
+ const value: Document[] = Document.GetData(fieldKey, ListField, []);
// bcz: not sure why, but I need these to force the flexlayout to update when the collection size changes.
var s = this.props.ContainingDocumentView != undefined ? this.props.ContainingDocumentView!.ScalingToScreenSpace : 1;
- var w = Document.GetFieldValue(KeyStore.Width, NumberField, Number(0)) / s;
- var h = Document.GetFieldValue(KeyStore.Height, NumberField, Number(0)) / s;
+ var w = Document.GetData(KeyStore.Width, NumberField, Number(0)) / s;
+ var h = Document.GetData(KeyStore.Height, NumberField, Number(0)) / s;
var chooseLayout = () => {
if (!CollectionDockingView.UseGoldenLayout)
diff --git a/src/views/collections/CollectionFreeFormView.tsx b/src/views/collections/CollectionFreeFormView.tsx
index d48d096ce..45d37ca4f 100644
--- a/src/views/collections/CollectionFreeFormView.tsx
+++ b/src/views/collections/CollectionFreeFormView.tsx
@@ -13,7 +13,7 @@ import "./CollectionFreeFormView.scss";
import { Utils } from "../../Utils";
import { CollectionViewBase, CollectionViewProps, COLLECTION_BORDER_WIDTH } from "./CollectionViewBase";
import { SelectionManager } from "../../util/SelectionManager";
-import { WAITING } from "../../fields/Field";
+import { FieldWaiting } from "../../fields/Field";
@observer
export class CollectionFreeFormView extends CollectionViewBase {
@@ -33,15 +33,15 @@ export class CollectionFreeFormView extends CollectionViewBase {
const doc = de.data["document"];
var me = this;
if (doc instanceof CollectionFreeFormDocumentView) {
- if (doc.props.ContainingCollectionView && doc.props.ContainingCollectionView !== this && doc.props.ContainingCollectionView != WAITING) {
+ if (doc.props.ContainingCollectionView && doc.props.ContainingCollectionView !== this && doc.props.ContainingCollectionView != FieldWaiting) {
doc.props.ContainingCollectionView.removeDocument(doc.props.Document);
this.addDocument(doc.props.Document);
}
const xOffset = de.data["xOffset"] as number || 0;
const yOffset = de.data["yOffset"] as number || 0;
const { scale, translateX, translateY } = Utils.GetScreenTransform(this._canvasRef.current!);
- if (this.props.ContainingDocumentView != WAITING) {
- let sscale = this.props.ContainingDocumentView!.props.Document.GetFieldValue(KeyStore.Scale, NumberField, Number(1))
+ if (this.props.ContainingDocumentView != FieldWaiting) {
+ let sscale = this.props.ContainingDocumentView!.props.Document.GetData(KeyStore.Scale, NumberField, Number(1))
const screenX = de.x - xOffset;
const screenY = de.y - yOffset;
const docX = (screenX - translateX) / sscale / scale;
@@ -64,12 +64,8 @@ export class CollectionFreeFormView extends CollectionViewBase {
}
}
- downactive: boolean = false;
@action
onPointerDown = (e: React.PointerEvent): void => {
- var me = this;
- me.downactive = this.active;
- var title = this.props.DocumentForCollection.Title;
if ((e.button === 2 && this.active) ||
!e.defaultPrevented) {
document.removeEventListener("pointermove", this.onPointerMove);
@@ -92,16 +88,14 @@ export class CollectionFreeFormView extends CollectionViewBase {
@action
onPointerMove = (e: PointerEvent): void => {
var me = this;
- var act = me.active;
- var title = me.props.DocumentForCollection.Title;
- if (!e.cancelBubble && this.active && this.props.ContainingDocumentView != WAITING) {
+ if (!e.cancelBubble && this.active && this.props.ContainingDocumentView != FieldWaiting) {
e.preventDefault();
e.stopPropagation();
let currScale: number = this.props.ContainingDocumentView!.ScalingToScreenSpace;
- let x = this.props.DocumentForCollection.GetFieldValue(KeyStore.PanX, NumberField, Number(0));
- let y = this.props.DocumentForCollection.GetFieldValue(KeyStore.PanY, NumberField, Number(0));
- this.props.DocumentForCollection.SetFieldValue(KeyStore.PanX, x + (e.pageX - this._lastX) / currScale, NumberField);
- this.props.DocumentForCollection.SetFieldValue(KeyStore.PanY, y + (e.pageY - this._lastY) / currScale, NumberField);
+ let x = this.props.DocumentForCollection.GetData(KeyStore.PanX, NumberField, Number(0));
+ let y = this.props.DocumentForCollection.GetData(KeyStore.PanY, NumberField, Number(0));
+ this.props.DocumentForCollection.SetData(KeyStore.PanX, x + (e.pageX - this._lastX) / currScale, NumberField);
+ this.props.DocumentForCollection.SetData(KeyStore.PanY, y + (e.pageY - this._lastY) / currScale, NumberField);
}
this._lastX = e.pageX;
this._lastY = e.pageY;
@@ -111,7 +105,7 @@ export class CollectionFreeFormView extends CollectionViewBase {
onPointerWheel = (e: React.WheelEvent): void => {
e.stopPropagation();
- if (this.props.ContainingDocumentView == WAITING)
+ if (this.props.ContainingDocumentView == FieldWaiting)
return;
let { LocalX, Ss, Panxx, Xx, LocalY, Panyy, Yy, ContainerX, ContainerY } = this.props.ContainingDocumentView!.TransformToLocalPoint(e.pageX, e.pageY);
@@ -123,9 +117,9 @@ export class CollectionFreeFormView extends CollectionViewBase {
let dx = ContainerX - newContainerX;
let dy = ContainerY - newContainerY;
- this.props.DocumentForCollection.SetField(KeyStore.Scale, new NumberField(deltaScale));
- this.props.DocumentForCollection.SetFieldValue(KeyStore.PanX, Panxx + dx, NumberField);
- this.props.DocumentForCollection.SetFieldValue(KeyStore.PanY, Panyy + dy, NumberField);
+ this.props.DocumentForCollection.Set(KeyStore.Scale, new NumberField(deltaScale));
+ this.props.DocumentForCollection.SetData(KeyStore.PanX, Panxx + dx, NumberField);
+ this.props.DocumentForCollection.SetData(KeyStore.PanY, Panyy + dy, NumberField);
}
@action
@@ -135,8 +129,8 @@ export class CollectionFreeFormView extends CollectionViewBase {
let fReader = new FileReader()
let file = e.dataTransfer.items[0].getAsFile();
let that = this;
- const panx: number = this.props.DocumentForCollection.GetFieldValue(KeyStore.PanX, NumberField, Number(0));
- const pany: number = this.props.DocumentForCollection.GetFieldValue(KeyStore.PanY, NumberField, Number(0));
+ const panx: number = this.props.DocumentForCollection.GetData(KeyStore.PanX, NumberField, Number(0));
+ const pany: number = this.props.DocumentForCollection.GetData(KeyStore.PanY, NumberField, Number(0));
let x = e.pageX - panx
let y = e.pageY - pany
@@ -146,11 +140,11 @@ export class CollectionFreeFormView extends CollectionViewBase {
let doc = Documents.ImageDocument(url, {
x: x, y: y
})
- let docs = that.props.DocumentForCollection.GetFieldT(KeyStore.Data, ListField);
- if (docs != WAITING) {
+ let docs = that.props.DocumentForCollection.GetT(KeyStore.Data, ListField);
+ if (docs != FieldWaiting) {
if (!docs) {
docs = new ListField<Document>();
- that.props.DocumentForCollection.SetField(KeyStore.Data, docs)
+ that.props.DocumentForCollection.Set(KeyStore.Data, docs)
}
docs.Data.push(doc);
}
@@ -169,27 +163,26 @@ export class CollectionFreeFormView extends CollectionViewBase {
bringToFront(doc: CollectionFreeFormDocumentView) {
const { CollectionFieldKey: fieldKey, DocumentForCollection: Document } = this.props;
- const value: Document[] = Document.GetListField<Document>(fieldKey, []);
- var topmost = value.reduce((topmost, d) => Math.max(d.GetNumberField(KeyStore.ZIndex, 0), topmost), -1000);
+ const value: Document[] = Document.GetList<Document>(fieldKey, []);
+ var topmost = value.reduce((topmost, d) => Math.max(d.GetNumber(KeyStore.ZIndex, 0), topmost), -1000);
value.map(d => {
- var zind = d.GetNumberField(KeyStore.ZIndex, 0);
+ var zind = d.GetNumber(KeyStore.ZIndex, 0);
if (zind != topmost - 1 - (topmost - zind) && d != doc.props.Document) {
- d.SetFieldValue(KeyStore.ZIndex, topmost - 1 - (topmost - zind), NumberField);
+ d.SetData(KeyStore.ZIndex, topmost - 1 - (topmost - zind), NumberField);
}
})
- if (doc.props.Document.GetNumberField(KeyStore.ZIndex, 0) != 0) {
- doc.props.Document.SetFieldValue(KeyStore.ZIndex, 0, NumberField);
+ if (doc.props.Document.GetNumber(KeyStore.ZIndex, 0) != 0) {
+ doc.props.Document.SetData(KeyStore.ZIndex, 0, NumberField);
}
}
render() {
const { CollectionFieldKey: fieldKey, DocumentForCollection: Document } = this.props;
- const value: Document[] = Document.GetListField<Document>(fieldKey, []);
- const panx: number = Document.GetNumberField(KeyStore.PanX, 0);
- const pany: number = Document.GetNumberField(KeyStore.PanY, 0);
- const currScale: number = Document.GetNumberField(KeyStore.Scale, 1);
- const data = Document.GetField(KeyStore.Data);
+ const value: Document[] = Document.GetList<Document>(fieldKey, []);
+ const panx: number = Document.GetNumber(KeyStore.PanX, 0);
+ const pany: number = Document.GetNumber(KeyStore.PanY, 0);
+ const currScale: number = Document.GetNumber(KeyStore.Scale, 1);
return (
<div className="border" style={{
diff --git a/src/views/collections/CollectionSchemaView.tsx b/src/views/collections/CollectionSchemaView.tsx
index 59d54e8c4..8817cb496 100644
--- a/src/views/collections/CollectionSchemaView.tsx
+++ b/src/views/collections/CollectionSchemaView.tsx
@@ -69,12 +69,11 @@ export class CollectionSchemaView extends CollectionViewBase {
render() {
const { DocumentForCollection: Document, CollectionFieldKey: fieldKey } = this.props;
- const children = Document.GetListField<Document>(fieldKey, []);
- const columns = Document.GetListField(KS.ColumnsKey,
+ const children = Document.GetList<Document>(fieldKey, []);
+ const columns = Document.GetList(KS.ColumnsKey,
[KS.Title, KS.Data, KS.Author])
let content;
if (this.selectedIndex != -1) {
- var data = this.props.DocumentForCollection.GetField(KS.Data);
content = (<DocumentView Document={children[this.selectedIndex]} DocumentView={undefined} ContainingCollectionView={this} />)
} else {
content = <div />
diff --git a/src/views/collections/CollectionViewBase.tsx b/src/views/collections/CollectionViewBase.tsx
index e00a29978..4fce02ef6 100644
--- a/src/views/collections/CollectionViewBase.tsx
+++ b/src/views/collections/CollectionViewBase.tsx
@@ -1,7 +1,7 @@
import { action, computed } from "mobx";
import { observer } from "mobx-react";
import { Document } from "../../fields/Document";
-import { Opt, WAITING } from "../../fields/Field";
+import { Opt, FieldWaiting } from "../../fields/Field";
import { Key, KeyStore } from "../../fields/Key";
import { ListField } from "../../fields/ListField";
import { SelectionManager } from "../../util/SelectionManager";
@@ -31,7 +31,7 @@ export class CollectionViewBase extends React.Component<CollectionViewProps> {
var isSelected = (this.props.ContainingDocumentView instanceof CollectionFreeFormDocumentView && SelectionManager.IsSelected(this.props.ContainingDocumentView));
var childSelected = SelectionManager.SelectedDocuments().some(view => view.props.ContainingCollectionView == this);
var topMost = this.props.ContainingDocumentView != undefined &&
- this.props.ContainingDocumentView != WAITING && this.props.ContainingDocumentView.props.ContainingCollectionView != WAITING && (
+ this.props.ContainingDocumentView != FieldWaiting && this.props.ContainingDocumentView.props.ContainingCollectionView != FieldWaiting && (
this.props.ContainingDocumentView.props.ContainingCollectionView == undefined ||
this.props.ContainingDocumentView.props.ContainingCollectionView instanceof CollectionDockingView);
return isSelected || childSelected || topMost;
@@ -39,14 +39,14 @@ export class CollectionViewBase extends React.Component<CollectionViewProps> {
@action
addDocument = (doc: Document): void => {
//TODO This won't create the field if it doesn't already exist
- const value = this.props.DocumentForCollection.GetFieldValue(this.props.CollectionFieldKey, ListField, new Array<Document>())
+ const value = this.props.DocumentForCollection.GetData(this.props.CollectionFieldKey, ListField, new Array<Document>())
value.push(doc);
}
@action
removeDocument = (doc: Document): void => {
//TODO This won't create the field if it doesn't already exist
- const value = this.props.DocumentForCollection.GetFieldValue(this.props.CollectionFieldKey, ListField, new Array<Document>())
+ const value = this.props.DocumentForCollection.GetData(this.props.CollectionFieldKey, ListField, new Array<Document>())
if (value.indexOf(doc) !== -1) {
value.splice(value.indexOf(doc), 1)
diff --git a/src/views/nodes/CollectionFreeFormDocumentView.tsx b/src/views/nodes/CollectionFreeFormDocumentView.tsx
index d98c8dcb7..25d67d96a 100644
--- a/src/views/nodes/CollectionFreeFormDocumentView.tsx
+++ b/src/views/nodes/CollectionFreeFormDocumentView.tsx
@@ -10,8 +10,7 @@ import { ContextMenu } from "../ContextMenu";
import "./NodeView.scss";
import React = require("react");
import { DocumentView, DocumentViewProps } from "./DocumentView";
-import { WAITING } from "../../fields/Field";
-import { ImageField } from '../../fields/ImageField';
+import { FieldWaiting } from "../../fields/Field";
@observer
@@ -32,20 +31,20 @@ export class CollectionFreeFormDocumentView extends DocumentView {
@computed
get x(): number {
- return this.props.Document.GetFieldValue(KeyStore.X, NumberField, Number(0));
+ return this.props.Document.GetData(KeyStore.X, NumberField, Number(0));
}
@computed
get y(): number {
- return this.props.Document.GetFieldValue(KeyStore.Y, NumberField, Number(0));
+ return this.props.Document.GetData(KeyStore.Y, NumberField, Number(0));
}
set x(x: number) {
- this.props.Document.SetFieldValue(KeyStore.X, x, NumberField)
+ this.props.Document.SetData(KeyStore.X, x, NumberField)
}
set y(y: number) {
- this.props.Document.SetFieldValue(KeyStore.Y, y, NumberField)
+ this.props.Document.SetData(KeyStore.Y, y, NumberField)
}
@computed
@@ -55,29 +54,29 @@ export class CollectionFreeFormDocumentView extends DocumentView {
@computed
get width(): number {
- return this.props.Document.GetFieldValue(KeyStore.Width, NumberField, Number(0));
+ return this.props.Document.GetData(KeyStore.Width, NumberField, Number(0));
}
set width(w: number) {
- this.props.Document.SetFieldValue(KeyStore.Width, w, NumberField)
+ this.props.Document.SetData(KeyStore.Width, w, NumberField)
}
@computed
get height(): number {
- return this.props.Document.GetFieldValue(KeyStore.Height, NumberField, Number(0));
+ return this.props.Document.GetData(KeyStore.Height, NumberField, Number(0));
}
set height(h: number) {
- this.props.Document.SetFieldValue(KeyStore.Height, h, NumberField)
+ this.props.Document.SetData(KeyStore.Height, h, NumberField)
}
@computed
get zIndex(): number {
- return this.props.Document.GetFieldValue(KeyStore.ZIndex, NumberField, Number(0));
+ return this.props.Document.GetData(KeyStore.ZIndex, NumberField, Number(0));
}
set zIndex(h: number) {
- this.props.Document.SetFieldValue(KeyStore.ZIndex, h, NumberField)
+ this.props.Document.SetData(KeyStore.ZIndex, h, NumberField)
}
@action
@@ -87,7 +86,7 @@ export class CollectionFreeFormDocumentView extends DocumentView {
@computed
get active(): boolean {
return SelectionManager.IsSelected(this) || this.props.ContainingCollectionView === undefined ||
- (this.props.ContainingCollectionView != WAITING && this.props.ContainingCollectionView!.active);
+ (this.props.ContainingCollectionView != FieldWaiting && this.props.ContainingCollectionView!.active);
}
@computed
diff --git a/src/views/nodes/DocumentView.tsx b/src/views/nodes/DocumentView.tsx
index cfd894a38..81353cd60 100644
--- a/src/views/nodes/DocumentView.tsx
+++ b/src/views/nodes/DocumentView.tsx
@@ -1,7 +1,7 @@
import { action, computed } from "mobx";
import { observer } from "mobx-react";
import { Document } from "../../fields/Document";
-import { Opt, WAITING } from "../../fields/Field";
+import { Opt, FieldWaiting } from "../../fields/Field";
import { Key, KeyStore } from "../../fields/Key";
import { ListField } from "../../fields/ListField";
import { NumberField } from "../../fields/NumberField";
@@ -31,17 +31,17 @@ export class DocumentView extends React.Component<DocumentViewProps> {
}
@computed
get layout(): string {
- return this.props.Document.GetFieldValue(KeyStore.Layout, TextField, String("<p>Error loading layout data</p>"));
+ return this.props.Document.GetData(KeyStore.Layout, TextField, String("<p>Error loading layout data</p>"));
}
@computed
get layoutKeys(): Key[] {
- return this.props.Document.GetFieldValue(KeyStore.LayoutKeys, ListField, new Array<Key>());
+ return this.props.Document.GetData(KeyStore.LayoutKeys, ListField, new Array<Key>());
}
@computed
get layoutFields(): Key[] {
- return this.props.Document.GetFieldValue(KeyStore.LayoutFields, ListField, new Array<Key>());
+ return this.props.Document.GetData(KeyStore.LayoutFields, ListField, new Array<Key>());
}
//
@@ -49,9 +49,9 @@ export class DocumentView extends React.Component<DocumentViewProps> {
//
@computed
public get ScalingToScreenSpace(): number {
- if (this.props.ContainingCollectionView != undefined && this.props.ContainingCollectionView != WAITING &&
- this.props.ContainingCollectionView.props.ContainingDocumentView != undefined && this.props.ContainingCollectionView.props.ContainingDocumentView != WAITING) {
- let ss = this.props.ContainingCollectionView.props.DocumentForCollection.GetFieldValue(KeyStore.Scale, NumberField, Number(1));
+ if (this.props.ContainingCollectionView != undefined && this.props.ContainingCollectionView != FieldWaiting &&
+ this.props.ContainingCollectionView.props.ContainingDocumentView != undefined && this.props.ContainingCollectionView.props.ContainingDocumentView != FieldWaiting) {
+ let ss = this.props.ContainingCollectionView.props.DocumentForCollection.GetData(KeyStore.Scale, NumberField, Number(1));
return this.props.ContainingCollectionView.props.ContainingDocumentView.ScalingToScreenSpace * ss;
}
return 1;
@@ -63,15 +63,15 @@ export class DocumentView extends React.Component<DocumentViewProps> {
public TransformToLocalPoint(screenX: number, screenY: number) {
// if this collection view is nested within another collection view, then
// first transform the screen point into the parent collection's coordinate space.
- let { LocalX: parentX, LocalY: parentY } = this.props.ContainingCollectionView != undefined && this.props.ContainingCollectionView != WAITING &&
- this.props.ContainingCollectionView.props.ContainingDocumentView != undefined && this.props.ContainingCollectionView.props.ContainingDocumentView != WAITING ?
+ let { LocalX: parentX, LocalY: parentY } = this.props.ContainingCollectionView != undefined && this.props.ContainingCollectionView != FieldWaiting &&
+ this.props.ContainingCollectionView.props.ContainingDocumentView != undefined && this.props.ContainingCollectionView.props.ContainingDocumentView != FieldWaiting ?
this.props.ContainingCollectionView.props.ContainingDocumentView.TransformToLocalPoint(screenX, screenY) :
{ LocalX: screenX, LocalY: screenY };
let ContainerX: number = parentX - COLLECTION_BORDER_WIDTH;
let ContainerY: number = parentY - COLLECTION_BORDER_WIDTH;
- var Xx = this.props.Document.GetFieldValue(KeyStore.X, NumberField, Number(0));
- var Yy = this.props.Document.GetFieldValue(KeyStore.Y, NumberField, Number(0));
+ var Xx = this.props.Document.GetData(KeyStore.X, NumberField, Number(0));
+ var Yy = this.props.Document.GetData(KeyStore.Y, NumberField, Number(0));
// CollectionDockingViews change the location of their children frames without using a Dash transformation.
// They also ignore any transformation that may have been applied to their content document.
// NOTE: this currently assumes CollectionDockingViews aren't nested.
@@ -81,9 +81,9 @@ export class DocumentView extends React.Component<DocumentViewProps> {
Yy = ry - COLLECTION_BORDER_WIDTH;
}
- let Ss = this.props.Document.GetFieldValue(KeyStore.Scale, NumberField, Number(1));
- let Panxx = this.props.Document.GetFieldValue(KeyStore.PanX, NumberField, Number(0));
- let Panyy = this.props.Document.GetFieldValue(KeyStore.PanY, NumberField, Number(0));
+ let Ss = this.props.Document.GetData(KeyStore.Scale, NumberField, Number(1));
+ let Panxx = this.props.Document.GetData(KeyStore.PanX, NumberField, Number(0));
+ let Panyy = this.props.Document.GetData(KeyStore.PanY, NumberField, Number(0));
let LocalX = (ContainerX - (Xx + Panxx)) / Ss;
let LocalY = (ContainerY - (Yy + Panyy)) / Ss;
@@ -95,8 +95,8 @@ export class DocumentView extends React.Component<DocumentViewProps> {
//
public TransformToScreenPoint(localX: number, localY: number, Ss: number = 1, Panxx: number = 0, Panyy: number = 0): { ScreenX: number, ScreenY: number } {
- var Xx = this.props.Document.GetFieldValue(KeyStore.X, NumberField, Number(0));
- var Yy = this.props.Document.GetFieldValue(KeyStore.Y, NumberField, Number(0));
+ var Xx = this.props.Document.GetData(KeyStore.X, NumberField, Number(0));
+ var Yy = this.props.Document.GetData(KeyStore.Y, NumberField, Number(0));
// CollectionDockingViews change the location of their children frames without using a Dash transformation.
// They also ignore any transformation that may have been applied to their content document.
// NOTE: this currently assumes CollectionDockingViews aren't nested.
@@ -113,11 +113,11 @@ export class DocumentView extends React.Component<DocumentViewProps> {
// if this collection view is nested within another collection view, then
// first transform the local point into the parent collection's coordinate space.
- let containingDocView = this.props.ContainingCollectionView != undefined && this.props.ContainingCollectionView != WAITING ? this.props.ContainingCollectionView.props.ContainingDocumentView : undefined;
- if (containingDocView != undefined && containingDocView != WAITING) {
- let ss = containingDocView.props.Document.GetFieldValue(KeyStore.Scale, NumberField, Number(1));
- let panxx = containingDocView.props.Document.GetFieldValue(KeyStore.PanX, NumberField, Number(0)) + COLLECTION_BORDER_WIDTH * ss;
- let panyy = containingDocView.props.Document.GetFieldValue(KeyStore.PanY, NumberField, Number(0)) + COLLECTION_BORDER_WIDTH * ss;
+ let containingDocView = this.props.ContainingCollectionView != undefined && this.props.ContainingCollectionView != FieldWaiting ? this.props.ContainingCollectionView.props.ContainingDocumentView : undefined;
+ if (containingDocView != undefined && containingDocView != FieldWaiting) {
+ let ss = containingDocView.props.Document.GetData(KeyStore.Scale, NumberField, Number(1));
+ let panxx = containingDocView.props.Document.GetData(KeyStore.PanX, NumberField, Number(0)) + COLLECTION_BORDER_WIDTH * ss;
+ let panyy = containingDocView.props.Document.GetData(KeyStore.PanY, NumberField, Number(0)) + COLLECTION_BORDER_WIDTH * ss;
let { ScreenX, ScreenY } = containingDocView.TransformToScreenPoint(parentX, parentY, ss, panxx, panyy);
parentX = ScreenX;
parentY = ScreenY;
@@ -132,8 +132,8 @@ export class DocumentView extends React.Component<DocumentViewProps> {
bindings[key.Name + "Key"] = key; // this maps string values of the form <keyname>Key to an actual key Kestore.keyname e.g, "DataKey" => KeyStore.Data
}
for (const key of this.layoutFields) {
- let field = this.props.Document.GetField(key);
- bindings[key.Name] = field && field != WAITING ? field.GetValue() : field;
+ let field = this.props.Document.Get(key);
+ bindings[key.Name] = field && field != FieldWaiting ? field.GetValue() : field;
}
if (bindings.DocumentView === undefined) {
bindings.DocumentView = this; // set the DocumentView to this if it hasn't already been set by a sub-class during its render method.
diff --git a/src/views/nodes/FieldView.tsx b/src/views/nodes/FieldView.tsx
index 7c81ac55e..05a7b91b9 100644
--- a/src/views/nodes/FieldView.tsx
+++ b/src/views/nodes/FieldView.tsx
@@ -2,7 +2,7 @@ import React = require("react")
import { Document } from "../../fields/Document";
import { observer } from "mobx-react";
import { computed } from "mobx";
-import { Field, Opt, WAITING } from "../../fields/Field";
+import { Field, Opt, FieldWaiting } from "../../fields/Field";
import { TextField } from "../../fields/TextField";
import { NumberField } from "../../fields/NumberField";
import { RichTextField } from "../../fields/RichTextField";
@@ -29,7 +29,7 @@ export class FieldView extends React.Component<FieldViewProps> {
@computed
get field(): Opt<Field> {
const { doc, fieldKey } = this.props;
- return doc.GetField(fieldKey);
+ return doc.Get(fieldKey);
}
render() {
const field = this.field;
@@ -47,7 +47,7 @@ export class FieldView extends React.Component<FieldViewProps> {
}
else if (field instanceof NumberField) {
return <p>{field.Data}</p>
- } else if (field != WAITING) {
+ } else if (field != FieldWaiting) {
return <p>{field.GetValue}</p>
} else
return <p> {"Waiting for server..."} </p>
diff --git a/src/views/nodes/FormattedTextBox.tsx b/src/views/nodes/FormattedTextBox.tsx
index cf6a1181a..3e3e22e46 100644
--- a/src/views/nodes/FormattedTextBox.tsx
+++ b/src/views/nodes/FormattedTextBox.tsx
@@ -6,7 +6,7 @@ import { keymap } from "prosemirror-keymap";
import { schema } from "prosemirror-schema-basic";
import { EditorState, Transaction } from "prosemirror-state";
import { EditorView } from "prosemirror-view";
-import { Opt, WAITING } from "../../fields/Field";
+import { Opt, FieldWaiting } from "../../fields/Field";
import { SelectionManager } from "../../util/SelectionManager";
import "./FormattedTextBox.scss";
import React = require("react")
@@ -48,11 +48,11 @@ export class FormattedTextBox extends React.Component<FieldViewProps> {
}
dispatchTransaction = (tx: Transaction) => {
- if (this._editorView && this._editorView != WAITING) {
+ if (this._editorView && this._editorView != FieldWaiting) {
const state = this._editorView.state.apply(tx);
this._editorView.updateState(state);
const { doc, fieldKey } = this.props;
- doc.SetFieldValue(fieldKey, JSON.stringify(state.toJSON()), RichTextField);
+ doc.SetData(fieldKey, JSON.stringify(state.toJSON()), RichTextField);
}
}
@@ -68,8 +68,8 @@ export class FormattedTextBox extends React.Component<FieldViewProps> {
]
};
- let field = doc.GetFieldT(fieldKey, RichTextField);
- if (field && field != WAITING) { // bcz: don't think this works
+ let field = doc.GetT(fieldKey, RichTextField);
+ if (field && field != FieldWaiting) { // bcz: don't think this works
state = EditorState.fromJSON(config, JSON.parse(field.Data));
} else {
state = EditorState.create(config);
@@ -82,20 +82,20 @@ export class FormattedTextBox extends React.Component<FieldViewProps> {
}
this._reactionDisposer = reaction(() => {
- const field = this.props.doc.GetFieldT(this.props.fieldKey, RichTextField);
- return field && field != WAITING ? field.Data : undefined;
+ const field = this.props.doc.GetT(this.props.fieldKey, RichTextField);
+ return field && field != FieldWaiting ? field.Data : undefined;
}, (field) => {
- if (field && this._editorView && this._editorView != WAITING) {
+ if (field && this._editorView && this._editorView != FieldWaiting) {
this._editorView.updateState(EditorState.fromJSON(config, JSON.parse(field)));
}
})
}
componentWillUnmount() {
- if (this._editorView && this._editorView != WAITING) {
+ if (this._editorView && this._editorView != FieldWaiting) {
this._editorView.destroy();
}
- if (this._reactionDisposer && this._reactionDisposer != WAITING) {
+ if (this._reactionDisposer && this._reactionDisposer != FieldWaiting) {
this._reactionDisposer();
}
}
@@ -107,7 +107,7 @@ export class FormattedTextBox extends React.Component<FieldViewProps> {
@action
onChange(e: React.ChangeEvent<HTMLInputElement>) {
const { fieldKey, doc } = this.props;
- doc.SetFieldValue(fieldKey, e.target.value, RichTextField);
+ doc.SetData(fieldKey, e.target.value, RichTextField);
}
onPointerDown = (e: React.PointerEvent): void => {
let me = this;
diff --git a/src/views/nodes/ImageBox.tsx b/src/views/nodes/ImageBox.tsx
index 079cca8ab..123c76d19 100644
--- a/src/views/nodes/ImageBox.tsx
+++ b/src/views/nodes/ImageBox.tsx
@@ -7,7 +7,7 @@ import React = require("react")
import { ImageField } from '../../fields/ImageField';
import { FieldViewProps, FieldView } from './FieldView';
import { CollectionFreeFormDocumentView } from './CollectionFreeFormDocumentView';
-import { WAITING } from '../../fields/Field';
+import { FieldWaiting } from '../../fields/Field';
import { observer } from "mobx-react"
import { observable, action } from 'mobx';
@@ -79,9 +79,9 @@ export class ImageBox extends React.Component<FieldViewProps> {
}
render() {
- let field = this.props.doc.GetFieldT(this.props.fieldKey, ImageField);
- let path = field == WAITING ? "https://image.flaticon.com/icons/svg/66/66163.svg" :
- field instanceof ImageField ? field.Data.href : "";
+ let field = this.props.doc.Get(this.props.fieldKey);
+ let path = field == FieldWaiting ? "https://image.flaticon.com/icons/svg/66/66163.svg" :
+ field instanceof ImageField ? field.Data.href : "http://www.cs.brown.edu/~bcz/face.gif";
return (
<div className="imageBox-cont" onPointerDown={this.onPointerDown} ref={this._ref} >