Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurkushman committed Mar 29, 2017
2 parents c26c871 + be1ae33 commit e02098e
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 2 deletions.
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,23 @@ and then pass variable (in this case - editor) to GigaTables main options in tab
}
```
That's it then You will be able to CRUD any record You want :-)
That's it then You will be able to CRUD any record You want.
## Hot keys
To efficiently manage table behavior You can use the following hot keys:
- Ctrl+Arrow Up - selects rows above the selected
- Ctrl+Arrow Down - selects rows below the selected
- Ctrl+A - selects all rows in a current table view
- Ctrl+Arrow Right - next page
- Ctrl+Arrow Left - prev page
PS In some OS like Macintosh can be default conflicting hot keys, ex.: Cmd+Arrow Left get back in browsers
## FAQ
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gigatables-react",
"version": "1.1.9",
"version": "1.2.0",
"description": "GigaTables is a ReactJS plug-in to help web-developers process table-data in applications and CMS, CRM, ERP or similar systems. It supports ajax data processing/editing (CRUD), pagination, cross-sorting, global search, shft/ctrl rows selection, 7 popular languages and more.",
"main": "./build/index.js",
"dependencies": {
Expand Down
23 changes: 23 additions & 0 deletions src/Reactables.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ class Reactables extends Main {
shiftDown: false,
arrowDown: false,
arrowUp: false,
arrowLeft: false,
arrowRight: false,
minRow: 0,
maxRow: 0,
opacity: 0,
Expand Down Expand Up @@ -136,13 +138,24 @@ class Reactables extends Main {
arrowDown: true
});
break;
case CommonConstants.ARROW_LEFT:
that.setState({
arrowLeft: true
});
break;
case CommonConstants.ARROW_RIGHT:
that.setState({
arrowRight: true
});
break;
case CommonConstants.A_KEY:
that.setState({
aDown: true
});
break;
}
that.addSelectedRows();
that.setPagination();
});
// disabling keys
document.addEventListener('keyup', (e) => {
Expand Down Expand Up @@ -177,6 +190,16 @@ class Reactables extends Main {
arrowDown: false
});
break;
case CommonConstants.ARROW_LEFT:
that.setState({
arrowLeft: false
});
break;
case CommonConstants.ARROW_RIGHT:
that.setState({
arrowRight: false
});
break;
case CommonConstants.A_KEY:
that.setState({
aDown: false
Expand Down
2 changes: 2 additions & 0 deletions src/components/CommonConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ module.exports = {
DELETE_KEY: 46,
ARROW_UP: 38,
ARROW_DOWN: 40,
ARROW_LEFT: 37,
ARROW_RIGHT: 39,
SYMBOLLESS_KEYS: [
16, // SHIFT
13, // ENTER
Expand Down
47 changes: 47 additions & 0 deletions src/components/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,7 @@ class Main extends React.Component {
perPage,
aDown
} = this.state;

if (shiftDown === true && arrowUp === true && selectedRows.length > 0) {
let min = Math.min(...selectedRows),
rows = selectedRows;
Expand Down Expand Up @@ -674,6 +675,52 @@ class Main extends React.Component {
}
}

setPagination()
{
const {
ctrlDown,
arrowLeft,
arrowRight,
fromRow,
page,
perPage,
countRows
} = this.state;

// let fromRow = parseInt(fromRow);
if (ctrlDown === true && arrowLeft === true) {
if (page === 1) {
let pages = Math.ceil(countRows / perPage);
this.setState({
fromRow: (pages - 1) * perPage,
page: pages,
arrowLeft: false
}, () => {this.createTable(this.jsonData, this.state.sortedButtons)});
} else {
this.setState({
fromRow: (page - 1) * perPage,
page: page - 1,
arrowLeft: false
}, () => {this.createTable(this.jsonData, this.state.sortedButtons)});
}
} else if (ctrlDown === true && arrowRight === true) {
let pages = Math.ceil(countRows / perPage);
if (page === pages) {
this.setState({
fromRow: 0,
page: 1,
arrowRight: false
}, () => {this.createTable(this.jsonData, this.state.sortedButtons)});
} else {
this.setState({
fromRow: page * perPage,
page: page + 1,
arrowRight: false
}, () => {this.createTable(this.jsonData, this.state.sortedButtons)});
}
}
}

}

export default Main

0 comments on commit e02098e

Please sign in to comment.