Skip to content
This repository has been archived by the owner on Dec 13, 2020. It is now read-only.

Commit

Permalink
Merge pull request #1034 from metasfresh/dev-999
Browse files Browse the repository at this point in the history
grid view: use keyboard + and - to expand/collapse included rows #999
  • Loading branch information
cadavre committed Jul 17, 2017
2 parents bdbaf24 + b7ad2ba commit db9289a
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 6 deletions.
17 changes: 12 additions & 5 deletions src/components/shortcuts/DocumentListContextShortcuts.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ class DocumentListContextShortcuts extends Component {
}
handleShortcuts = (action, event) => {
const {
handleAdvancedEdit, handleOpenNewTab, handleDelete, getAllLeafs
handleAdvancedEdit, handleOpenNewTab, handleDelete, getAllLeafs,
handleIndent
} = this.props;

switch (action) {
Expand All @@ -16,23 +17,29 @@ class DocumentListContextShortcuts extends Component {
if(handleOpenNewTab) {
handleOpenNewTab();
}
break
break;
case 'REMOVE_SELECTED':
event.preventDefault();
if(handleDelete){
handleDelete();
}
break
break;
case 'ADVANCED_EDIT':
event.preventDefault();
if(handleAdvancedEdit){
handleAdvancedEdit();
}
break
break;
case 'SELECT_ALL_LEAFS':
event.preventDefault();
getAllLeafs();
break
break;
case 'EXPAND_INDENT':
handleIndent(true);
break;
case 'COLLAPSE_INDENT':
handleIndent(false);
break;
}
}

Expand Down
27 changes: 27 additions & 0 deletions src/components/table/Table.js
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,31 @@ class Table extends Component {
})
}

handleShortcutIndent = (expand) => {
const {selected, rows, collapsedParentsRows} = this.state;
const {keyProperty} = this.props;

let node = "";
let isCollapsed = "";
selected.length === 1 && rows.map((item)=>{
if(item.id === selected[0]){
if(item.includedDocuments){
node = item;
isCollapsed = collapsedParentsRows.indexOf(item[keyProperty]) > -1;
}
}
});

if(node){
if(isCollapsed && expand) {
this.handleRowCollapse(node, expand);
} else if(!isCollapsed && !expand) {
this.handleRowCollapse(node, expand);
}
}

}

renderTableBody = () => {
const {
tabid, cols, type, docId, readonly, keyProperty, onDoubleClick,
Expand Down Expand Up @@ -917,6 +942,8 @@ class Table extends Component {
() => this.handleDelete() : ''
}
getAllLeafs={this.getAllLeafs}

handleIndent = {this.handleShortcutIndent}
/>

{!readonly &&
Expand Down
4 changes: 3 additions & 1 deletion src/keymap.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ export default {
REMOVE_SELECTED: mod + '+' + 'y',
ADVANCED_EDIT: mod + '+' + 'a',
//=================== POS ======================
SELECT_ALL_LEAFS: mod + '+' + 's'
SELECT_ALL_LEAFS: mod + '+' + 's',
EXPAND_INDENT: '+',
COLLAPSE_INDENT: '-'

},
TABLE_CONTEXT: {
Expand Down

0 comments on commit db9289a

Please sign in to comment.