aboutsummaryrefslogtreecommitdiff
path: root/src/views/collections
diff options
context:
space:
mode:
authorbob <bcz@cs.brown.edu>2019-02-05 12:18:52 -0500
committerbob <bcz@cs.brown.edu>2019-02-05 12:18:52 -0500
commit7740c0010944cfa215c9b21b113f030199ffab82 (patch)
treeae9f5b0cbb0826c5e75d3a98862ed2d96f4802f1 /src/views/collections
parentea9f41a84a307343593245e6de0c721704dc60fa (diff)
naming changes
Diffstat (limited to 'src/views/collections')
-rw-r--r--src/views/collections/CollectionDockingView.tsx4
-rw-r--r--src/views/collections/CollectionFreeFormView.tsx8
-rw-r--r--src/views/collections/CollectionSchemaView.tsx4
-rw-r--r--src/views/collections/CollectionViewBase.tsx14
4 files changed, 16 insertions, 14 deletions
diff --git a/src/views/collections/CollectionDockingView.tsx b/src/views/collections/CollectionDockingView.tsx
index 2e8d5a514..92b5e563c 100644
--- a/src/views/collections/CollectionDockingView.tsx
+++ b/src/views/collections/CollectionDockingView.tsx
@@ -69,7 +69,7 @@ export class CollectionDockingView extends CollectionViewBase {
@action
onResize = (event: any) => {
- var cur = this.props.DocumentViewForCollection!.MainContent.current;
+ var cur = this.props.ContainingDocumentView!.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);
@@ -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.DocumentViewForCollection != undefined ? this.props.DocumentViewForCollection!.ScalingToScreenSpace : 1;
+ 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;
diff --git a/src/views/collections/CollectionFreeFormView.tsx b/src/views/collections/CollectionFreeFormView.tsx
index abc811642..cc907b2cc 100644
--- a/src/views/collections/CollectionFreeFormView.tsx
+++ b/src/views/collections/CollectionFreeFormView.tsx
@@ -39,7 +39,7 @@ 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.DocumentViewForCollection!.props.Document.GetFieldValue(KeyStore.Scale, NumberField, Number(1))
+ let sscale = this.props.ContainingDocumentView!.props.Document.GetFieldValue(KeyStore.Scale, NumberField, Number(1))
const screenX = de.x - xOffset;
const screenY = de.y - yOffset;
const docX = (screenX - translateX) / sscale / scale;
@@ -94,7 +94,7 @@ export class CollectionFreeFormView extends CollectionViewBase {
if (!e.cancelBubble && this.active) {
e.preventDefault();
e.stopPropagation();
- let currScale: number = this.props.DocumentViewForCollection!.ScalingToScreenSpace;
+ 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);
@@ -108,7 +108,7 @@ export class CollectionFreeFormView extends CollectionViewBase {
onPointerWheel = (e: React.WheelEvent): void => {
e.stopPropagation();
- let { LocalX, Ss, Panxx, Xx, LocalY, Panyy, Yy, ContainerX, ContainerY } = this.props.DocumentViewForCollection!.TransformToLocalPoint(e.pageX, e.pageY);
+ let { LocalX, Ss, Panxx, Xx, LocalY, Panyy, Yy, ContainerX, ContainerY } = this.props.ContainingDocumentView!.TransformToLocalPoint(e.pageX, e.pageY);
var deltaScale = (1 - (e.deltaY / 1000)) * Ss;
@@ -198,7 +198,7 @@ export class CollectionFreeFormView extends CollectionViewBase {
<div className="node-container" ref={this._nodeContainerRef}>
{value.map(doc => {
- return (<CollectionFreeFormDocumentView key={doc.Id} ContainingCollectionView={this} Document={doc} DocumentView={this.props.DocumentViewForCollection} />);
+ return (<CollectionFreeFormDocumentView key={doc.Id} ContainingCollectionView={this} Document={doc} DocumentView={undefined} />);
})}
</div>
</div>
diff --git a/src/views/collections/CollectionSchemaView.tsx b/src/views/collections/CollectionSchemaView.tsx
index 19b1434ef..8503aaf1e 100644
--- a/src/views/collections/CollectionSchemaView.tsx
+++ b/src/views/collections/CollectionSchemaView.tsx
@@ -74,9 +74,7 @@ export class CollectionSchemaView extends CollectionViewBase {
[KS.Title, KS.Data, KS.Author])
let content;
if (this.selectedIndex != -1) {
- content = (<DocumentView Document={children[this.selectedIndex]}
- DocumentView={undefined}
- ContainingCollectionView={this} />)
+ 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 bfded71d9..76145f12b 100644
--- a/src/views/collections/CollectionViewBase.tsx
+++ b/src/views/collections/CollectionViewBase.tsx
@@ -9,11 +9,12 @@ import { ContextMenu } from "../ContextMenu";
import React = require("react");
import { DocumentView } from "../nodes/DocumentView";
import { CollectionDockingView } from "./CollectionDockingView";
+import { CollectionFreeFormDocumentView } from "../nodes/CollectionFreeFormDocumentView";
export interface CollectionViewProps {
- fieldKey: Key;
- Document: Document;
+ CollectionFieldKey: Key;
+ DocumentForCollection: Document;
ContainingDocumentView: Opt<DocumentView>;
}
@@ -22,9 +23,12 @@ export const COLLECTION_BORDER_WIDTH = 2;
@observer
export class CollectionViewBase extends React.Component<CollectionViewProps> {
+ public static LayoutString(collectionType: string) {
+ return `<${collectionType} DocumentForCollection={Document} CollectionFieldKey={DataKey} ContainingDocumentView={DocumentView}/>`;
+ }
@computed
public get active(): boolean {
- var isSelected = (this.props.ContainingDocumentView != undefined && SelectionManager.IsSelected(this.props.ContainingDocumentView));
+ 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.props.ContainingCollectionView == undefined ||
@@ -34,14 +38,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.Document.GetFieldValue(this.props.fieldKey, ListField, new Array<Document>())
+ const value = this.props.DocumentForCollection.GetFieldValue(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.Document.GetFieldValue(this.props.fieldKey, ListField, new Array<Document>())
+ const value = this.props.DocumentForCollection.GetFieldValue(this.props.CollectionFieldKey, ListField, new Array<Document>())
if (value.indexOf(doc) !== -1) {
value.splice(value.indexOf(doc), 1)