aboutsummaryrefslogtreecommitdiff
path: root/src/views/nodes
diff options
context:
space:
mode:
Diffstat (limited to 'src/views/nodes')
-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
5 files changed, 53 insertions, 54 deletions
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} >