aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorusodhi <61431818+usodhi@users.noreply.github.com>2020-06-01 10:06:31 +0530
committerusodhi <61431818+usodhi@users.noreply.github.com>2020-06-01 10:06:31 +0530
commit85553878a01877efb9e9d3b748064db66a6d8e30 (patch)
tree37b16df637ed7d5bfbb6eff392f57c25f2d125aa /src
parent28388e57564accf6ba3758b475144a78c2774458 (diff)
added grid ref and fixed css
Diffstat (limited to 'src')
-rw-r--r--src/client/views/collections/CollectionViewChromes.scss23
-rw-r--r--src/client/views/collections/CollectionViewChromes.tsx41
-rw-r--r--src/client/views/collections/collectionGrid/CollectionGridView.scss43
-rw-r--r--src/client/views/collections/collectionGrid/CollectionGridView.tsx37
-rw-r--r--src/client/views/collections/collectionGrid/Grid.tsx9
5 files changed, 95 insertions, 58 deletions
diff --git a/src/client/views/collections/CollectionViewChromes.scss b/src/client/views/collections/CollectionViewChromes.scss
index 9795a3a22..910c14060 100644
--- a/src/client/views/collections/CollectionViewChromes.scss
+++ b/src/client/views/collections/CollectionViewChromes.scss
@@ -164,13 +164,31 @@
}
}
-
.collectionStackingViewChrome-cont,
.collectionTreeViewChrome-cont {
display: flex;
justify-content: space-between;
}
+ .collectionGridViewChrome-cont {
+ display: flex;
+ margin-left: 10;
+
+ .grid-control {
+ align-self: center;
+ width: 30%;
+
+ .grid-icon {
+ margin-right: 5px;
+ }
+ }
+
+ .collectionGridViewChrome-entryBox {
+ width: 50%;
+ }
+ }
+
+
.collectionStackingViewChrome-sort,
.collectionTreeViewChrome-sort {
display: flex;
@@ -238,9 +256,6 @@
cursor: text;
}
- .collectionGridViewChrome-entryBox {
- width: 50%;
- }
}
}
diff --git a/src/client/views/collections/CollectionViewChromes.tsx b/src/client/views/collections/CollectionViewChromes.tsx
index 2bffbdf7d..9423e417d 100644
--- a/src/client/views/collections/CollectionViewChromes.tsx
+++ b/src/client/views/collections/CollectionViewChromes.tsx
@@ -15,8 +15,6 @@ import { COLLECTION_BORDER_WIDTH } from "../globalCssVariables.scss";
import { CollectionViewType } from "./CollectionView";
import { CollectionView } from "./CollectionView";
import "./CollectionViewChromes.scss";
-import { CollectionGridView } from "./collectionGrid/CollectionGridView";
-import HeightLabel from "./collectionMulticolumn/MultirowHeightLabel";
const datepicker = require('js-datepicker');
interface CollectionViewChromeProps {
@@ -516,10 +514,10 @@ export class CollectionGridViewChrome extends React.Component<CollectionViewChro
/**
* Sets the value of `numCols` on the grid's Document to the value entered.
*/
- @action
+ @undoBatch
onNumColsEnter = (e: React.KeyboardEvent<HTMLInputElement>) => {
if (e.key === "Enter" || e.key === "Tab") {
- if (this.props.CollectionView.props.Document.numCols as number !== e.currentTarget.valueAsNumber) {
+ if (e.currentTarget.valueAsNumber > 0 && this.props.CollectionView.props.Document.numCols as number !== e.currentTarget.valueAsNumber) {
this.props.CollectionView.props.Document.numCols = e.currentTarget.valueAsNumber;
//this.props.CollectionView.forceUpdate(); // to be used if CollectionGridView is not an observer
}
@@ -530,39 +528,44 @@ export class CollectionGridViewChrome extends React.Component<CollectionViewChro
/**
* Sets the value of `rowHeight` on the grid's Document to the value entered.
*/
- @action
+ @undoBatch
onRowHeightEnter = (e: React.KeyboardEvent<HTMLInputElement>) => {
if (e.key === "Enter" || e.key === "Tab") {
- if (this.props.CollectionView.props.Document.rowHeight as number !== e.currentTarget.valueAsNumber) {
+ if (e.currentTarget.valueAsNumber > 0 && this.props.CollectionView.props.Document.rowHeight as number !== e.currentTarget.valueAsNumber) {
this.props.CollectionView.props.Document.rowHeight = e.currentTarget.valueAsNumber;
- //this.props.CollectionView.forceUpdate();
}
}
}
- onCheck = (event: React.ChangeEvent<HTMLInputElement>) => this.props.CollectionView.props.Document.flexGrid = event.target.checked;
+ /**
+ * Sets whether the grid is flexible or not on the grid's Document.
+ */
+ @undoBatch
+ toggleFlex = () => {
+ this.props.CollectionView.props.Document.flexGrid = !this.props.CollectionView.props.Document.flexGrid;
+ }
render() {
return (
- <div className="collectionTreeViewChrome-cont">
- <span className={"search-icon"}>
- <span className="icon-background">
+ <div className="collectionGridViewChrome-cont">
+ <span className={"grid-control"}>
+ <span className="grid-icon">
<FontAwesomeIcon icon="columns" size="1x" />
</span>
- <input className="collectionGridViewChrome-entryBox" type="number" placeholder={this.props.CollectionView.props.Document.numCols as string} onKeyDown={this.onNumColsEnter} autoFocus />
+ <input className="collectionGridViewChrome-entryBox" type="number" placeholder={this.props.CollectionView.props.Document.numCols as string} onKeyDown={this.onNumColsEnter} onClick={(e: React.MouseEvent<HTMLInputElement, MouseEvent>) => e.currentTarget.focus()} />
</span>
- <span className={"search-icon"}>
- <span className="icon-background">
+ <span className={"grid-control"}>
+ <span className="grid-icon">
<FontAwesomeIcon icon="text-height" size="1x" />
</span>
- <input className="collectionGridViewChrome-entryBox" type="number" placeholder={this.props.CollectionView.props.Document.rowHeight as string} onKeyDown={this.onRowHeightEnter} />
+ <input className="collectionGridViewChrome-entryBox" type="number" placeholder={this.props.CollectionView.props.Document.rowHeight as string} onKeyDown={this.onRowHeightEnter} onClick={(e: React.MouseEvent<HTMLInputElement, MouseEvent>) => e.currentTarget.focus()} />
</span>
- <span className={"search-icon"}>
- <span className="icon-background">
+ <span className={"grid-control"}>
+ <input style={{ marginRight: 5 }} type="checkbox" onClick={this.toggleFlex} defaultChecked={this.props.CollectionView.props.Document.flexGrid as boolean} />
+ <span className="grid-icon">
<FontAwesomeIcon icon="arrow-up" size="1x" />
</span>
- <input type="checkbox" onChange={this.onCheck} defaultChecked={this.props.CollectionView.props.Document.flexGrid as boolean} />
- <label>Flexible Grid</label>
+ <label>Flexible</label>
</span>
</div>
);
diff --git a/src/client/views/collections/collectionGrid/CollectionGridView.scss b/src/client/views/collections/collectionGrid/CollectionGridView.scss
index b88721b4d..49d463441 100644
--- a/src/client/views/collections/collectionGrid/CollectionGridView.scss
+++ b/src/client/views/collections/collectionGrid/CollectionGridView.scss
@@ -1,14 +1,4 @@
-// .react-grid-layout.layout {
-// // max-height: 100%;// min-height: 100%;
-// overflow-y: auto;
-// }
-
-// .collectionView {// background-color: white;
-// overflow-y: scroll;
-// }
-
-
-.collectionGridView_contents {
+.collectionGridView-contents {
display: flex;
overflow: hidden;
width: 100%;
@@ -16,13 +6,32 @@
flex-direction: column;
}
-.collectionGridView_contents .document-wrapper {
- display: flex;
- flex-direction: column;
- width: 100%;
+.collectionGridView-contents .collectionGridView-gridContainer {
height: 100%;
+ overflow-y: auto;
+ background-color: white;
+}
+
+.documentDecorations-container .documentDecorations-resizer {
+ pointer-events: none;
+
+}
+
+#documentDecorations-bottomRightResizer,
+#documentDecorations-bottomLeftResizer,
+#documentDecorations-topRightResizer,
+#documentDecorations-topLeftResizer {
+ visibility: collapse;
+}
+
+/* Chrome, Safari, Edge, Opera */
+input::-webkit-outer-spin-button,
+input::-webkit-inner-spin-button {
+ -webkit-appearance: none;
+ margin: 0;
}
-.react-grid-layout.layout {
- height: 100%
+/* Firefox */
+input[type=number] {
+ -moz-appearance: textfield;
} \ No newline at end of file
diff --git a/src/client/views/collections/collectionGrid/CollectionGridView.tsx b/src/client/views/collections/collectionGrid/CollectionGridView.tsx
index 111ce4beb..5eeaa9b0d 100644
--- a/src/client/views/collections/collectionGrid/CollectionGridView.tsx
+++ b/src/client/views/collections/collectionGrid/CollectionGridView.tsx
@@ -1,4 +1,4 @@
-import { computed, observable } from 'mobx';
+import { computed, observable, action } from 'mobx';
import * as React from "react";
import { Doc, DocListCast } from '../../../../fields/Doc';
import { documentSchema } from '../../../../fields/documentSchemas';
@@ -23,6 +23,8 @@ const GridSchema = makeInterface(documentSchema);
@observer
export class CollectionGridView extends CollectionSubView(GridSchema) {
+ private containerRef: React.RefObject<HTMLDivElement>;
+ @observable private _scroll: number = 0;
constructor(props: Readonly<SubCollectionViewProps>) {
super(props);
@@ -33,6 +35,8 @@ export class CollectionGridView extends CollectionSubView(GridSchema) {
this.setLayout = this.setLayout.bind(this);
this.deleteInContext = this.deleteInContext.bind(this);
+
+ this.containerRef = React.createRef();
}
componentDidMount() {
@@ -66,7 +70,8 @@ export class CollectionGridView extends CollectionSubView(GridSchema) {
* documents before the target.
*/
private lookupIndividualTransform = (doc: Doc) => {
- const yTranslation = this.rowHeightPlusGap * NumCast(doc.y) + 10;
+ const yTranslation = this.rowHeightPlusGap * NumCast(doc.y) + 10 - this._scroll;
+ console.log("CollectionGridView -> privatelookupIndividualTransform -> this.containerRef.current!.scrollTop", this.containerRef.current!.scrollTop)
const xTranslation = this.colWidthPlusGap * NumCast(doc.x) + 10;
return this.props.ScreenToLocalTransform().translate(-xTranslation, -yTranslation);
}
@@ -113,7 +118,7 @@ export class CollectionGridView extends CollectionSubView(GridSchema) {
onClick={this.onChildClickHandler}
renderDepth={this.props.renderDepth + 1}
parentActive={this.props.active}
- display={"contents"}
+ display={"contents"} // this causes an issue- this is the reason the decorations box is weird with images and web boxes
removeDocument={this.deleteInContext}
/>;
}
@@ -291,17 +296,21 @@ export class CollectionGridView extends CollectionSubView(GridSchema) {
ref={this.createDashEventsTarget}
onPointerDown={e => { ((e.target as any)?.className.includes("react-resizable-handle")) && e.stopPropagation(); }} // the grid doesn't stopPropagation when its widgets are hit, so we need to otherwise the outer documents will respond
>
- DIV HERE with ref to access scroll of and adjust in getting position
- <Grid
- width={this.props.PanelWidth()}
- nodeList={contents}
- layout={layout}
- numCols={this.props.Document.numCols as number}
- rowHeight={this.props.Document.rowHeight as number}
- setLayout={this.setLayout}
- flex={this.props.Document.flexGrid as boolean}
- scale={this.props.ScreenToLocalTransform().Scale}
- />
+ <div className="collectionGridView-gridContainer"
+ ref={this.containerRef}
+ onScroll={action((e: React.UIEvent<HTMLDivElement>) => this._scroll = e.currentTarget.scrollTop)}
+ >
+ <Grid
+ width={this.props.PanelWidth()}
+ nodeList={contents}
+ layout={layout}
+ numCols={this.props.Document.numCols as number}
+ rowHeight={this.props.Document.rowHeight as number}
+ setLayout={this.setLayout}
+ flex={this.props.Document.flexGrid as boolean}
+ scale={this.props.ScreenToLocalTransform().Scale}
+ />
+ </div>
</div>
);
}
diff --git a/src/client/views/collections/collectionGrid/Grid.tsx b/src/client/views/collections/collectionGrid/Grid.tsx
index 673f670a6..be6c4343a 100644
--- a/src/client/views/collections/collectionGrid/Grid.tsx
+++ b/src/client/views/collections/collectionGrid/Grid.tsx
@@ -26,9 +26,11 @@ interface GridProps {
*/
@observer
export default class Grid extends React.Component<GridProps> {
+ gridRef: React.RefObject<HTMLDivElement>;
constructor(props: Readonly<GridProps>) {
super(props);
+ this.gridRef = React.createRef();
this.onLayoutChange = this.onLayoutChange.bind(this);
}
@@ -50,13 +52,12 @@ export default class Grid extends React.Component<GridProps> {
width={this.props.width}
compactType={null}
isDroppable={true}
- useCSSTransforms={true}
+ // useCSSTransforms={true}
margin={[10, 10]}
onLayoutChange={this.onLayoutChange}
preventCollision={false} // change this to true later
- transformScale={0.8} // 1.2/scale
- style={{ height: "100%", overflowY: "scroll" }}
- // draggableHandle={".documentDecorations-resizer"}
+ // transformScale={2} // 1.2/scale
+ onDrop={({ x, y, e }) => { console.log("Grid -> render -> x, y, e", x, y, e) }}
>
{this.props.nodeList}
</GridLayout >