aboutsummaryrefslogtreecommitdiff
path: root/src/views/collections
diff options
context:
space:
mode:
authorbob <bcz@cs.brown.edu>2019-02-05 17:41:12 -0500
committerbob <bcz@cs.brown.edu>2019-02-05 17:41:12 -0500
commit26af9562cc515627be4be8759b70ebfbab8bb83c (patch)
treef2148b4ca0aee6eecc063a9d3f65c910b404ad51 /src/views/collections
parent6e66f8b227c730e07863a93a8bce5ee0d51d2ddc (diff)
first changes
Diffstat (limited to 'src/views/collections')
-rw-r--r--src/views/collections/CollectionDockingView.tsx7
-rw-r--r--src/views/collections/CollectionFreeFormView.tsx35
-rw-r--r--src/views/collections/CollectionViewBase.tsx9
3 files changed, 32 insertions, 19 deletions
diff --git a/src/views/collections/CollectionDockingView.tsx b/src/views/collections/CollectionDockingView.tsx
index 92b5e563c..51e2cfbbc 100644
--- a/src/views/collections/CollectionDockingView.tsx
+++ b/src/views/collections/CollectionDockingView.tsx
@@ -15,6 +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";
@observer
export class CollectionDockingView extends CollectionViewBase {
@@ -69,6 +70,8 @@ export class CollectionDockingView extends CollectionViewBase {
@action
onResize = (event: any) => {
+ if (this.props.ContainingDocumentView == WAITING)
+ return;
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
@@ -217,7 +220,7 @@ export class CollectionDockingView extends CollectionViewBase {
CollectionDockingView.myLayout._maximizedStack = stack;
CollectionDockingView.myLayout._maxstack = stack.header.controlsContainer.find('.lm_maximise');
}
- stack.header.controlsContainer.find('.lm_popout').hide();
+ //stack.header.controlsContainer.find('.lm_popout').hide();
stack.header.controlsContainer.find('.lm_close') //get the close icon
.off('click') //unbind the current click handler
.click(function () {
@@ -252,6 +255,8 @@ export class CollectionDockingView extends CollectionViewBase {
render() {
+ if (this.props.ContainingDocumentView == WAITING)
+ return;
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.
diff --git a/src/views/collections/CollectionFreeFormView.tsx b/src/views/collections/CollectionFreeFormView.tsx
index cc907b2cc..2c10c8056 100644
--- a/src/views/collections/CollectionFreeFormView.tsx
+++ b/src/views/collections/CollectionFreeFormView.tsx
@@ -13,6 +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";
@observer
export class CollectionFreeFormView extends CollectionViewBase {
@@ -32,21 +33,23 @@ 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) {
+ if (doc.props.ContainingCollectionView && doc.props.ContainingCollectionView !== this && doc.props.ContainingCollectionView != WAITING) {
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!);
- 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;
- const docY = (screenY - translateY) / sscale / scale;
- doc.x = docX;
- doc.y = docY;
- this.bringToFront(doc);
+ if (this.props.ContainingDocumentView != WAITING) {
+ 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;
+ const docY = (screenY - translateY) / sscale / scale;
+ doc.x = docX;
+ doc.y = docY;
+ this.bringToFront(doc);
+ }
}
e.stopPropagation();
}
@@ -91,7 +94,7 @@ export class CollectionFreeFormView extends CollectionViewBase {
var me = this;
var act = me.active;
var title = me.props.DocumentForCollection.Title;
- if (!e.cancelBubble && this.active) {
+ if (!e.cancelBubble && this.active && this.props.ContainingDocumentView != WAITING) {
e.preventDefault();
e.stopPropagation();
let currScale: number = this.props.ContainingDocumentView!.ScalingToScreenSpace;
@@ -108,6 +111,8 @@ export class CollectionFreeFormView extends CollectionViewBase {
onPointerWheel = (e: React.WheelEvent): void => {
e.stopPropagation();
+ if (this.props.ContainingDocumentView == WAITING)
+ return;
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;
@@ -142,11 +147,13 @@ export class CollectionFreeFormView extends CollectionViewBase {
x: x, y: y
})
let docs = that.props.DocumentForCollection.GetFieldT(KeyStore.Data, ListField);
- if (!docs) {
- docs = new ListField<Document>();
- that.props.DocumentForCollection.SetField(KeyStore.Data, docs)
+ if (docs != WAITING) {
+ if (!docs) {
+ docs = new ListField<Document>();
+ that.props.DocumentForCollection.SetField(KeyStore.Data, docs)
+ }
+ docs.Data.push(doc);
}
- docs.Data.push(doc);
}
}), false)
diff --git a/src/views/collections/CollectionViewBase.tsx b/src/views/collections/CollectionViewBase.tsx
index 76145f12b..e00a29978 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 } from "../../fields/Field";
+import { Opt, WAITING } from "../../fields/Field";
import { Key, KeyStore } from "../../fields/Key";
import { ListField } from "../../fields/ListField";
import { SelectionManager } from "../../util/SelectionManager";
@@ -30,9 +30,10 @@ export class CollectionViewBase extends React.Component<CollectionViewProps> {
public get active(): boolean {
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 ||
- this.props.ContainingDocumentView.props.ContainingCollectionView instanceof CollectionDockingView);
+ var topMost = this.props.ContainingDocumentView != undefined &&
+ this.props.ContainingDocumentView != WAITING && this.props.ContainingDocumentView.props.ContainingCollectionView != WAITING && (
+ this.props.ContainingDocumentView.props.ContainingCollectionView == undefined ||
+ this.props.ContainingDocumentView.props.ContainingCollectionView instanceof CollectionDockingView);
return isSelected || childSelected || topMost;
}
@action