Skip to content

Commit 02a70c1

Browse files
authored
Merge pull request #70 from opentripplanner/dev
Patch release
2 parents 646fa12 + 3c217e0 commit 02a70c1

9 files changed

+154
-91
lines changed

Diff for: example-config.yml

+21
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,27 @@ api:
22
host: http://localhost
33
path: /otp/routers/default
44
port: 8001
5+
# Add suggested locations to be shown as options in the form view.
6+
# locations:
7+
# - id: 'airport'
8+
# icon: 'plane'
9+
# name: 'Portland International Airport (PDX)'
10+
# lat: 45.587579
11+
# lon: -122.593084
12+
# - id: 'zoo'
13+
# icon: building
14+
# lat: 45.51010444232195
15+
# lon: -122.71607145667079
16+
# name: Oregon Zoo, Portland, OR
17+
18+
### The persistence setting is used to enable the storage of places (home, work),
19+
### recent searches/places, user overrides, and favorite stops. Currently the
20+
### only strategy is localStorage (which is used by default). It also must be
21+
### enabled to show the stored locations (see above).
22+
### TODO: add another server-based strategy
23+
persistence:
24+
enabled: true
25+
strategy: localStorage
526

627
map:
728
initLat: 45.52

Diff for: lib/components/app/default-main-panel.js

+11-6
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,18 @@ import DefaultSearchForm from '../form/default-search-form'
77
import PlanTripButton from '../form/plan-trip-button'
88
import UserSettings from '../form/user-settings'
99
import NarrativeRoutingResults from '../narrative/narrative-routing-results'
10-
import { getActiveSearch } from '../../util/state'
10+
import { getActiveSearch, getShowUserSettings } from '../../util/state'
1111

