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