Skip to content

Commit

Permalink
Merge pull request #1013 from ibi-group/timetable-new-features
Browse files Browse the repository at this point in the history
Support copy from right in timetable editor
  • Loading branch information
miles-grant-ibigroup authored Jan 7, 2025
2 parents d51634b + 1551753 commit f044bbb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions i18n/english.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1295,6 +1295,7 @@ components:
- New trip
- Clone selected trip(s)
- Copy time value from adjacent cell (the cell immediately to the left)
- Copy time value from adjacent cell (the cell immediately to the right)
- Copy value from cell directly above
title: Timetable editor keyboard shortcuts
TimezoneSelect:
Expand Down
13 changes: 12 additions & 1 deletion lib/editor/components/timetable/TimetableGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,25 @@ export default class TimetableGrid extends Component<Props> {
case 222: { // single quote
// Set current cell's value to adjacent cell's (leftward) value.
const adjacentCol = columns[this._getColIndex(scrollToColumn) - 1]
if (evt.shiftKey && !activeCell && isTimeFormat(adjacentCol.type)) {
if (evt.shiftKey && !activeCell && adjacentCol && isTimeFormat(adjacentCol.type) && isTimeFormat(col.type)) {
const value = objectPath.get(data[scrollToRow], adjacentCol.key)
this._handleCellChange(value, scrollToRow, col, scrollToColumn)
this.offsetScrollCol(1)
return false
}
break
}
case 76: { // l
// Set current cell's value to adjacent cell's (rightward) value.
const adjacentCol = columns[this._getColIndex(scrollToColumn) + 1]
if (evt.shiftKey && !activeCell && adjacentCol && isTimeFormat(adjacentCol.type) && isTimeFormat(col.type)) {
const value = objectPath.get(data[scrollToRow], adjacentCol.key)
this._handleCellChange(value, scrollToRow, col, scrollToColumn)
this.offsetScrollCol(-1)
return false
}
break
}
case 186: { // semi-colon
// Set current cell's value to above cell's value.
const previousRowIndex = scrollToRow - 1
Expand Down
2 changes: 1 addition & 1 deletion lib/editor/util/timetable.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { EXCEPTION_EXEMPLARS } from '.'
export const SHORTCUTS = {
offset: ['o', 'SHIFT:+:o', 'i', 'SHIFT:+:i', '-', 'SHIFT:+:-', '+', 'SHIFT:+:+'],
navigate: ['k:/:j', '←:/:→', 'x', 'a', 'd'],
modify: ['#', 'n', 'c', 'SHIFT:+:\'', 'SHIFT:+:;']
modify: ['#', 'n', 'c', 'SHIFT:+:\'', 'SHIFT:+:l', 'SHIFT:+:;']
}

/**
Expand Down

0 comments on commit f044bbb

Please sign in to comment.