aboutsummaryrefslogtreecommitdiff
path: root/src/views/collections
diff options
context:
space:
mode:
Diffstat (limited to 'src/views/collections')
-rw-r--r--src/views/collections/CollectionDockingView.tsx12
-rw-r--r--src/views/collections/CollectionFreeFormView.tsx37
-rw-r--r--src/views/collections/CollectionSchemaView.tsx12
3 files changed, 36 insertions, 25 deletions
diff --git a/src/views/collections/CollectionDockingView.tsx b/src/views/collections/CollectionDockingView.tsx
index 197b7df46..1a523e1bf 100644
--- a/src/views/collections/CollectionDockingView.tsx
+++ b/src/views/collections/CollectionDockingView.tsx
@@ -4,7 +4,7 @@ import React = require("react");
import FlexLayout from "flexlayout-react";
import { action, observable, computed } from "mobx";
import { Document } from "../../fields/Document";
-import { DocumentView, DocumentContentsView } from "../nodes/DocumentView";
+import { DocumentView } from "../nodes/DocumentView";
import { ListField } from "../../fields/ListField";
import { NumberField } from "../../fields/NumberField";
import { SSL_OP_SINGLE_DH_USE } from "constants";
@@ -20,7 +20,7 @@ import { CollectionViewBase, CollectionViewProps, COLLECTION_BORDER_WIDTH } from
export class CollectionDockingView extends CollectionViewBase {
private static UseGoldenLayout = true;
- public static LayoutString() { return '<CollectionDockingView DocumentForCollection={Document} CollectionFieldKey={DataKey} DocumentContentsContainingCollection={ContainingDocumentContentsView}/>'; }
+ public static LayoutString() { return CollectionViewBase.LayoutString("CollectionDockingView"); }
private _containerRef = React.createRef<HTMLDivElement>();
@computed
private get modelForFlexLayout() {
@@ -69,7 +69,7 @@ export class CollectionDockingView extends CollectionViewBase {
@action
onResize = (event: any) => {
- var cur = this.props.DocumentContentsContainingCollection!.MainContent.current;
+ var cur = this.props.DocumentContentsOfCollection!.MainContent.current;
// bcz: since GoldenLayout isn't a React component itself, we need to notify it to resize when its document container's size has changed
CollectionDockingView.myLayout.updateSize(cur!.getBoundingClientRect().width, cur!.getBoundingClientRect().height);
@@ -96,7 +96,7 @@ export class CollectionDockingView extends CollectionViewBase {
const value: Document[] = Document.GetFieldValue(fieldKey, ListField, []);
for (var i: number = 0; i < value.length; i++) {
if (value[i].Id === component) {
- return (<DocumentView key={value[i].Id} ContainingCollectionView={this} Document={value[i]} ContainingDocumentContentsView={this.props.DocumentContentsContainingCollection} />);
+ return (<DocumentView key={value[i].Id} ContainingCollectionView={this} Document={value[i]} DocumentContentsView={undefined} />);
}
}
if (component === "text") {
@@ -237,7 +237,7 @@ export class CollectionDockingView extends CollectionViewBase {
container.getElement().html("<div id='" + containingDiv + "'></div>");
setTimeout(function () {
ReactDOM.render((
- <DocumentContentsView key={state.doc.Id} Document={state.doc} ContainingCollectionView={me} ContainingDocumentContentsView={me.props.DocumentContentsContainingCollection} /> // bcz: need to fill in containingdoccontnents with value of DocumentContents when created...
+ <DocumentView key={state.doc.Id} Document={state.doc} ContainingCollectionView={me} DocumentContentsView={undefined} /> // bcz: need to fill in DocumentContentsView with value of DocumentContents when created...
),
document.getElementById(containingDiv)
);
@@ -255,7 +255,7 @@ export class CollectionDockingView extends CollectionViewBase {
const { CollectionFieldKey: fieldKey, DocumentForCollection: Document } = this.props;
const value: Document[] = Document.GetFieldValue(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.DocumentContentsContainingCollection != undefined ? this.props.DocumentContentsContainingCollection!.ScalingToScreenSpace : 1;
+ var s = this.props.DocumentContentsOfCollection != undefined ? this.props.DocumentContentsOfCollection!.ScalingToScreenSpace : 1;
var w = Document.GetFieldValue(KeyStore.Width, NumberField, Number(0)) / s;
var h = Document.GetFieldValue(KeyStore.Height, NumberField, Number(0)) / s;
diff --git a/src/views/collections/CollectionFreeFormView.tsx b/src/views/collections/CollectionFreeFormView.tsx
index d0dea7a79..c91946475 100644
--- a/src/views/collections/CollectionFreeFormView.tsx
+++ b/src/views/collections/CollectionFreeFormView.tsx
@@ -3,7 +3,7 @@ import { Key, KeyStore } from "../../fields/Key";
import React = require("react");
import { action, observable, computed } from "mobx";
import { Document } from "../../fields/Document";
-import { DocumentView } from "../nodes/DocumentView";
+import { CollectionFreeFormDocumentView } from "../nodes/CollectionFreeFormDocumentView";
import { ListField } from "../../fields/ListField";
import { NumberField } from "../../fields/NumberField";
import { SSL_OP_SINGLE_DH_USE } from "constants";
@@ -12,10 +12,11 @@ import { DragManager } from "../../util/DragManager";
import "./CollectionFreeFormView.scss";
import { Utils } from "../../Utils";
import { CollectionViewBase, CollectionViewProps, COLLECTION_BORDER_WIDTH } from "./CollectionViewBase";
+import { SelectionManager } from "../../util/SelectionManager";
@observer
export class CollectionFreeFormView extends CollectionViewBase {
- public static LayoutString() { return '<CollectionFreeFormView DocumentForCollection={Document} CollectionFieldKey={DataKey} DocumentContentsContainingCollection={ContainingDocumentContentsView}/>'; }
+ public static LayoutString() { return CollectionViewBase.LayoutString("CollectionFreeFormView"); }
private _containerRef = React.createRef<HTMLDivElement>();
private _canvasRef = React.createRef<HTMLDivElement>();
private _nodeContainerRef = React.createRef<HTMLDivElement>();
@@ -29,7 +30,8 @@ export class CollectionFreeFormView extends CollectionViewBase {
@action
drop = (e: Event, de: DragManager.DropEvent) => {
const doc = de.data["document"];
- if (doc instanceof DocumentView) {
+ var me = this;
+ if (doc instanceof CollectionFreeFormDocumentView) {
if (doc.props.ContainingCollectionView && doc.props.ContainingCollectionView !== this) {
doc.props.ContainingCollectionView.removeDocument(doc.props.Document);
this.addDocument(doc.props.Document);
@@ -37,14 +39,14 @@ export class CollectionFreeFormView extends CollectionViewBase {
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!);
- let sscale = this.props.DocumentContentsContainingCollection!.props.Document.GetFieldValue(KeyStore.Scale, NumberField, Number(1))
+ let sscale = this.props.DocumentContentsOfCollection!.props.Document.GetFieldValue(KeyStore.Scale, NumberField, Number(1))
const screenX = de.x - xOffset;
const screenY = de.y - yOffset;
const docX = (screenX - translateX) / sscale / scale;
const docY = (screenY - translateY) / sscale / scale;
doc.x = docX;
doc.y = docY;
- //this.bringToFront(doc);
+ this.bringToFront(doc);
}
e.stopPropagation();
}
@@ -59,9 +61,14 @@ export class CollectionFreeFormView extends CollectionViewBase {
}
}
+ downactive: boolean = false;
@action
onPointerDown = (e: React.PointerEvent): void => {
- if (e.button === 2 && this.active) {
+ 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);
document.addEventListener("pointermove", this.onPointerMove);
document.removeEventListener("pointerup", this.onPointerUp);
@@ -76,28 +83,32 @@ export class CollectionFreeFormView extends CollectionViewBase {
document.removeEventListener("pointermove", this.onPointerMove);
document.removeEventListener("pointerup", this.onPointerUp);
e.stopPropagation();
+ SelectionManager.DeselectAll();
}
@action
onPointerMove = (e: PointerEvent): void => {
- if (!e.cancelBubble) {
+ var me = this;
+ var act = me.active;
+ var title = me.props.DocumentForCollection.Title;
+ if (!e.cancelBubble && this.active) {
e.preventDefault();
e.stopPropagation();
- let currScale: number = this.props.DocumentContentsContainingCollection!.ScalingToScreenSpace;
+ let currScale: number = this.props.DocumentContentsOfCollection!.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);
- this._lastX = e.pageX;
- this._lastY = e.pageY;
}
+ this._lastX = e.pageX;
+ this._lastY = e.pageY;
}
@action
onPointerWheel = (e: React.WheelEvent): void => {
e.stopPropagation();
- let { LocalX, Ss, Panxx, Xx, LocalY, Panyy, Yy, ContainerX, ContainerY } = this.props.DocumentContentsContainingCollection!.TransformToLocalPoint(e.pageX, e.pageY);
+ let { LocalX, Ss, Panxx, Xx, LocalY, Panyy, Yy, ContainerX, ContainerY } = this.props.DocumentContentsOfCollection!.TransformToLocalPoint(e.pageX, e.pageY);
var deltaScale = (1 - (e.deltaY / 1000)) * Ss;
@@ -148,7 +159,7 @@ export class CollectionFreeFormView extends CollectionViewBase {
}
@action
- bringToFront(doc: DocumentView) {
+ bringToFront(doc: CollectionFreeFormDocumentView) {
const { CollectionFieldKey: fieldKey, DocumentForCollection: Document } = this.props;
const value: Document[] = Document.GetListField<Document>(fieldKey, []);
@@ -187,7 +198,7 @@ export class CollectionFreeFormView extends CollectionViewBase {
<div className="node-container" ref={this._nodeContainerRef}>
{value.map(doc => {
- return (<DocumentView key={doc.Id} ContainingCollectionView={this} Document={doc} ContainingDocumentContentsView={this.props.DocumentContentsContainingCollection} />);
+ return (<CollectionFreeFormDocumentView key={doc.Id} ContainingCollectionView={this} Document={doc} DocumentContentsView={this.props.DocumentContentsOfCollection} />);
})}
</div>
</div>
diff --git a/src/views/collections/CollectionSchemaView.tsx b/src/views/collections/CollectionSchemaView.tsx
index f625b39c5..8c79c9189 100644
--- a/src/views/collections/CollectionSchemaView.tsx
+++ b/src/views/collections/CollectionSchemaView.tsx
@@ -1,4 +1,3 @@
-import { DocumentContentsView } from "../nodes/DocumentView";
import React = require("react")
import ReactTable, { ReactTableDefaults, CellInfo, ComponentPropsGetterRC, ComponentPropsGetterR } from "react-table";
import { observer } from "mobx-react";
@@ -11,22 +10,23 @@ import SplitPane from "react-split-pane"
import "./CollectionSchemaView.scss"
import { ScrollBox } from "../../util/ScrollBox";
import { CollectionViewBase } from "./CollectionViewBase";
+import { DocumentView } from "../nodes/DocumentView";
@observer
export class CollectionSchemaView extends CollectionViewBase {
- public static LayoutString() { return '<CollectionSchemaView DocumentForCollection={Document} CollectionFieldKey={DataKey} ContainingDocumentView={ContainingDocumentContentsView}/>'; }
+ public static LayoutString() { return CollectionViewBase.LayoutString("CollectionSchemaView"); }
@observable
selectedIndex = 0;
renderCell = (rowProps: CellInfo) => {
- if (!this.props.DocumentContentsContainingCollection) {
+ if (!this.props.DocumentContentsOfCollection) {
return <div></div>
}
let props: FieldViewProps = {
doc: rowProps.value[0],
fieldKey: rowProps.value[1],
- documentViewContainer: this.props.DocumentContentsContainingCollection
+ documentViewContainer: this.props.DocumentContentsOfCollection
}
return (
<FieldView {...props} />
@@ -77,8 +77,8 @@ export class CollectionSchemaView extends CollectionViewBase {
[KS.Title, KS.Data, KS.Author])
let content;
if (this.selectedIndex != -1) {
- content = (<DocumentContentsView Document={children[this.selectedIndex]}
- ContainingDocumentContentsView={this.props.DocumentContentsContainingCollection}
+ content = (<DocumentView Document={children[this.selectedIndex]}
+ DocumentContentsView={this.props.DocumentContentsOfCollection}
ContainingCollectionView={this} />)
} else {
content = <div />