aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client/views/collections/CollectionMasonryViewFieldRow.tsx12
-rw-r--r--src/client/views/collections/CollectionStackingView.tsx20
2 files changed, 27 insertions, 5 deletions
diff --git a/src/client/views/collections/CollectionMasonryViewFieldRow.tsx b/src/client/views/collections/CollectionMasonryViewFieldRow.tsx
index af3e18a4b..b272151c1 100644
--- a/src/client/views/collections/CollectionMasonryViewFieldRow.tsx
+++ b/src/client/views/collections/CollectionMasonryViewFieldRow.tsx
@@ -36,6 +36,9 @@ interface CMVFieldRowProps {
createDropTarget: (ele: HTMLDivElement) => void;
screenToLocalTransform: () => Transform;
setDocHeight: (key: string, thisHeight: number) => void;
+ observeHeight: (myref: any) => void;
+ unobserveHeight: (myref: any) => void;
+ showHandle: boolean;
}
@observer
@@ -53,14 +56,19 @@ export class CollectionMasonryViewFieldRow extends React.Component<CMVFieldRowPr
private _contRef: React.RefObject<HTMLDivElement> = React.createRef();
private _sensitivity: number = 16;
private _counter: number = 0;
-
+ private _ele: any;
createRowDropRef = (ele: HTMLDivElement | null) => {
this._dropDisposer && this._dropDisposer();
if (ele) {
+ this._ele = ele;
+ this.props.observeHeight(ele);
this._dropDisposer = DragManager.MakeDropTarget(ele, this.rowDrop.bind(this));
}
}
+ componentWillUnmount() {
+ this.props.unobserveHeight(this._ele);
+ }
getTrueHeight = () => {
if (this._collapsed) {
@@ -293,7 +301,7 @@ export class CollectionMasonryViewFieldRow extends React.Component<CMVFieldRowPr
gridTemplateColumns: numberRange(rows).reduce((list: string, i: any) => list + ` ${this.props.parent.columnWidth}px`, ""),
}}>
{this.props.parent.children(this.props.docList)}
- {this.props.parent.columnDragger}
+ {this.props.showHandle && this.props.parent.props.active() ? this.props.parent.columnDragger : (null)}
</div>
</div>;
}
diff --git a/src/client/views/collections/CollectionStackingView.tsx b/src/client/views/collections/CollectionStackingView.tsx
index 84e6ecced..b066f2be3 100644
--- a/src/client/views/collections/CollectionStackingView.tsx
+++ b/src/client/views/collections/CollectionStackingView.tsx
@@ -295,7 +295,7 @@ export class CollectionStackingView extends CollectionSubView(doc => doc) {
this.refList.push(ref);
const doc = this.props.DataDoc && this.props.DataDoc.layout === this.layoutDoc ? this.props.DataDoc : this.layoutDoc;
this.observer = new _global.ResizeObserver(action((entries: any) => {
- if (this.props.Document._autoHeight && ref && !SelectionManager.GetIsDragging()) {
+ if (this.props.Document._autoHeight && ref && this.refList.length && !SelectionManager.GetIsDragging()) {
Doc.Layout(doc)._height = Math.max(...this.refList.map(r => Number(getComputedStyle(r).height.replace("px", ""))));
}
}));
@@ -325,7 +325,7 @@ export class CollectionStackingView extends CollectionSubView(doc => doc) {
return this.props.ScreenToLocalTransform().translate(offset[0], offset[1] + offsety);
}
- sectionMasonry = (heading: SchemaHeaderField | undefined, docList: Doc[]) => {
+ sectionMasonry = (heading: SchemaHeaderField | undefined, docList: Doc[], first: boolean) => {
const key = this.pivotField;
let type: "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" | undefined = undefined;
const types = docList.length ? docList.map(d => typeof d[key]) : this.filteredChildren.map(d => typeof d[key]);
@@ -335,6 +335,20 @@ export class CollectionStackingView extends CollectionSubView(doc => doc) {
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}
+ unobserveHeight={(ref) => this.refList.splice(this.refList.indexOf(ref), 1)}
+ observeHeight={(ref) => {
+ if (ref) {
+ this.refList.push(ref);
+ const doc = this.props.DataDoc && this.props.DataDoc.layout === this.layoutDoc ? this.props.DataDoc : this.layoutDoc;
+ this.observer = new _global.ResizeObserver(action((entries: any) => {
+ if (this.props.Document._autoHeight && ref && this.refList.length && !SelectionManager.GetIsDragging()) {
+ Doc.Layout(doc)._height = this.refList.reduce((p, r) => p + Number(getComputedStyle(r).height.replace("px", "")), 0)
+ }
+ }));
+ this.observer.observe(ref);
+ }
+ }}
key={heading ? heading.heading : ""}
rows={rows}
headings={this.headings}
@@ -387,7 +401,7 @@ export class CollectionStackingView extends CollectionSubView(doc => doc) {
const entries = Array.from(this.Sections.entries());
sections = entries.sort(this.sortFunc);
}
- return sections.map(section => this.isStackingView ? this.sectionStacking(section[0], section[1]) : this.sectionMasonry(section[0], section[1]));
+ return sections.map((section, i) => this.isStackingView ? this.sectionStacking(section[0], section[1]) : this.sectionMasonry(section[0], section[1], i === 0));
}