@@ -8,12 +8,12 @@ import {generateUID} from '../../../common/util/util'
88import { entityIsNew } from '../../util/objects'
99
1010export default class TripPatternListControls extends Component {
11- _onClickClone = ( ) => {
11+ _onClickClonePattern = ( ) => {
1212 const { activePattern, cloneEntity, feedSource} = this . props
1313 cloneEntity ( feedSource . id , 'trippattern' , activePattern . id , true )
1414 }
1515
16- _onClickDelete = ( ) => {
16+ _onClickDeletePattern = ( ) => {
1717 const {
1818 activeEntity,
1919 activePattern,
@@ -61,7 +61,7 @@ export default class TripPatternListControls extends Component {
6161 * the order of the shape points. NOTE: this does not change the travel times
6262 * for the pattern stops.
6363 */
64- _onClickReverse = ( ) => {
64+ _onClickReversePattern = ( ) => {
6565 const {
6666 activePattern,
6767 controlPoints,
@@ -79,6 +79,7 @@ export default class TripPatternListControls extends Component {
7979 const patternStops = [ ...activePattern . patternStops ]
8080 // Reverse sort on existing stopSequence values
8181 . sort ( ( a , b ) => b . stopSequence - a . stopSequence )
82+ // Update sequence for new order.
8283 . map ( ( ps , i ) => ( {
8384 ...ps ,
8485 stopSequence : i
@@ -98,8 +99,9 @@ export default class TripPatternListControls extends Component {
9899 }
99100
100101 render ( ) {
101- const { activePatternId, activeEntity } = this . props
102+ const { activeEntity , activePatternId, activePatternTripCount } = this . props
102103 const { tripPatterns} = activeEntity
104+ const patternHasTrips = activePatternTripCount > 0
103105 const createPatternDisabled = tripPatterns && tripPatterns . findIndex ( entityIsNew ) !== - 1
104106 return (
105107 < div
@@ -112,8 +114,12 @@ export default class TripPatternListControls extends Component {
112114 overlay = { < Tooltip id = 'tooltip' > Reverse trip pattern</ Tooltip > } >
113115 < Button
114116 bsSize = 'small'
115- disabled = { ! activePatternId }
116- onClick = { this . _onClickReverse } >
117+ title = { patternHasTrips
118+ ? 'Cannot reverse patterns that have trips'
119+ : 'Select pattern to reverse' }
120+ // Do not allow reversing trip pattern if it has trips
121+ disabled = { ! activePatternId || patternHasTrips }
122+ onClick = { this . _onClickReversePattern } >
117123 < Icon type = 'exchange' />
118124 </ Button >
119125 </ OverlayTrigger >
@@ -123,7 +129,7 @@ export default class TripPatternListControls extends Component {
123129 < Button
124130 bsSize = 'small'
125131 disabled = { ! activePatternId }
126- onClick = { this . _onClickClone } >
132+ onClick = { this . _onClickClonePattern } >
127133 < Icon type = 'clone' />
128134 </ Button >
129135 </ OverlayTrigger >
@@ -133,7 +139,7 @@ export default class TripPatternListControls extends Component {
133139 < Button
134140 bsSize = 'small'
135141 disabled = { ! activePatternId }
136- onClick = { this . _onClickDelete } >
142+ onClick = { this . _onClickDeletePattern } >
137143 < Icon type = 'trash' />
138144 </ Button >
139145 </ OverlayTrigger >
0 commit comments