aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/DocComponent.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/DocComponent.tsx')
-rw-r--r--src/client/views/DocComponent.tsx16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/client/views/DocComponent.tsx b/src/client/views/DocComponent.tsx
index fdaca8056..61b7a3bff 100644
--- a/src/client/views/DocComponent.tsx
+++ b/src/client/views/DocComponent.tsx
@@ -10,6 +10,8 @@ import { DocUtils } from '../documents/Documents';
import { DocumentType } from '../documents/DocumentTypes';
import { DocumentView } from './nodes/DocumentView';
import * as React from 'react';
+import { DocumentManager } from '../util/DocumentManager';
+import { CollectionFreeFormView } from './collections/collectionFreeForm';
/// DocComponent returns a generic React base class used by views that don't have 'fieldKey' props (e.g.,CollectionFreeFormDocumentView, DocumentView)
export interface DocComponentProps {
@@ -26,7 +28,7 @@ export function DocComponent<P extends DocComponentProps>() {
}
// This is the "The Document" -- it encapsulates, data, layout, and any templates
@computed get rootDoc() {
- return Cast(this.props.Document.rootDocument, Doc, null) || this.props.Document;
+ return this.props.Document;
}
// This is the rendering data of a document -- it may be "The Document", or it may be some template document that holds the rendering info
@computed get layoutDoc() {
@@ -58,7 +60,9 @@ export function ViewBoxBaseComponent<P extends ViewBoxBaseProps>() {
class Component extends React.Component<React.PropsWithChildren<P>> {
//TODO This might be pretty inefficient if doc isn't observed, because computed doesn't cache then
//@computed get Document(): T { return schemaCtor(this.props.Document); }
-
+ @computed get Document() {
+ return this.props.Document;
+ }
// This is the "The Document" -- it encapsulates, data, layout, and any templates
@computed get rootDoc() {
return Cast(this.props.Document.rootDocument, Doc, null) || this.props.Document;
@@ -146,7 +150,11 @@ export function ViewBoxAnnotatableComponent<P extends ViewBoxAnnotatableProps>()
doc.type !== DocumentType.LOADING && Doc.AddDocToList(recent, 'data', doc, undefined, true, true);
}
});
- this.isAnyChildContentActive() && this.props.select(false);
+ if (targetDataDoc.isGroup && DocListCast(targetDataDoc[annotationKey ?? this.annotationKey]).length < 2) {
+ (DocumentManager.Instance.getFirstDocumentView(targetDataDoc)?.ComponentView as CollectionFreeFormView)?.promoteCollection();
+ } else {
+ this.isAnyChildContentActive() && this.props.select(false);
+ }
return true;
}
@@ -173,7 +181,7 @@ export function ViewBoxAnnotatableComponent<P extends ViewBoxAnnotatableProps>()
if (this.props.filterAddDocument?.(docs) === false || docs.find(doc => Doc.AreProtosEqual(doc, this.props.Document) && Doc.LayoutField(doc) === Doc.LayoutField(this.props.Document))) {
return false;
}
- const targetDataDoc = this.rootDoc[DocData];
+ const targetDataDoc = this.dataDoc;
const effectiveAcl = GetEffectiveAcl(targetDataDoc);
if (effectiveAcl === AclPrivate || effectiveAcl === AclReadonly) {