Skip to content

Commit

Permalink
inital flow type fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-heppner-ibigroup committed Oct 16, 2024
1 parent 0c34d0d commit e5ec45b
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 14 deletions.
1 change: 1 addition & 0 deletions lib/editor/components/EditorInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ export default class EditorInput extends React.Component<Props> {
onChange={this._onHourMinuteInputChange}
seconds={value && value * 60}
standaloneInput
showSeconds={false}
/>
</FormGroup>
)
Expand Down
6 changes: 4 additions & 2 deletions lib/editor/components/EntityDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import * as mapActions from '../actions/map'
import ActiveTripPatternList from '../containers/ActiveTripPatternList'
import { getZones, getEditorTable, canApproveGtfs } from '../util'
import { getTableById } from '../util/gtfs'
import type {Entity, Feed, GtfsSpecField, GtfsStop, GtfsLocation, GtfsLocationGroup, Pattern, Project} from '../../types'
import type {Entity, Feed, GtfsSpecField, GtfsStop, GtfsLocation, Pattern, Project} from '../../types'
import type {EditorTables, ManagerUserState, MapState} from '../../types/reducers'
import type {EditorValidationIssue} from '../util/validation/common'

Expand All @@ -25,7 +25,9 @@ type Props = {
activeEntity: Entity,
activeEntityId: number,
activePattern: Pattern,
activePatternStops: Array<GtfsStop | GtfsLocation | GtfsLocationGroup>,
activePatternLocationGroups: Array<GtfsLocation>,
activePatternLocations: Array<GtfsLocation>,
activePatternStops: Array<GtfsStop>,
deleteEntity: typeof activeActions.deleteGtfsEntity,
entities: Array<Entity>,
entityEdited: boolean,
Expand Down
2 changes: 1 addition & 1 deletion lib/editor/components/ExceptionDate.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {toast} from 'react-toastify'

import {updateActiveGtfsEntity} from '../actions/active'
import type {ScheduleException} from '../../types'
import type {EditorValidationIssue} from '../util/validation'
import type {EditorValidationIssue} from '../util/validation/common'
import { getComponentMessages } from '../../common/util/config'

import {sortDates} from './ExceptionDateRange'
Expand Down
2 changes: 1 addition & 1 deletion lib/editor/components/ExceptionDateRange.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {updateActiveGtfsEntity} from '../actions/active'
import { getComponentMessages } from '../../common/util/config'
import {modifyRangeOfDates, updateDates} from '../../common/util/exceptions'
import type {ExceptionDate, ScheduleException, ScheduleExceptionDateRange} from '../../types'
import type {EditorValidationIssue} from '../util/validation'
import type {EditorValidationIssue} from '../util/validation/common'

import {inputStyleProps} from './ExceptionDate'
import ExceptionValidationErrorsList from './ExceptionValidationErrorsList'
Expand Down
2 changes: 1 addition & 1 deletion lib/editor/components/ExceptionValidationErrorsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import React from 'react'

import { getComponentMessages } from '../../common/util/config'
import type { EditorValidationIssue } from '../util/validation'
import type { EditorValidationIssue } from '../util/validation/common'

const VALIDATION_ERROR_LIMIT = 3

Expand Down
8 changes: 4 additions & 4 deletions lib/editor/components/map/PatternLocationMarker.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default class PatternLocationMarker extends Component<Props> {

_onChangeTimeInLocation = (value: number) => {
const {activePattern, index, updatePatternStops} = this.props
const patternStops = {activePattern}
const { patternStops } = activePattern
if (patternStops[index].hasOwnProperty('defaultDwellTime')) {
patternStops[index].defaultDwellTime = value
updatePatternStops(activePattern, patternStops)
Expand All @@ -61,7 +61,7 @@ export default class PatternLocationMarker extends Component<Props> {

_onChangeTravelTime = (value: number) => {
const {activePattern, index, updatePatternStops} = this.props
const patternStops = {activePattern}
const { patternStops } = activePattern
if (patternStops[index].hasOwnProperty('defaultTravelTime')) {
patternStops[index].defaultTravelTime = value
updatePatternStops(activePattern, patternStops)
Expand Down Expand Up @@ -140,7 +140,7 @@ export default class PatternLocationMarker extends Component<Props> {
controlId='defaultTravelTime'>
<ControlLabel>Travel time</ControlLabel>
<MinuteSecondInput
seconds={patternStop.defaultTravelTime}
seconds={patternStop.defaultTravelTime || 0}
onChange={this._onChangeTravelTime} />
</FormGroup>
</Col>
Expand All @@ -149,7 +149,7 @@ export default class PatternLocationMarker extends Component<Props> {
controlId='defaultTimeInLocation'>
<ControlLabel>Time in location</ControlLabel>
<MinuteSecondInput
seconds={patternStop.defaultDwellTime}
seconds={patternStop.defaultDwellTime || 0}
onChange={this._onChangeTimeInLocation} />
</FormGroup>
</Col>
Expand Down
4 changes: 2 additions & 2 deletions lib/editor/components/map/PatternStopMarker.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export default class PatternStopMarker extends Component<Props> {
controlId='defaultTravelTime'>
<ControlLabel>Travel time</ControlLabel>
<MinuteSecondInput
seconds={patternStop.defaultTravelTime}
seconds={patternStop.defaultTravelTime || 0}
onChange={this._onChangeTravelTime} />
</FormGroup>
</Col>
Expand All @@ -129,7 +129,7 @@ export default class PatternStopMarker extends Component<Props> {
controlId='defaultDwellTime'>
<ControlLabel>Dwell time</ControlLabel>
<MinuteSecondInput
seconds={patternStop.defaultDwellTime}
seconds={patternStop.defaultDwellTime || 0}
onChange={this._onChangeDwellTime} />
</FormGroup>
</Col>
Expand Down
1 change: 1 addition & 0 deletions lib/editor/components/map/PatternStopsLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export default class PatternStopsLayer extends Component<Props> {
const locationGroup = activePatternLocationGroups.find(l => l && l.location_group_id === locationGroupId)
if (!stop && !location && !locationGroup) {
console.log(stop)
// $FlowFixMe
console.warn(`Could not find stop for stopId: ${stopId || locationId || locationGroupId}`, activePatternStops)
return
}
Expand Down
5 changes: 3 additions & 2 deletions lib/editor/util/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import type {
Project,
Trip,
User,
ZoneInfo
ZoneInfo,
GtfsSpecTable
} from '../../types'
import type {ManagerUserState} from '../../types/reducers'

Expand Down Expand Up @@ -195,7 +196,7 @@ export function getZones (

// used to select the table from gtfs.yml to be used for
// validating and populating fields in editor (EntityDetails)
export function getEditorTable (component: string) {
export function getEditorTable (component: string): GtfsSpecTable {
const spec = getGtfsSpec()
if (!spec) {
throw new Error('Editor spec could not be found!')
Expand Down
2 changes: 1 addition & 1 deletion lib/editor/util/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,7 @@ export function generateControlPointsFromPatternStops (
}
}
export function stopToPoint (stop: GtfsStop) {
export function stopToPoint (stop: GtfsStop | GtfsLocation | GtfsLocationGroup) {
return point([stop.stop_lon, stop.stop_lat])
}
Expand Down
1 change: 1 addition & 0 deletions lib/types/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,7 @@ export type GtfsSpecField = {

export type GtfsSpecTable = {
datatools?: boolean,
extraFields?: Array<GtfsSpecField>,
fields: Array<GtfsSpecField>,
flex?: boolean, // Denotes table as being non-csv flex table
helpContent: string,
Expand Down

0 comments on commit e5ec45b

Please sign in to comment.