diff options
| author | Tyler Schicke <tyler_schicke@brown.edu> | 2019-02-05 19:37:48 -0500 |
|---|---|---|
| committer | Tyler Schicke <tyler_schicke@brown.edu> | 2019-02-05 19:37:48 -0500 |
| commit | 6a13071a695732b2235f988278c52d0072af0fb5 (patch) | |
| tree | 94d6ccf16572463520fd744e41988b1dc8c7b7e3 /src/views/collections/CollectionViewBase.tsx | |
| parent | 41afca0448b4e75459fc8aeb53192f6a44aa2b18 (diff) | |
| parent | 6e66f8b227c730e07863a93a8bce5ee0d51d2ddc (diff) | |
Merge branch 'master' of github-tsch-brown:browngraphicslab/Dash-Web into scripting
Diffstat (limited to 'src/views/collections/CollectionViewBase.tsx')
| -rw-r--r-- | src/views/collections/CollectionViewBase.tsx | 14 |
1 files changed, 9 insertions, 5 deletions
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) |
