aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreeng5 <eleanor_eng@brown.edu>2019-09-05 12:13:27 -0400
committereeng5 <eleanor_eng@brown.edu>2019-09-05 12:13:27 -0400
commit5da8791dabdd3dd25e80fb320258ec809c22291e (patch)
treecd7f32502642542f0b9ca47bec82038927b5edfd
parent5a7ec36e558bdf5333cb7c16faad8f31bfcf314e (diff)
this is temporary
-rw-r--r--src/client/views/collections/CollectionMasonryViewFieldRow.tsx31
-rw-r--r--src/client/views/collections/CollectionStackingView.tsx49
2 files changed, 78 insertions, 2 deletions
diff --git a/src/client/views/collections/CollectionMasonryViewFieldRow.tsx b/src/client/views/collections/CollectionMasonryViewFieldRow.tsx
index 1c1e44bb5..65e05ff28 100644
--- a/src/client/views/collections/CollectionMasonryViewFieldRow.tsx
+++ b/src/client/views/collections/CollectionMasonryViewFieldRow.tsx
@@ -33,6 +33,7 @@ interface CMVFieldRowProps {
type: "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" | undefined;
createDropTarget: (ele: HTMLDivElement) => void;
screenToLocalTransform: () => Transform;
+ addToDocHeight: (thisHeight: number) => void;
}
@observer
@@ -43,17 +44,45 @@ export class CollectionMasonryViewFieldRow extends React.Component<CMVFieldRowPr
private dropDisposer?: DragManager.DragDropDisposer;
private _headerRef: React.RefObject<HTMLDivElement> = React.createRef();
private _startDragPosition: { x: number, y: number } = { x: 0, y: 0 };
+ private _contRef: React.RefObject<HTMLDivElement> = React.createRef();
private _sensitivity: number = 16;
@observable _heading = this.props.headingObject ? this.props.headingObject.heading : this.props.heading;
@observable _color = this.props.headingObject ? this.props.headingObject.color : "#f1efeb";
createRowDropRef = (ele: HTMLDivElement | null) => {
+ console.log("createRowDropRef ran");
this._dropRef = ele;
this.dropDisposer && this.dropDisposer();
if (ele) {
this.dropDisposer = DragManager.MakeDropTarget(ele, { handlers: { drop: this.rowDrop.bind(this) } });
}
+ // this.getTrueHeight();
+ }
+
+ getTrueHeight = () => { //handle collapse in here (if collapsed, return #)
+ //also, don't need to return anything
+ //call this in component did mount or something...
+ if (this.collapsed) {
+ this.props.addToDocHeight(20);
+ console.log("collapsed");
+ } else { //this is calculating the heights correctlty
+ let rawHeight = this._contRef.current!.getBoundingClientRect().height + 20;
+ let transformScale = this.props.screenToLocalTransform().Scale;
+ let trueHeight = rawHeight * transformScale;
+ this.props.addToDocHeight(trueHeight);
+ console.log("trueHeight: " + trueHeight);
+ }
+ this.props.addToDocHeight(20);
+ }
+
+ // componentDidMount = () => {
+ // this.getTrueHeight();
+ // }
+
+ componentDidUpdate = () => {
+ console.log("componentDidUpdate");
+ this.getTrueHeight(); //why does this
}
@undoBatch
@@ -323,6 +352,8 @@ export class CollectionMasonryViewFieldRow extends React.Component<CMVFieldRowPr
{this.collapsed ? (null) :
< div >
<div key={`${heading}-stack`} className={`collectionStackingView-masonryGrid`}
+ // ref={this.getTrueHeight}
+ ref={this._contRef}
style={{
padding: `${this.props.parent.yMargin}px ${this.props.parent.xMargin}px`,
width: this.props.parent.NodeWidth,
diff --git a/src/client/views/collections/CollectionStackingView.tsx b/src/client/views/collections/CollectionStackingView.tsx
index 7ba177a7d..43a7333d0 100644
--- a/src/client/views/collections/CollectionStackingView.tsx
+++ b/src/client/views/collections/CollectionStackingView.tsx
@@ -25,6 +25,8 @@ import { ContextMenuProps } from "../ContextMenuItem";
import { ScriptBox } from "../ScriptBox";
import { CollectionMasonryViewFieldRow } from "./CollectionMasonryViewFieldRow";
+let _height: number = 0;
+
@observer
export class CollectionStackingView extends CollectionSubView(doc => doc) {
_masonryGridRef: HTMLDivElement | null = null;
@@ -34,7 +36,9 @@ export class CollectionStackingView extends CollectionSubView(doc => doc) {
_sectionFilterDisposer?: IReactionDisposer;
_docXfs: any[] = [];
_columnStart: number = 0;
+ // _height: number = 0;
@observable private cursor: CursorProperty = "grab";
+ // @computed private _height: number = 0;
@computed get sectionHeaders() { return Cast(this.props.Document.sectionHeaders, listSpec(SchemaHeaderField)); }
@computed get sectionFilter() { return StrCast(this.props.Document.sectionFilter); }
@computed get filteredChildren() { return this.childDocs.filter(d => !d.isMinimized); }
@@ -54,6 +58,14 @@ export class CollectionStackingView extends CollectionSubView(doc => doc) {
childDocHeight(child: Doc) { return this.getDocHeight(Doc.GetLayoutDataDocPair(this.props.Document, this.props.DataDoc, this.props.fieldKey, child).layout); }
+ addToDocHeight(sectionHeight: number) {
+ // if (_height !== undefined) {
+ console.log("indiv height: " + _height);
+ _height += sectionHeight;
+ // }
+ // return _height;
+ }
+
get layoutDoc() {
// if this document's layout field contains a document (ie, a rendering template), then we will use that
// to determine the render JSX string, otherwise the layout field should directly contain a JSX layout string.
@@ -102,8 +114,40 @@ export class CollectionStackingView extends CollectionSubView(doc => doc) {
return this.props.ContentScaling() * sectionsList.reduce((maxHght, s) => Math.max(maxHght,
(this.Sections.size ? 50 : 0) + s.reduce((height, d, i) => height + this.childDocHeight(d) + (i === s.length - 1 ? this.yMargin : this.gridGap), this.yMargin)), 0);
} else {
- return this.props.ContentScaling() * sectionsList.reduce((totalHeight, s) => totalHeight +
- (this.Sections.size ? 50 : 0) + s.reduce((height, d, i) => height + this.childDocHeight(d) + (i === s.length - 1 ? this.yMargin : this.gridGap), this.yMargin) + 47, 0);
+ // let rowArray: CollectionMasonryViewFieldRow[] = [];
+ for (let i = 0; i < this.Sections.size; i++) {
+ // rowArray.push(this._masonryGridRef);
+ }
+ let sum: number = 0;
+ // let counter: number = 0;
+ sum += _height; //calculated height of the node from the masonry prop
+ // console.log("height: " + _height);
+ if (this.sectionHeaders !== undefined) {
+ // this.sectionHeaders.forEach(sec => {
+ // if (sec.collapsed) {
+ // sum += 20;
+ // console.log("sec collapsed");
+ // } else {
+ // // sum += sectionsList[counter].reduce((height, d, i) => height + this.childDocHeight(d) + (i === sectionsList[counter].length - 1 ? this.yMargin : this.gridGap), this.yMargin);
+ // // sum += NumCast(document.getElementsByClassName("collectionStackingView-sectionHeader-subCont").offsetHeight);
+ // // sum += this.addToDocHeight(this.Sections[counter]);
+ // // console.log("section is not collapsed");
+ // sum += _height;
+ // // this.addToDocHeight(40);
+ // // console.log("this._height in componentDidMount: " + _height);
+ // }
+ // // console.log("IN IF STATEMENT, sum is: " + sum);
+ // counter += 1;
+ // });
+ }
+ // return this.props.ContentScaling() * sectionsList.reduce((totalHeight, s) => totalHeight +
+ // (this.Sections.size ? 50 : 0) + s.reduce((height, d, i) => height + this.childDocHeight(d) + (i === s.length - 1 ? this.yMargin : this.gridGap), this.yMargin) + 47, 0);
+ sum += 20; //allow space for the "add group" button
+ console.log("sum: " + sum);
+ _height = 0; //without this the height get HUGE (just keeps adding i think...)
+ return this.props.ContentScaling() * (sum + (this.Sections.size ? 50 : 0)); //+47
+ // return this.props.ContentScaling() * sectionsList.reduce((totalHeight, s) => totalHeight +
+ // (this.Sections.size ? 50 : 0) + s.reduce((height, d, i) => height + this.childDocHeight(d) + (i === s.length - 1 ? this.yMargin : this.gridGap), this.yMargin) + 47, 0);
}
}
return -1;
@@ -313,6 +357,7 @@ export class CollectionStackingView extends CollectionSubView(doc => doc) {
type={type}
createDropTarget={this.createDropTarget}
screenToLocalTransform={this.props.ScreenToLocalTransform}
+ addToDocHeight={this.addToDocHeight}
/>;
}