Skip to content

Commit 051439a

Browse files
committed
Merge branch 'dev' into mongo-pojo
2 parents bd9302a + f78e310 commit 051439a

File tree

8 files changed

+1107
-1060
lines changed

8 files changed

+1107
-1060
lines changed

i18n/english.yml

Lines changed: 362 additions & 364 deletions
Large diffs are not rendered by default.

i18n/espanol.yml

Lines changed: 331 additions & 332 deletions
Large diffs are not rendered by default.

i18n/francais.yml

Lines changed: 331 additions & 332 deletions
Large diffs are not rendered by default.

lib/common/util/config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export function getGtfsPlusSpec (): Array<GtfsPlusTable> {
1414

1515
export function getComponentMessages (componentName: string): any {
1616
return (
17-
objectPath.get(window.DT_CONFIG, ['messages', 'active', componentName]) ||
17+
objectPath.get(window.DT_CONFIG, ['messages', 'active', 'components', componentName]) ||
1818
{}
1919
)
2020
}
@@ -65,7 +65,7 @@ export function initializeConfig () {
6565
: navigator.language
6666

6767
config.messages.active =
68-
lang.find(l => l.id === languageId) || lang.find(l => l.id === 'en-US')
68+
lang.find(l => l._id === languageId) || lang.find(l => l._id === 'en-US')
6969

7070
// console.log('config', config)
7171
window.DT_CONFIG = config

lib/editor/components/timetable/EditableCell.js

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -298,24 +298,10 @@ export default class EditableCell extends Component {
298298
const focusedNotEditing = this.props.isFocused && !this.state.isEditing
299299
const edgeDiff = this.props.isFocused ? 0 : 0.5
300300
const divStyle = {
301-
height: '100%',
302-
display: 'inline-block',
303301
paddingTop: `${3 + edgeDiff}px`,
304302
paddingLeft: `${3 + edgeDiff}px`,
305-
UserSelect: 'none',
306-
userSelect: 'none',
307303
fontWeight: this.state.edited ? 'bold' : 'normal'
308304
}
309-
const inputStyle = {
310-
width: '100%',
311-
height: '100%',
312-
outline: 'none',
313-
margin: '1px',
314-
marginLeft: '2px',
315-
padding: '1px',
316-
border: 0,
317-
backgroundColor: 'rgba(0,0,0,0)'
318-
}
319305
const cellStyle = {
320306
backgroundColor: this.props.invalidData && !this.state.isEditing
321307
? 'pink'
@@ -333,27 +319,25 @@ export default class EditableCell extends Component {
333319
: '1px solid #ddd',
334320
margin: `${-0.5 + edgeDiff}px`,
335321
padding: `${-edgeDiff}px`,
336-
whiteSpace: 'nowrap',
337-
cursor: 'default',
338-
fontWeight: '400',
339322
// fontFamily: '"Courier New", Courier, monospace',
340323
color: this.props.lightText ? '#aaa' : '#000',
341324
...this.props.style
342325
}
343326
const cellHtml = this.state.isEditing
344327
? <input
345-
type='text'
346-
ref={this._createRef}
347-
readOnly={!this.state.isEditing}
348328
defaultValue={this.cellRenderer(this.state.data)}
349-
placeholder={this.props.placeholder || ''}
350-
onPaste={this.handlePaste}
351-
style={inputStyle}
352-
onKeyDown={this.handleKeyDown}
329+
className='cell-input'
330+
onBlur={this.cancel}
353331
onChange={this.handleChange}
354332
onFocus={this._onInputFocus}
355-
onBlur={this.cancel} />
333+
onKeyDown={this.handleKeyDown}
334+
onPaste={this.handlePaste}
335+
placeholder={this.props.placeholder || ''}
336+
readOnly={!this.state.isEditing}
337+
ref={this._createRef}
338+
type='text' />
356339
: <div
340+
className='cell-div noselect'
357341
style={divStyle}
358342
>
359343
{this.cellRenderer(this.state.data)}

lib/editor/components/timetable/TimetableGrid.js

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,43 @@ export default class TimetableGrid extends Component {
271271
)
272272
}
273273

274+
/**
275+
* Handle a change in the value of a cell.
276+
*
277+
* This function gets called with a post-processed value from the `save`
278+
* method of EditableCell. The value can be a time value or non-time entry
279+
* such as Trip Id or Headsign.
280+
*/
274281
_onCellChange = (value, rowIndex, col, colIndex) => {
275-
const {columns, hideDepartureTimes, updateCellValue} = this.props
282+
const {
283+
activePattern,
284+
columns,
285+
data,
286+
hideDepartureTimes,
287+
updateCellValue
288+
} = this.props
289+
290+
// determine if the value is a time entry
291+
if (isTimeFormat(col.type)) {
292+
// make sure stop time isn't null
293+
const splitColKeys = col.key.split('.')
294+
const stopTimeIdx = splitColKeys[1]
295+
const trip = data[rowIndex]
296+
const stopTime = trip.stopTimes[stopTimeIdx]
297+
if (!stopTime) {
298+
// stop time is null. Create new stop time
299+
300+
// get stop id from pattern
301+
const {stopId} = activePattern.patternStops[stopTimeIdx]
302+
303+
// create filler stop time object
304+
updateCellValue(
305+
{ stopId },
306+
rowIndex,
307+
`${rowIndex}.stopTimes.${stopTimeIdx}`
308+
)
309+
}
310+
}
276311
updateCellValue(value, rowIndex, `${rowIndex}.${col.key}`)
277312
// if departure times are hidden, set departure time value equal to arrival time
278313
const nextCol = columns[colIndex + 1]

lib/editor/util/index.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,22 @@ export function sortAndFilterTrips (
134134
? trips
135135
.filter(t => t.useFrequency === useFrequency) // filter out based on useFrequency
136136
.sort((a, b) => {
137-
if (!a.stopTimes[0].departureTime || !b.stopTimes[0].departureTime) {
137+
// There may be a case where a null value (skipped stop) appears first
138+
// in the list of stopTimes. In this case, we want to compare on the
139+
// first stopTime that exists for each pair of trips.
140+
let aStopTime, bStopTime
141+
let count = 0
142+
while (!aStopTime || !bStopTime) {
143+
aStopTime = a.stopTimes[count]
144+
bStopTime = b.stopTimes[count]
145+
count++
146+
}
147+
if (!aStopTime.departureTime || !bStopTime.departureTime) {
138148
return 0
139-
} else if (a.stopTimes[0].departureTime < b.stopTimes[0].departureTime) {
149+
} else if (aStopTime.departureTime < bStopTime.departureTime) {
140150
return -1
141151
} else if (
142-
a.stopTimes[0].departureTime > b.stopTimes[0].departureTime
152+
aStopTime.departureTime > bStopTime.departureTime
143153
) {
144154
return 1
145155
}

lib/style.css

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,31 @@
154154

155155
/* TIMETABLE EDITOR */
156156

157+
.editable-cell {
158+
cursor: default;
159+
font-weight: 400;
160+
white-space: nowrap;
161+
}
162+
157163
/* remove blue focus outline from timetable cell */
158164
.editable-cell:focus {
159-
outline:0;
165+
outline: 0;
166+
}
167+
168+
.editable-cell .cell-input {
169+
background-color: rgba(0,0,0,0);
170+
border: 0;
171+
height: 100%;
172+
width: 100%;
173+
margin: 1px;
174+
margin-left: 2px;
175+
outline: none;
176+
padding: 1px;
177+
}
178+
179+
.editable-cell .cell-div {
180+
display: inline-block;
181+
height: 100%;
160182
}
161183

162184
/* Bootstrap button dropdown fix for menu showing up underneath leaflet zoom controls */

0 commit comments

Comments
 (0)