|
|
|
@ -28,13 +28,8 @@ class TripForm extends Component {
|
|
|
|
|
state = { |
|
|
|
|
id: null, |
|
|
|
|
trip_id: "", |
|
|
|
|
email: "", |
|
|
|
|
fare_url: "", |
|
|
|
|
lang: "", |
|
|
|
|
name: "", |
|
|
|
|
phone: "", |
|
|
|
|
timezone: "", |
|
|
|
|
url: "", |
|
|
|
|
service: null, |
|
|
|
|
frequency_set: [], |
|
|
|
|
newStopTime: false, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -79,6 +74,15 @@ class TripForm extends Component {
|
|
|
|
|
const { agencyId, routeId, tripId } = props.match.params |
|
|
|
|
if (!props.calendar.fetching && props.calendar.count === 0) |
|
|
|
|
store.dispatch(getCalendar()) |
|
|
|
|
if (tripId === undefined) { |
|
|
|
|
const { route } = props |
|
|
|
|
const tRoute = route.results.filter(ele => ele.route_id === routeId) |
|
|
|
|
if (tRoute.length > 0) { |
|
|
|
|
return { route: tRoute[0].id } |
|
|
|
|
} else { |
|
|
|
|
store.dispatch(getRoute(`agency=${agencyId}`)) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (tripId !== undefined && state.id === null) { |
|
|
|
|
const { route } = props |
|
|
|
|
const tRoute = route.results.filter(ele => ele.route_id === routeId) |
|
|
|
@ -130,7 +134,7 @@ class TripForm extends Component {
|
|
|
|
|
label="Service" |
|
|
|
|
type="text" |
|
|
|
|
fieldName="service" |
|
|
|
|
value={one.service ? one.service.id : ''} |
|
|
|
|
value={one.service} |
|
|
|
|
handleChange={this.handleChange} |
|
|
|
|
choices={calendar.results.map(ele => ({ value: ele.id, label: ele.service_id }))} />} |
|
|
|
|
|
|
|
|
@ -201,7 +205,7 @@ class TripForm extends Component {
|
|
|
|
|
const one = this.state |
|
|
|
|
const { fetching } = this.props.trip |
|
|
|
|
// redirect to view page if no data
|
|
|
|
|
const { agencyId, routeId, tripId } = this.props.match.params |
|
|
|
|
const { agencyId, routeId } = this.props.match.params |
|
|
|
|
// this is a create form
|
|
|
|
|
// if (tripId === undefined) {
|
|
|
|
|
// if (one.justSubmit === true && !fetching) {
|
|
|
|
@ -217,11 +221,9 @@ class TripForm extends Component {
|
|
|
|
|
if (one.justSubmit === true && !fetching) { |
|
|
|
|
return <Redirect to={`/map/${agencyId}/route/${routeId}/trip`} /> |
|
|
|
|
} |
|
|
|
|
return ( |
|
|
|
|
<div className="columns"> |
|
|
|
|
<div className="column is-half"> |
|
|
|
|
{this.renderForm()} |
|
|
|
|
</div> |
|
|
|
|
let StopTimePane = null |
|
|
|
|
if (this.state.id !== null) { |
|
|
|
|
StopTimePane = ( |
|
|
|
|
<div className="column is-half"> |
|
|
|
|
<StyleBox> |
|
|
|
|
{!this.state.newStopTime && <button className="button is-outlined" onClick={this.toggleNewStopTime}>new StopTime</button>} |
|
|
|
@ -232,6 +234,15 @@ class TripForm extends Component {
|
|
|
|
|
{this.props.stoptime.results.map( |
|
|
|
|
ele => <StopTimeOne key={`stb-${ele.id}`} item={ele} />)} |
|
|
|
|
</div> |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
<div className="columns"> |
|
|
|
|
<div className="column is-half"> |
|
|
|
|
{this.renderForm()} |
|
|
|
|
</div> |
|
|
|
|
{StopTimePane} |
|
|
|
|
</div> |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|