@@ -30,6 +30,7 @@ export default class TimetableGrid extends Component {
3030 static propTypes = {
3131 updateCellValue : PropTypes . func ,
3232 toggleAllRows : PropTypes . func ,
33+ saveEditedTrips : PropTypes . func ,
3334 selected : PropTypes . array ,
3435 toggleRowSelection : PropTypes . func
3536 }
@@ -50,7 +51,10 @@ export default class TimetableGrid extends Component {
5051 handleKeyPress = ( evt ) => {
5152 const {
5253 activeCell,
54+ activePattern,
55+ activeScheduleId,
5356 data,
57+ saveEditedTrips,
5458 setActiveCell,
5559 scrollToColumn,
5660 scrollToRow,
@@ -67,7 +71,14 @@ export default class TimetableGrid extends Component {
6771 break
6872 case 13 : // Enter
6973 if ( ! activeCell ) {
70- return setActiveCell ( `${ scrollToRow } -${ scrollToColumn } ` )
74+ if ( evt . metaKey || evt . ctrlKey ) {
75+ // If Enter is pressed with CTRL or CMD and no cell is active, save
76+ // any unsaved trips.
77+ return saveEditedTrips ( activePattern , activeScheduleId )
78+ } else {
79+ // Otherwise, set active cell
80+ return setActiveCell ( `${ scrollToRow } -${ scrollToColumn } ` )
81+ }
7182 } else {
7283 return setActiveCell ( null )
7384 }
@@ -242,6 +253,7 @@ export default class TimetableGrid extends Component {
242253 ( selected [ 0 ] !== '*' && selected . indexOf ( rowIndex ) !== - 1 )
243254
244255 let val = objectPath . get ( data [ rowIndex ] , col . key )
256+ // console.log(val, data[rowIndex], col.key)
245257 if ( col . key === 'tripId' && val === null ) {
246258 val = objectPath . get ( data [ rowIndex ] , 'id' ) !== ENTITY . NEW_ID ? objectPath . get ( data [ rowIndex ] , 'id' ) : null
247259 }
0 commit comments