aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/CollectionTreeView.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/collections/CollectionTreeView.tsx')
-rw-r--r--src/client/views/collections/CollectionTreeView.tsx30
1 files changed, 10 insertions, 20 deletions
diff --git a/src/client/views/collections/CollectionTreeView.tsx b/src/client/views/collections/CollectionTreeView.tsx
index 6fb18d4c2..ea077ea40 100644
--- a/src/client/views/collections/CollectionTreeView.tsx
+++ b/src/client/views/collections/CollectionTreeView.tsx
@@ -7,7 +7,7 @@ import { Document, listSpec } from '../../../fields/Schema';
import { ScriptField } from '../../../fields/ScriptField';
import { BoolCast, Cast, NumCast, ScriptCast, StrCast } from '../../../fields/Types';
import { TraceMobx } from '../../../fields/util';
-import { emptyFunction, OmitKeys, returnEmptyDoclist, returnEmptyFilter, returnFalse, returnTrue } from '../../../Utils';
+import { emptyFunction, OmitKeys, returnEmptyDoclist, returnEmptyFilter, returnFalse, returnTrue, returnOne } from '../../../Utils';
import { DocUtils } from '../../documents/Documents';
import { CurrentUserUtils } from '../../util/CurrentUserUtils';
import { DocumentManager } from '../../util/DocumentManager';
@@ -47,7 +47,8 @@ export class CollectionTreeView extends CollectionSubView<Document, Partial<coll
private _disposers: { [name: string]: IReactionDisposer } = {};
private _isDisposing = false; // notes that instance is in process of being disposed
private refList: Set<any> = new Set(); // list of tree view items to monitor for height changes
- private observer: any; // observer for mnonitoring tree view items.
+ private observer: any; // observer for monitoring tree view items.
+ private static expandViewLabelSize = 20;
@computed get doc() { return this.props.Document; }
@computed get dataDoc() { return this.props.DataDoc || this.doc; }
@@ -187,36 +188,26 @@ export class CollectionTreeView extends CollectionSubView<Document, Partial<coll
get documentTitle() {
- return <DocumentView
- Document={this.doc}
- DataDoc={undefined}
- LayoutTemplateString={FormattedTextBox.LayoutString("text")}
+ return <FormattedTextBox
+ {...this.props}
+ fieldKey={"text"}
renderDepth={this.props.renderDepth + 1}
isContentActive={this.isContentActive}
isDocumentActive={this.isContentActive}
rootSelected={returnTrue}
forceAutoHeight={true} // needed to make the title resize even if the rest of the tree view is not autoHeight
- docViewPath={this.props.docViewPath}
- styleProvider={this.props.styleProvider}
- layerProvider={this.props.layerProvider}
PanelWidth={this.documentTitleWidth}
PanelHeight={this.documentTitleHeight}
- NativeWidth={this.documentTitleWidth}
- NativeHeight={this.documentTitleHeight}
- focus={this.props.focus}
- treeViewDoc={this.props.Document}
- ScreenToLocalTransform={this.titleTransform}
+ scaling={returnOne}
docFilters={returnEmptyFilter}
docRangeFilters={returnEmptyFilter}
searchFilterDocs={returnEmptyDoclist}
ContainingCollectionDoc={this.doc}
ContainingCollectionView={this.props.CollectionView}
- addDocument={this.props.addDocument}
+ addDocument={returnFalse}
moveDocument={returnFalse}
removeDocument={returnFalse}
whenChildContentsActiveChanged={this.whenChildContentsActiveChanged}
- addDocTab={this.props.addDocTab}
- pinToPres={this.props.pinToPres}
bringToFront={returnFalse}
/>;
}
@@ -265,7 +256,7 @@ export class CollectionTreeView extends CollectionSubView<Document, Partial<coll
@computed get titleBar() {
return this.dataDoc === null ? (null) :
<div className="collectionTreeView-titleBar" key={this.doc[Id]}
- style={!this.outlineMode ? { paddingLeft: this.marginX(), paddingRight: this.marginX(), paddingTop: this.marginTop() } : {}}
+ style={!this.outlineMode ? { paddingLeft: this.marginX(), paddingTop: this.marginTop() } : {}}
ref={r => this._titleRef = r}
onKeyDown={e => {
if (this.outlineMode) {
@@ -333,10 +324,9 @@ export class CollectionTreeView extends CollectionSubView<Document, Partial<coll
marginBot = () => NumCast(this.doc._yMargin);
documentTitleWidth = () => Math.min(this.layoutDoc?.[WidthSym](), this.panelWidth());
documentTitleHeight = () => (this.layoutDoc?.[HeightSym]() || 0) - NumCast(this.layoutDoc.autoHeightMargins);
- titleTransform = () => this.props.ScreenToLocalTransform().translate(-NumCast(this.doc._xPadding, 10), -NumCast(this.doc._yPadding, 20));
truncateTitleWidth = () => this.treeViewtruncateTitleWidth;
onChildClick = () => this.props.onChildClick?.() || ScriptCast(this.doc.onChildClick);
- panelWidth = () => (this.props.PanelWidth() - 2 * this.marginX()) * (this.props.scaling?.() || 1);
+ panelWidth = () => Math.max(0, this.props.PanelWidth() - this.marginX() - CollectionTreeView.expandViewLabelSize) * (this.props.scaling?.() || 1);
addAnnotationDocument = (doc: Doc | Doc[]) => this.props.CollectionView?.addDocument(doc, `${this.props.fieldKey}-annotations`) || false;
remAnnotationDocument = (doc: Doc | Doc[]) => this.props.CollectionView?.removeDocument(doc, `${this.props.fieldKey}-annotations`) || false;