1212
class DefaultMainPanel extends Component {
1313
render () {
1414
const {
15+
activeSearch,
16+
currentQuery,
1517
customIcons,
1618
itineraryClass,
1719
itineraryFooter,
1820
mainPanelContent,
19-
currentQuery,
20-
activeSearch
21+
showUserSettings
2122
} = this.props
2223
const showPlanTripButton = mainPanelContent === 'EDIT_DATETIME' ||
2324
mainPanelContent === 'EDIT_SETTINGS'
@@ -35,7 +36,9 @@ class DefaultMainPanel extends Component {
3536
overflow: 'auto'
3637
}}>
3738
<DefaultSearchForm icons={customIcons} />
38-
{!activeSearch && !showPlanTripButton && <UserSettings />}
39+
{!activeSearch && !showPlanTripButton && showUserSettings &&
40+
<UserSettings />
41+
}
3942
<div className='desktop-narrative-container'>
4043
<NarrativeRoutingResults
4144
itineraryClass={itineraryClass}
@@ -66,10 +69,12 @@ class DefaultMainPanel extends Component {
6669

6770
// connect to the redux store
6871
const mapStateToProps = (state, ownProps) => {
72+
const showUserSettings = getShowUserSettings(state.otp)
6973
return {
70-
mainPanelContent: state.otp.ui.mainPanelContent,
74+
activeSearch: getActiveSearch(state.otp),
7175
currentQuery: state.otp.currentQuery,
72-
activeSearch: getActiveSearch(state.otp)
76+
mainPanelContent: state.otp.ui.mainPanelContent,
77+
showUserSettings
7378
}
7479
}
7580

Diff for: lib/components/app/print-layout.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ class PrintLayout extends Component {
3737
const { location } = this.props
3838
// Parse the URL query parameters, if present
3939
if (location && location.search) {
40-
this.props.parseUrlQueryString(location.search)
41-
this.props.routingQuery()
40+
this.props.parseUrlQueryString()
4241
}
4342
}
4443

Diff for: lib/components/form/location-field.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { addLocationSearch, getCurrentPosition } from '../../actions/location'
1919
import { findNearbyStops } from '../../actions/api'
2020
import { distanceStringImperial } from '../../util/distance'
2121
import { formatStoredPlaceName } from '../../util/map'
22-
import { getActiveSearch } from '../../util/state'
22+
import { getActiveSearch, getShowUserSettings } from '../../util/state'
2323

2424
class LocationField extends Component {
2525
static propTypes = {
@@ -283,6 +283,7 @@ class LocationField extends Component {
283283
location,
284284
user,
285285
showClearButton,
286+
showUserSettings,
286287
static: isStatic,
287288
suppressNearby,
288289
type,
@@ -381,7 +382,7 @@ class LocationField extends Component {
381382
}
382383

383384
/* 3b) Process stored user locations */
384-
if (locations.length > 0) {
385+
if (locations.length > 0 && showUserSettings) {
385386
// Add the menu sub-heading (not a selectable item)
386387
menuItems.push(<MenuItem header key='mp-header'>My Places</MenuItem>)
387388

@@ -569,13 +570,15 @@ const mapStateToProps = (state, ownProps) => {
569570
const activeSearch = getActiveSearch(state.otp)
570571
const query = activeSearch ? activeSearch.query : state.otp.currentQuery
571572
const location = query[ownProps.type]
573+
const showUserSettings = getShowUserSettings(state.otp)
572574
return {
573575
config: state.otp.config,
574576
location,
575577
user: state.otp.user,
576578
currentPosition: state.otp.location.currentPosition,
577579
sessionSearches: state.otp.location.sessionSearches,
578580
nearbyStops: state.otp.location.nearbyStops,
581+
showUserSettings,
579582
stopsIndex: state.otp.transitIndex.stops
580583
}
581584
}

Diff for: lib/components/form/settings-selector-panel.js

+35-23
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
getTransitModes
2424
} from '../../util/itinerary'
2525
import { getTripOptionsFromQuery, isNotDefaultQuery } from '../../util/query'
26+
import { getShowUserSettings } from '../../util/state'
2627

2728
class SettingsSelectorPanel extends Component {
2829
static propTypes = {
@@ -345,8 +346,15 @@ class SettingsSelectorPanel extends Component {
345346
}
346347

347348
render () {
348-
const { config, defaults, mode, icons, query, queryModes } = this.props
349-
349+
const {
350+
config,
351+
defaults,
352+
mode,
353+
icons,
354+
query,
355+
queryModes,
356+
showUserSettings
357+
} = this.props
350358
const modeHasTransit = hasTransit(mode)
351359
const { transitModes, accessModes, bicycleModes, micromobilityModes } = config.modes
352360

@@ -358,26 +366,28 @@ class SettingsSelectorPanel extends Component {
358366
return (
359367
<div className='settings-selector-panel'>
360368
<div className='modes-panel'>
361-
<div style={{ marginBottom: '5px' }} className='pull-right'>
362-
<Button
363-
bsStyle='link'
364-
bsSize='xsmall'
365-
disabled={rememberIsDisabled}
366-
onClick={this._toggleStoredSettings}
367-
>{defaults
368-
? <span><Icon type='times' /> Forget my options</span>
369-
: <span><Icon type='lock' /> Remember trip options</span>
370-
}</Button>
371-
<Button
372-
bsStyle='link'
373-
bsSize='xsmall'
374-
disabled={queryIsDefault && !defaults}
375-
onClick={this._resetForm}
376-
>
377-
<Icon type='undo' />{' '}
378-
Restore{defaults ? ' my' : ''} defaults
379-
</Button>
380-
</div>
369+
{showUserSettings &&
370+
<div style={{ marginBottom: '5px' }} className='store-settings pull-right'>
371+
<Button
372+
bsStyle='link'
373+
bsSize='xsmall'
374+
disabled={rememberIsDisabled}
375+
onClick={this._toggleStoredSettings}
376+
>{defaults
377+
? <span><Icon type='times' /> Forget my options</span>
378+
: <span><Icon type='lock' /> Remember trip options</span>
379+
}</Button>
380+
<Button
381+
bsStyle='link'
382+
bsSize='xsmall'
383+
disabled={queryIsDefault && !defaults}
384+
onClick={this._resetForm}
385+
>
386+
<Icon type='undo' />{' '}
387+
Restore{defaults ? ' my' : ''} defaults
388+
</Button>
389+
</div>
390+
}
381391
{/* Take Transit button */}
382392
<Row className='mode-group-row'>
383393
<Col xs={12}>
@@ -548,6 +558,7 @@ class SettingsSelectorPanel extends Component {
548558
const mapStateToProps = (state, ownProps) => {
549559
const { config, currentQuery, user } = state.otp
550560
const { defaults } = user
561+
const showUserSettings = getShowUserSettings(state.otp)
551562
const { companies, mode, routingType } = currentQuery
552563
return {
553564
defaults,
@@ -557,7 +568,8 @@ const mapStateToProps = (state, ownProps) => {
557568
companies,
558569
modeGroups: config.modeGroups,
559570
queryModes: !mode || mode.length === 0 ? [] : mode.split(','),
560-
routingType
571+
routingType,
572+
showUserSettings
561573
}
562574
}
563575

Diff for: lib/components/map/endpoint.js

+52-50
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export default class Endpoint extends Component {
5151
}
5252

5353
render () {
54-
const { type, location, locations } = this.props
54+
const { type, location, locations, showPopup } = this.props
5555
const position = location && location.lat && location.lon ? [location.lat, location.lon] : null
5656
if (!position) return null
5757
const fgStyle = { fontSize: 24, width: 32, height: 32 }
@@ -91,57 +91,59 @@ export default class Endpoint extends Component {
9191
icon={divIcon({ html: iconHtml, className: '' })}
9292
position={position}
9393
onDragEnd={this._onDragEnd}>
94-
<Popup>
95-
<div>
96-
<strong>
97-
<Icon type={icon} /> {location.name}
98-
</strong>
94+
{showPopup &&
95+
<Popup>
9996
<div>
100-
<Button
101-
bsStyle='link'
102-
bsSize='small'
103-
disabled={isWork}
104-
style={{ padding: 0 }}
105-
onClick={isHome ? this._forgetHome : this._rememberAsHome}>
106-
{isHome
107-
? <span><Icon type='times' /> Forget home</span>
108-
: <span><Icon type='home' /> Save as home</span>
109-
}
110-
</Button>
97+
<strong>
98+
<Icon type={icon} /> {location.name}
99+
</strong>
100+
<div>
101+
<Button
102+
bsStyle='link'
103+
bsSize='small'
104+
disabled={isWork}
105+
style={{ padding: 0 }}
106+
onClick={isHome ? this._forgetHome : this._rememberAsHome}>
107+
{isHome
108+
? <span><Icon type='times' /> Forget home</span>
109+
: <span><Icon type='home' /> Save as home</span>
110+
}
111+
</Button>
112+
</div>
113+
<div>
114+
<Button
115+
bsStyle='link'
116+
bsSize='small'
117+
disabled={isHome}
118+
style={{ padding: 0 }}
119+
onClick={isWork ? this._forgetWork : this._rememberAsWork}>
120+
{isWork
121+
? <span><Icon type='times' /> Forget work</span>
122+
: <span><Icon type='briefcase' /> Save as work</span>
123+
}
124+
</Button>
125+
</div>
126+
<div>
127+
<Button
128+
bsStyle='link'
129+
bsSize='small'
130+
style={{ padding: 0 }}
131+
onClick={this._clearLocation}>
132+
<Icon type='times' /> Remove as {type} location
133+
</Button>
134+
</div>
135+
<div>
136+
<Button
137+
bsStyle='link'
138+
bsSize='small'
139+
style={{ padding: 0 }}
140+
onClick={this._swapLocation}>
141+
<Icon type='refresh' /> Change to {otherType} location
142+
</Button>
143+
</div>
111144
</div>
112-
<div>
113-
<Button
114-
bsStyle='link'
115-
bsSize='small'
116-
disabled={isHome}
117-
style={{ padding: 0 }}
118-
onClick={isWork ? this._forgetWork : this._rememberAsWork}>
119-
{isWork
120-
? <span><Icon type='times' /> Forget work</span>
121-
: <span><Icon type='briefcase' /> Save as work</span>
122-
}
123-
</Button>
124-
</div>
125-
<div>
126-
<Button
127-
bsStyle='link'
128-
bsSize='small'
129-
style={{ padding: 0 }}
130-
onClick={this._clearLocation}>
131-
<Icon type='times' /> Remove as {type} location
132-
</Button>
133-
</div>
134-
<div>
135-
<Button
136-
bsStyle='link'
137-
bsSize='small'
138-
style={{ padding: 0 }}
139-
onClick={this._swapLocation}>
140-
<Icon type='refresh' /> Change to {otherType} location
141-
</Button>
142-
</div>
143-
</div>
144-
</Popup>
145+
</Popup>
146+
}
145147
</Marker>
146148
)
147149
}

Diff for: lib/components/map/endpoints-overlay.js

+16-5
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,27 @@ import { connect } from 'react-redux'
33

44
import Endpoint from './endpoint'
55
import { clearLocation, forgetPlace, rememberPlace, setLocation } from '../../actions/map'
6-
import { getActiveSearch } from '../../util/state'
6+
import { getActiveSearch, getShowUserSettings } from '../../util/state'
77

88
class EndpointsOverlay extends Component {
99
static propTypes = {
1010
query: PropTypes.object
1111
}
1212
render () {
13-
const { from, to } = this.props.query
13+
const { query, showUserSettings } = this.props
14+
const { from, to } = query
1415
return (
1516
<div>
16-
<Endpoint type='from' location={from} {...this.props} />
17-
<Endpoint type='to' location={to} {...this.props} />
17+
<Endpoint
18+
type='from'
19+
showPopup={showUserSettings}
20+
location={from}
21+
{...this.props} />
22+
<Endpoint
23+
type='to'
24+
showPopup={showUserSettings}
25+
location={to}
26+
{...this.props} />
1827
</div>
1928
)
2029
}
@@ -27,9 +36,11 @@ const mapStateToProps = (state, ownProps) => {
2736
// current query is no search is available.
2837
const activeSearch = getActiveSearch(state.otp)
2938
const query = activeSearch ? activeSearch.query : state.otp.currentQuery
39+
const showUserSettings = getShowUserSettings(state.otp)
3040
return {
41+
locations: state.otp.user.locations,
3142
query,
32-
locations: state.otp.user.locations
43+
showUserSettings
3344
}
3445
}
3546

0 commit comments

Comments
 (0)