aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/CollectionBaseView.tsx
diff options
context:
space:
mode:
authorbob <bcz@cs.brown.edu>2019-06-25 09:35:09 -0400
committerbob <bcz@cs.brown.edu>2019-06-25 09:35:09 -0400
commit45ded4da2592bc2a8201e1260dfb6a80485684c7 (patch)
tree47cd5a7e031ae9535f4926e74b10bd24266b78d9 /src/client/views/collections/CollectionBaseView.tsx
parent66acf0237f2e1fe74660e5c2a035757403f79f8b (diff)
converted isTopMost into renderDepth and capped renderDepth at 7. removed previous cycle detection.
Diffstat (limited to 'src/client/views/collections/CollectionBaseView.tsx')
-rw-r--r--src/client/views/collections/CollectionBaseView.tsx48
1 files changed, 9 insertions, 39 deletions
diff --git a/src/client/views/collections/CollectionBaseView.tsx b/src/client/views/collections/CollectionBaseView.tsx
index 79a9f3be0..50d1a5071 100644
--- a/src/client/views/collections/CollectionBaseView.tsx
+++ b/src/client/views/collections/CollectionBaseView.tsx
@@ -64,8 +64,7 @@ export class CollectionBaseView extends React.Component<CollectionViewProps> {
active = (): boolean => {
var isSelected = this.props.isSelected();
- var topMost = this.props.isTopMost;
- return isSelected || this._isChildActive || topMost;
+ return isSelected || this._isChildActive || this.props.renderDepth === 0;
}
//TODO should this be observable?
@@ -75,32 +74,6 @@ export class CollectionBaseView extends React.Component<CollectionViewProps> {
this.props.whenActiveChanged(isActive);
}
- createsCycle(documentToAdd: Doc, containerDocument: Doc): boolean {
- if (!(documentToAdd instanceof Doc)) {
- return false;
- }
- if (StrCast(documentToAdd.layout).indexOf("CollectionView") !== -1) {
- let data = DocListCast(documentToAdd.data);
- for (const doc of data) {
- if (this.createsCycle(doc, containerDocument)) {
- return true;
- }
- }
- }
- let annots = DocListCast(documentToAdd.annotations);
- for (const annot of annots) {
- if (this.createsCycle(annot, containerDocument)) {
- return true;
- }
- }
- for (let containerProto: Opt<Doc> = containerDocument; containerProto !== undefined; containerProto = FieldValue(containerProto.proto)) {
- if (containerProto[Id] === documentToAdd[Id]) {
- return true;
- }
- }
- return false;
- }
-
@action.bound
addDocument(doc: Doc, allowDuplicates: boolean = false): boolean {
var curPage = NumCast(this.props.Document.curPage, -1);
@@ -109,19 +82,16 @@ export class CollectionBaseView extends React.Component<CollectionViewProps> {
Doc.GetProto(doc).annotationOn = this.props.Document;
}
allowDuplicates = true;
- if (!this.createsCycle(doc, this.dataDoc)) {
- //TODO This won't create the field if it doesn't already exist
- const value = Cast(this.dataDoc[this.props.fieldKey], listSpec(Doc));
- if (value !== undefined) {
- if (allowDuplicates || !value.some(v => v instanceof Doc && v[Id] === doc[Id])) {
- value.push(doc);
- }
- } else {
- Doc.SetOnPrototype(this.dataDoc, this.props.fieldKey, new List([doc]));
+ //TODO This won't create the field if it doesn't already exist
+ const value = Cast(this.dataDoc[this.props.fieldKey], listSpec(Doc));
+ if (value !== undefined) {
+ if (allowDuplicates || !value.some(v => v instanceof Doc && v[Id] === doc[Id])) {
+ value.push(doc);
}
- return true;
+ } else {
+ Doc.SetOnPrototype(this.dataDoc, this.props.fieldKey, new List([doc]));
}
- return false;
+ return true;
}
@action.bound