aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/CollectionViewBase.tsx
diff options
context:
space:
mode:
authorTyler Schicke <tyler_schicke@brown.edu>2019-02-19 06:21:26 -0500
committerTyler Schicke <tyler_schicke@brown.edu>2019-02-19 06:21:26 -0500
commitb305a084cd43afe24d84221a1b4e55c252f5af8a (patch)
treed8c5ee1651fb0a1104d9636860c9417e5e306fa2 /src/client/views/collections/CollectionViewBase.tsx
parentf9d55f59c9db0f9ea7e98729f9e0892a828ee3f6 (diff)
parentec2b0b56058fce137ff28ae3ec125f9e695f315c (diff)
Merge branch 'master' of github-tsch-brown:browngraphicslab/Dash-Web into server_database_merge
Diffstat (limited to 'src/client/views/collections/CollectionViewBase.tsx')
-rw-r--r--src/client/views/collections/CollectionViewBase.tsx41
1 files changed, 30 insertions, 11 deletions
diff --git a/src/client/views/collections/CollectionViewBase.tsx b/src/client/views/collections/CollectionViewBase.tsx
index 4fcbb1699..0a90bd0f2 100644
--- a/src/client/views/collections/CollectionViewBase.tsx
+++ b/src/client/views/collections/CollectionViewBase.tsx
@@ -10,39 +10,58 @@ import React = require("react");
import { DocumentView } from "../nodes/DocumentView";
import { CollectionDockingView } from "./CollectionDockingView";
import { CollectionFreeFormDocumentView } from "../nodes/CollectionFreeFormDocumentView";
-import { FieldViewProps } from "../nodes/FieldView";
+import { Transform } from "../../util/Transform";
+
+
+export interface CollectionViewProps {
+ fieldKey: Key;
+ Document: Document;
+ ContainingDocumentView: Opt<DocumentView>;
+ ScreenToLocalTransform: () => Transform;
+ isSelected: () => boolean;
+ isTopMost: boolean;
+ select: (ctrlPressed: boolean) => void;
+ BackgroundView?: () => JSX.Element;
+}
export const COLLECTION_BORDER_WIDTH = 2;
@observer
-export class CollectionViewBase extends React.Component<FieldViewProps> {
+export class CollectionViewBase extends React.Component<CollectionViewProps> {
+ public static LayoutString(collectionType: string, fieldKey: string = "DataKey") {
+ return `<${collectionType} Document={Document}
+ ScreenToLocalTransform={ScreenToLocalTransform} fieldKey={${fieldKey}} isSelected={isSelected} select={select}
+ isTopMost={isTopMost}
+ ContainingDocumentView={DocumentView} BackgroundView={BackgroundView} />`;
+ }
@computed
public get active(): boolean {
- var isSelected = (this.props.DocumentViewForField instanceof CollectionFreeFormDocumentView && SelectionManager.IsSelected(this.props.DocumentViewForField));
+ var isSelected = (this.props.ContainingDocumentView && SelectionManager.IsSelected(this.props.ContainingDocumentView));
var childSelected = SelectionManager.SelectedDocuments().some(view => view.props.ContainingCollectionView == this);
- var topMost = this.props.DocumentViewForField != undefined && (
- this.props.DocumentViewForField.props.ContainingCollectionView == undefined ||
- this.props.DocumentViewForField.props.ContainingCollectionView instanceof CollectionDockingView);
+ var topMost = this.props.isTopMost;
return isSelected || childSelected || topMost;
}
@action
addDocument = (doc: Document): void => {
//TODO This won't create the field if it doesn't already exist
- const value = this.props.doc.GetData(this.props.fieldKey, ListField, new Array<Document>())
+ const value = this.props.Document.GetData(this.props.fieldKey, ListField, new Array<Document>())
value.push(doc);
}
@action
- removeDocument = (doc: Document): void => {
+ removeDocument = (doc: Document): boolean => {
//TODO This won't create the field if it doesn't already exist
- const value = this.props.doc.GetData(this.props.fieldKey, ListField, new Array<Document>())
- if (value.indexOf(doc) !== -1) {
- value.splice(value.indexOf(doc), 1)
+ const value = this.props.Document.GetData(this.props.fieldKey, ListField, new Array<Document>())
+ let index = value.indexOf(doc);
+ if (index !== -1) {
+ value.splice(index, 1)
SelectionManager.DeselectAll()
ContextMenu.Instance.clearItems()
+ return true;
}
+ return false
}
} \ No newline at end of file