aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client/views/EditableView.tsx30
-rw-r--r--src/client/views/collections/CollectionMasonryViewFieldRow.tsx32
-rw-r--r--src/client/views/collections/CollectionStackingView.tsx43
-rw-r--r--src/client/views/collections/CollectionStackingViewFieldColumn.tsx66
-rw-r--r--src/new_fields/SchemaHeaderField.ts3
5 files changed, 75 insertions, 99 deletions
diff --git a/src/client/views/EditableView.tsx b/src/client/views/EditableView.tsx
index 87af19062..757ddbad1 100644
--- a/src/client/views/EditableView.tsx
+++ b/src/client/views/EditableView.tsx
@@ -41,8 +41,10 @@ export interface EditableProps {
editing?: boolean;
onClick?: (e: React.MouseEvent) => boolean;
isEditingCallback?: (isEditing: boolean) => void;
- // HeadingObject: SchemaHeaderField | undefined;
- // HeadingsHack: number;
+ HeadingObject?: SchemaHeaderField | undefined;
+ HeadingsHack?: number;
+ toggle?: () => void;
+ color?: string | undefined;
}
/**
@@ -53,7 +55,6 @@ export interface EditableProps {
@observer
export class EditableView extends React.Component<EditableProps> {
@observable _editing: boolean = false;
- @observable _collapsed: boolean = false;
@observable _headingsHack: number = 1;
constructor(props: EditableProps) {
@@ -71,14 +72,13 @@ export class EditableView extends React.Component<EditableProps> {
}
}
- // collapseSection() {
- // if (this.props.HeadingObject) {
- // this._headingsHack++;
- // this.props.HeadingObject.setCollapsed(!this.props.HeadingObject.collapsed);
- // this._collapsed = !this._collapsed;
- // console.log("THIS IS COLLAPSE FROM EDITABLEVIEW" + this._collapsed);
- // }
- // }
+ collapseSection() {
+ if (this.props.HeadingObject) {
+ this._headingsHack++;
+ this.props.HeadingObject.setCollapsed(!this.props.HeadingObject.collapsed);
+ this.props.toggle && this.props.toggle();
+ }
+ }
@action
onKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
@@ -107,13 +107,15 @@ export class EditableView extends React.Component<EditableProps> {
@action
onClick = (e: React.MouseEvent) => {
e.nativeEvent.stopPropagation();
- // if (e.ctrlKey) {
- // this.collapseSection();
- // }
if (!this.props.onClick || !this.props.onClick(e)) {
this._editing = true;
this.props.isEditingCallback && this.props.isEditingCallback(true);
}
+ if (e.ctrlKey) {
+ this._editing = false;
+ this.props.isEditingCallback && this.props.isEditingCallback(false);
+ this.collapseSection();
+ }
e.stopPropagation();
}
diff --git a/src/client/views/collections/CollectionMasonryViewFieldRow.tsx b/src/client/views/collections/CollectionMasonryViewFieldRow.tsx
index 8943fea3b..ca386f91b 100644
--- a/src/client/views/collections/CollectionMasonryViewFieldRow.tsx
+++ b/src/client/views/collections/CollectionMasonryViewFieldRow.tsx
@@ -248,7 +248,12 @@ export class CollectionMasonryViewFieldRow extends React.Component<CMVFieldRowPr
@observable private collapsed: boolean = false;
+ private toggleVisibility = action(() => {
+ this.collapsed = !this.collapsed;
+ });
+
@observable _headingsHack: number = 1;
+
render() {
let cols = this.props.rows();
let rows = Math.max(1, Math.min(this.props.docList.length, Math.floor((this.props.parent.props.PanelWidth() - 2 * this.props.parent.xMargin) / (this.props.parent.columnWidth + this.props.parent.gridGap))));
@@ -264,30 +269,23 @@ export class CollectionMasonryViewFieldRow extends React.Component<CMVFieldRowPr
SetValue: this.headingChanged,
contents: evContents,
oneLine: true,
- // HeadingObject: this.props.headingObject,
- // HeadingsHack: this._headingsHack
+ HeadingObject: this.props.headingObject,
+ HeadingsHack: this._headingsHack,
+ toggle: this.toggleVisibility,
+ color: this.props.color
};
let newEditableViewProps = {
GetValue: () => "",
SetValue: this.addDocument,
contents: "+ NEW",
- // HeadingObject: this.props.headingObject,
- // HeadingsHack: this._headingsHack
+ HeadingObject: this.props.headingObject,
+ HeadingsHack: this._headingsHack,
+ toggle: this.toggleVisibility,
+ color: this.props.color
};
- // let headingView = this.props.headingObject ?
let headingView =
<div>
- <div key={`${this.props.heading}`} className="collectionStackingView-sectionHeader" style={{ background: this.props.color }}
- onClick={action(() => {
- if (this.props.headingObject) {
- this._headingsHack++;
- this.props.headingObject.setCollapsed(!this.props.headingObject.collapsed);
- this.collapsed = !this.collapsed;
- console.log("value of collapse: " + this.collapsed);
- }
- })}
- >
- {this.props.heading}
+ <div className="collectionStackingView-sectionHeader">
<div className="collectionStackingView-sectionHeader-subCont" onPointerDown={this.headerDown}
title={evContents === `NO ${key.toUpperCase()} VALUE` ?
`Documents that don't have a ${key} value will go here. This column cannot be removed.` : ""}
@@ -324,7 +322,7 @@ export class CollectionMasonryViewFieldRow extends React.Component<CMVFieldRowPr
>
{headingView}
{this.collapsed ? (null) :
- <div>
+ < div >
<div key={`${heading}-stack`} className={`collectionStackingView-masonryGrid`}
style={{
padding: `${this.props.parent.yMargin}px ${this.props.parent.xMargin}px`,
diff --git a/src/client/views/collections/CollectionStackingView.tsx b/src/client/views/collections/CollectionStackingView.tsx
index 289c3a1fa..f0a8741af 100644
--- a/src/client/views/collections/CollectionStackingView.tsx
+++ b/src/client/views/collections/CollectionStackingView.tsx
@@ -286,49 +286,6 @@ export class CollectionStackingView extends CollectionSubView(doc => doc) {
translate(offset[0], offset[1]).
scale(NumCast(doc.width, 1) / this.columnWidth);
}
- // masonryChildren(docs: Doc[]) {
- // this._docXfs.length = 0;
- // return docs.map((d, i) => {
- // let dref = React.createRef<HTMLDivElement>();
- // let layoutDoc = Doc.expandTemplateLayout(d, this.props.DataDoc);
- // let width = () => (d.nativeWidth && !d.ignoreAspect && !this.props.Document.fillColumn ? Math.min(d[WidthSym](), this.columnWidth) : this.columnWidth);/// (uniqueHeadings.length + 1);
- // let height = () => this.getDocHeight(layoutDoc);
- // let dxf = () => this.getDocTransform(layoutDoc, dref.current!);
- // let rowSpan = Math.ceil((height() + this.gridGap) / this.gridGap);
- // this._docXfs.push({ dxf: dxf, width: width, height: height });
- // return <div className="collectionStackingView-masonryDoc" key={d[Id]} ref={dref} style={{ gridRowEnd: `span ${rowSpan}` }} >
- // {this.getDisplayDoc(layoutDoc, d, dxf, width)}
- // </div>;
- // });
- // }
-
- // @observable _headingsHack: number = 1;
- // sectionMasonry(heading: SchemaHeaderField | undefined, docList: Doc[]) {
- // let cols = Math.max(1, Math.min(docList.length,
- // Math.floor((this.props.PanelWidth() - 2 * this.xMargin) / (this.columnWidth + this.gridGap))));
- // // let specialCols = () => this.isMasonryView ? 1 : Math.max(1, Math.min(docList.length,
- // // Math.floor((this.props.PanelWidth() - 2 * this.xMargin) / (this.columnWidth + this.gridGap))));
- // // let type: "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" | undefined = undefined;
- // return <div ref={} key={heading ? heading.heading : "empty"} className="collectionStackingView-masonrySection">
- // {!heading ? (null) :
- // <div key={`${heading.heading}`} className="collectionStackingView-sectionHeader" style={{ background: heading.color }}
- // onClick={action(() => this._headingsHack++ && heading.setCollapsed(!heading.collapsed))} >
- // {heading.heading}
- // </div>}
- // {this._headingsHack && heading && heading.collapsed ? (null) :
- // <div key={`${heading}-stack`} className={`collectionStackingView-masonryGrid`}
- // style={{
- // padding: `${this.yMargin}px ${this.xMargin}px`,
- // width: `${cols * (this.columnWidth + this.gridGap) + 2 * this.xMargin - this.gridGap}px`,
- // gridGap: this.gridGap,
- // gridTemplateColumns: numberRange(cols).reduce((list, i) => list + ` ${this.columnWidth}px`, ""),
- // }}>
- // {this.masonryChildren(docList)}
- // {this.columnDragger}
- // </div>
- // }
- // </div>;
- // }
sectionMasonry = (heading: SchemaHeaderField | undefined, docList: Doc[]) => {
let key = this.sectionFilter;
diff --git a/src/client/views/collections/CollectionStackingViewFieldColumn.tsx b/src/client/views/collections/CollectionStackingViewFieldColumn.tsx
index a3db46584..01bfd813b 100644
--- a/src/client/views/collections/CollectionStackingViewFieldColumn.tsx
+++ b/src/client/views/collections/CollectionStackingViewFieldColumn.tsx
@@ -247,6 +247,14 @@ export class CollectionStackingViewFieldColumn extends React.Component<CSVFieldC
);
}
+ @observable private collapsed: boolean = false;
+
+ private toggleVisibility = action(() => {
+ this.collapsed = !this.collapsed;
+ });
+
+ @observable _headingsHack: number = 1;
+
render() {
let cols = this.props.cols();
let key = StrCast(this.props.parent.props.Document.sectionFilter);
@@ -261,12 +269,20 @@ export class CollectionStackingViewFieldColumn extends React.Component<CSVFieldC
GetValue: () => evContents,
SetValue: this.headingChanged,
contents: evContents,
- oneLine: true
+ oneLine: true,
+ HeadingObject: this.props.headingObject,
+ HeadingsHack: this._headingsHack,
+ toggle: this.toggleVisibility,
+ color: this._color
};
let newEditableViewProps = {
GetValue: () => "",
SetValue: this.addDocument,
- contents: "+ NEW"
+ contents: "+ NEW",
+ HeadingObject: this.props.headingObject,
+ HeadingsHack: this._headingsHack,
+ toggle: this.toggleVisibility,
+ color: this._color
};
let headingView = this.props.headingObject ?
<div key={heading} className="collectionStackingView-sectionHeader" ref={this._headerRef}
@@ -307,27 +323,31 @@ export class CollectionStackingViewFieldColumn extends React.Component<CSVFieldC
<div className="collectionStackingViewFieldColumn" key={heading} style={{ width: `${100 / ((uniqueHeadings.length + ((this.props.parent.props.CollectionView.props.Document.chromeStatus !== 'view-mode' && this.props.parent.props.CollectionView.props.Document.chromeStatus !== 'disabled') ? 1 : 0)) || 1)}%`, background: this._background }}
ref={this.createColumnDropRef} onPointerEnter={this.pointerEntered} onPointerLeave={this.pointerLeave}>
{headingView}
- <div key={`${heading}-stack`} className={`collectionStackingView-masonry${singleColumn ? "Single" : "Grid"}`}
- style={{
- padding: singleColumn ? `${style.yMargin}px ${0}px ${style.yMargin}px ${0}px` : `${style.yMargin}px ${0}px`,
- margin: "auto",
- width: "max-content", //singleColumn ? undefined : `${cols * (style.columnWidth + style.gridGap) + 2 * style.xMargin - style.gridGap}px`,
- height: 'max-content',
- position: "relative",
- gridGap: style.gridGap,
- gridTemplateColumns: singleColumn ? undefined : templatecols,
- gridAutoRows: singleColumn ? undefined : "0px"
- }}
- // ref={this.createColumnDropRef} onPointerEnter={this.pointerEntered} onPointerLeave={this.pointerLeave}
- >
- {this.children(this.props.docList)}
- {singleColumn ? (null) : this.props.parent.columnDragger}
- </div>
- {(this.props.parent.props.CollectionView.props.Document.chromeStatus !== 'view-mode' && this.props.parent.props.CollectionView.props.Document.chromeStatus !== 'disabled') ?
- <div key={`${heading}-add-document`} className="collectionStackingView-addDocumentButton"
- style={{ width: style.columnWidth / style.numGroupColumns }}>
- <EditableView {...newEditableViewProps} />
- </div> : null}
+ {this.collapsed ? (null) :
+ <div>
+ <div key={`${heading}-stack`} className={`collectionStackingView-masonry${singleColumn ? "Single" : "Grid"}`}
+ style={{
+ padding: singleColumn ? `${style.yMargin}px ${0}px ${style.yMargin}px ${0}px` : `${style.yMargin}px ${0}px`,
+ margin: "auto",
+ width: "max-content", //singleColumn ? undefined : `${cols * (style.columnWidth + style.gridGap) + 2 * style.xMargin - style.gridGap}px`,
+ height: 'max-content',
+ position: "relative",
+ gridGap: style.gridGap,
+ gridTemplateColumns: singleColumn ? undefined : templatecols,
+ gridAutoRows: singleColumn ? undefined : "0px"
+ }}
+ // ref={this.createColumnDropRef} onPointerEnter={this.pointerEntered} onPointerLeave={this.pointerLeave}
+ >
+ {this.children(this.props.docList)}
+ {singleColumn ? (null) : this.props.parent.columnDragger}
+ </div>
+ {(this.props.parent.props.CollectionView.props.Document.chromeStatus !== 'view-mode' && this.props.parent.props.CollectionView.props.Document.chromeStatus !== 'disabled') ?
+ <div key={`${heading}-add-document`} className="collectionStackingView-addDocumentButton"
+ style={{ width: style.columnWidth / style.numGroupColumns }}>
+ <EditableView {...newEditableViewProps} />
+ </div> : null}
+ </div>
+ }
</div>
);
}
diff --git a/src/new_fields/SchemaHeaderField.ts b/src/new_fields/SchemaHeaderField.ts
index 7494c9bd1..92d0aec9a 100644
--- a/src/new_fields/SchemaHeaderField.ts
+++ b/src/new_fields/SchemaHeaderField.ts
@@ -105,5 +105,4 @@ export class SchemaHeaderField extends ObjectField {
[ToScriptString]() {
return `invalid`;
}
-}
-
+} \ No newline at end of file