aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/CollectionViewChromes.tsx
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/client/views/collections/CollectionViewChromes.tsx
parent28388e57564accf6ba3758b475144a78c2774458 (diff)
added grid ref and fixed css
Diffstat (limited to 'src/client/views/collections/CollectionViewChromes.tsx')
-rw-r--r--src/client/views/collections/CollectionViewChromes.tsx41
1 files changed, 22 insertions, 19 deletions
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>
);