aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/CollectionStackingView.tsx
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2025-03-06 16:17:47 -0500
committerbobzel <zzzman@gmail.com>2025-03-06 16:17:47 -0500
commit5ad858090f3006631062877d90120e3cc505fada (patch)
tree9f87a8e1e7098a1025f6f4aac332dbc854db5be3 /src/client/views/collections/CollectionStackingView.tsx
parent9c2a7c14fd9d0e44609aab30c6323583162009db (diff)
parentadaa107aac8558fa6f46e6ba1263c650c212d506 (diff)
Merge branch 'master' into aarav_edit
Diffstat (limited to 'src/client/views/collections/CollectionStackingView.tsx')
-rw-r--r--src/client/views/collections/CollectionStackingView.tsx71
1 files changed, 45 insertions, 26 deletions
diff --git a/src/client/views/collections/CollectionStackingView.tsx b/src/client/views/collections/CollectionStackingView.tsx
index a57256424..96125f2c2 100644
--- a/src/client/views/collections/CollectionStackingView.tsx
+++ b/src/client/views/collections/CollectionStackingView.tsx
@@ -110,7 +110,9 @@ export class CollectionStackingView extends CollectionSubView<Partial<collection
}
// columnWidth handles the margin on the left and right side of the documents
@computed get columnWidth() {
- return Math.min(this._props.PanelWidth() - 2 * this.xMargin, this.isStackingView ? Number.MAX_VALUE : this.layoutDoc._columnWidth === -1 ? this._props.PanelWidth() - 2 * this.xMargin : NumCast(this.layoutDoc._columnWidth, 250));
+ const availableWidth = this._props.PanelWidth() - 2 * this.xMargin;
+ const cwid = availableWidth / (NumCast(this.Document._layout_columnCount) || this._props.PanelWidth() / NumCast(this.Document._layout_columnWidth, this._props.PanelWidth() / 4));
+ return Math.min(availableWidth, this.isStackingView ? Number.MAX_VALUE : cwid - this.gridGap);
}
@computed get NodeWidth() {
@@ -221,6 +223,9 @@ export class CollectionStackingView extends CollectionSubView<Partial<collection
return fields;
}
+ setAutoHeight = () => this._props.setHeight?.(this.headerMargin + (this.isStackingView ? Math.max(...this._refList.map(DivHeight)) : 2 * this.yMargin + this._refList.reduce((p, r) => p + DivHeight(r), 0)));
+ observer = new ResizeObserver(this.setAutoHeight);
+
componentDidMount() {
super.componentDidMount?.();
this._props.setContentViewBox?.(this);
@@ -232,10 +237,21 @@ export class CollectionStackingView extends CollectionSubView<Partial<collection
this.dataDoc['_' + this.fieldKey + '_columnHeaders'] = new List();
}
);
+ // reset section headers when a new filter is inputted
+ this._disposers.width = reaction(
+ () => [this._props.PanelWidth() - 2 * this.xMargin, NumCast(this.Document._layout_columnWidth, 250)],
+ ([pw, cw]) => {
+ if (!this.isStackingView && Math.round(pw / cw)) {
+ this.layoutDoc._layout_columnCount = Math.round(pw / cw);
+ }
+ }
+ );
+
this._disposers.autoHeight = reaction(
- () => this.layoutDoc._layout_autoHeight,
- layoutAutoHeight => layoutAutoHeight && this._props.setHeight?.(this.headerMargin + (this.isStackingView ? Math.max(...this._refList.map(DivHeight)) : this._refList.reduce((p, r) => p + DivHeight(r), 0)))
+ () => [this.layoutDoc._layout_autoHeight, this.yMargin],
+ ([autoH]) => autoH && this.setAutoHeight()
);
+
this._disposers.refList = reaction(
() => ({ refList: this._refList.slice(), autoHeight: this.layoutDoc._layout_autoHeight && !DocumentView.LightboxContains(this.DocumentView?.()) }),
({ refList, autoHeight }) => {
@@ -435,8 +451,8 @@ export class CollectionStackingView extends CollectionSubView<Partial<collection
);
};
@action
- onDividerMove = (e: PointerEvent, down: number[], delta: number[]) => {
- this.layoutDoc._columnWidth = Math.max(10, this.columnWidth + delta[0]);
+ onDividerMove = (e: PointerEvent) => {
+ this.Document._layout_columnWidth = Math.max(10, (this._props.DocumentView?.().screenToViewTransform().transformPoint(e.clientX, 0)[0] ?? 0) - this.xMargin);
return false;
};
@@ -446,7 +462,7 @@ export class CollectionStackingView extends CollectionSubView<Partial<collection
className="collectionStackingView-columnDragger"
onPointerDown={this.columnDividerDown}
ref={this._draggerRef}
- style={{ cursor: this._cursor, color: SettingsManager.userColor, left: `${this.columnWidth + this.xMargin}px`, top: `${Math.max(0, this.yMargin - 9)}px` }}>
+ style={{ cursor: this._cursor, color: SettingsManager.userColor, left: `${NumCast(this.Document._layout_columnWidth) + this.xMargin}px` }}>
<FontAwesomeIcon icon="arrows-alt-h" />
</div>
);
@@ -590,24 +606,29 @@ export class CollectionStackingView extends CollectionSubView<Partial<collection
}
const rows = () => (!this.isStackingView ? 1 : Math.max(1, Math.min(docList.length, Math.floor((this._props.PanelWidth() - 2 * this.xMargin) / (this.columnWidth + this.gridGap)))));
return (
- <CollectionMasonryViewFieldRow
- showHandle={first}
- Document={this.Document}
- chromeHidden={this.chromeHidden}
- pivotField={this.pivotField}
- refList={this._refList}
- key={heading ? heading.heading : ''}
- rows={rows}
- headings={this.headings}
- heading={heading ? heading.heading : ''}
- headingObject={heading}
- docList={docList}
- parent={this}
- type={type}
- createDropTarget={this.createDashEventsTarget}
- screenToLocalTransform={this.ScreenToLocalBoxXf}
- setDocHeight={this.setDocHeight}
- />
+ <div key={(heading?.heading ?? '') + 'head'}>
+ {this._props.isContentActive() && !this.isStackingView && !this.chromeHidden ? this.columnDragger : null}
+ <div style={{ top: this.yMargin }}>
+ <CollectionMasonryViewFieldRow
+ showHandle={first}
+ Document={this.Document}
+ chromeHidden={this.chromeHidden}
+ pivotField={this.pivotField}
+ refList={this._refList}
+ key={heading ? heading.heading : ''}
+ rows={rows}
+ headings={this.headings}
+ heading={heading ? heading.heading : ''}
+ headingObject={heading}
+ docList={docList}
+ parent={this}
+ type={type}
+ createDropTarget={this.createDashEventsTarget}
+ screenToLocalTransform={this.ScreenToLocalBoxXf}
+ setDocHeight={this.setDocHeight}
+ />
+ </div>
+ </div>
);
};
@@ -699,8 +720,6 @@ export class CollectionStackingView extends CollectionSubView<Partial<collection
return this._props.isContentActive() === false ? 'none' : undefined;
}
- observer = new ResizeObserver(() => this._props.setHeight?.(this.headerMargin + (this.isStackingView ? Math.max(...this._refList.map(DivHeight)) : this._refList.reduce((p, r) => p + DivHeight(r), 0))));
-
onPassiveWheel = (e: WheelEvent) => e.stopPropagation();
render() {
TraceMobx();