aboutsummaryrefslogtreecommitdiff
path: root/src/views/collections/CollectionFreeFormView.tsx
diff options
context:
space:
mode:
authorbob <bcz@cs.brown.edu>2019-02-04 10:44:30 -0500
committerbob <bcz@cs.brown.edu>2019-02-04 10:44:30 -0500
commite79e53d78546501fc855b76a84f000289ed7433a (patch)
tree80d3309086d31d95a139933be237842d3c3ee796 /src/views/collections/CollectionFreeFormView.tsx
parent6539a76c8fae1fa816bde4d9e094eb074d1a68b8 (diff)
split out common code into CollectionViewBase. organized a few other things, too.
Diffstat (limited to 'src/views/collections/CollectionFreeFormView.tsx')
-rw-r--r--src/views/collections/CollectionFreeFormView.tsx37
1 files changed, 3 insertions, 34 deletions
diff --git a/src/views/collections/CollectionFreeFormView.tsx b/src/views/collections/CollectionFreeFormView.tsx
index 403dbf503..ab2aeee64 100644
--- a/src/views/collections/CollectionFreeFormView.tsx
+++ b/src/views/collections/CollectionFreeFormView.tsx
@@ -3,20 +3,18 @@ import { Key, KeyStore } from "../../fields/Key";
import React = require("react");
import { action, observable, computed } from "mobx";
import { Document } from "../../fields/Document";
-import { DocumentView, CollectionViewProps, COLLECTION_BORDER_WIDTH } 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";
-import { SelectionManager } from "../../util/SelectionManager";
import { Documents } from "../../documents/Documents";
-import { ContextMenu } from "../ContextMenu";
import { DragManager } from "../../util/DragManager";
import "./CollectionFreeFormView.scss";
import { Utils } from "../../Utils";
-import { CollectionDockingView } from "./CollectionDockingView";
+import { CollectionViewBase, CollectionViewProps, COLLECTION_BORDER_WIDTH } from "./CollectionViewBase";
@observer
-export class CollectionFreeFormView extends React.Component<CollectionViewProps> {
+export class CollectionFreeFormView extends CollectionViewBase {
private _containerRef = React.createRef<HTMLDivElement>();
private _canvasRef = React.createRef<HTMLDivElement>();
private _nodeContainerRef = React.createRef<HTMLDivElement>();
@@ -27,16 +25,6 @@ export class CollectionFreeFormView extends React.Component<CollectionViewProps>
super(props);
}
- @computed
- public get active(): boolean {
- var isSelected = (this.props.ContainingDocumentView != undefined && 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);
- return isSelected || childSelected || topMost;
- }
-
@action
drop = (e: Event, de: DragManager.DropEvent) => {
const doc = de.data["document"];
@@ -159,25 +147,6 @@ export class CollectionFreeFormView 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>())
- 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>())
- if (value.indexOf(doc) !== -1) {
- value.splice(value.indexOf(doc), 1)
-
- SelectionManager.DeselectAll()
- ContextMenu.Instance.clearItems()
- }
- }
-
- @action
bringToFront(doc: DocumentView) {
const { fieldKey, Document: Document } = this.props;