aboutsummaryrefslogtreecommitdiff
path: root/src/views/collections
diff options
context:
space:
mode:
Diffstat (limited to 'src/views/collections')
-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
4 files changed, 43 insertions, 53 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)