StationPicker sends json message
This commit is contained in:
parent
0a64d70ae3
commit
7502be1c5e
@ -74,8 +74,19 @@ class RoutePlanner extends Component {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
stationSearch() {
|
static getDerivedStateFromProps(props, state) {
|
||||||
console.log("Searching");
|
if (state.fromStation === null && props.stations && props.stations[0]) {
|
||||||
|
const abbr = props.stations[0].abbr;
|
||||||
|
return { fromStation: abbr, toStation: abbr};
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
stationSearch(evt) {
|
||||||
|
evt.preventDefault();
|
||||||
|
api.action("bartinfo", "json", {
|
||||||
|
from: this.state.fromStation,
|
||||||
|
to: this.state.toStation});
|
||||||
}
|
}
|
||||||
|
|
||||||
changeStation(evt) {
|
changeStation(evt) {
|
||||||
@ -98,14 +109,18 @@ class RoutePlanner extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
renderStationForm() {
|
renderStationForm() {
|
||||||
|
let initialState = null;
|
||||||
|
if (this.props.stations && this.props.stations[0]) {
|
||||||
|
initialState = this.props.stations[0].abbr;
|
||||||
|
}
|
||||||
return (<form name="bartSearch" onSubmit={this.stationSearch.bind(this)}>
|
return (<form name="bartSearch" onSubmit={this.stationSearch.bind(this)}>
|
||||||
From:
|
From:
|
||||||
<select name="fromStation" value={this.state.fromStation || ""} onChange={this.changeStation.bind(this)}>
|
<select disabled={!initialState} name="fromStation" value={this.state.fromStation || initialState} onChange={this.changeStation.bind(this)}>
|
||||||
{ this.renderStationOptions() }
|
{ this.renderStationOptions() }
|
||||||
</select>
|
</select>
|
||||||
<br/>
|
<br/>
|
||||||
To:
|
To:
|
||||||
<select name="toStation" value={this.state.toStation || ""} onChange={this.changeStation.bind(this)}>
|
<select disabled={!initialState} name="toStation" value={this.state.toStation || initialState} onChange={this.changeStation.bind(this)}>
|
||||||
{ this.renderStationOptions() }
|
{ this.renderStationOptions() }
|
||||||
</select>
|
</select>
|
||||||
<input type="submit" value="Search"/>
|
<input type="submit" value="Search"/>
|
||||||
|
@ -60,6 +60,10 @@
|
|||||||
%+ give-simple-payload:app eyre-id
|
%+ give-simple-payload:app eyre-id
|
||||||
%+ require-authorization:app inbound-request
|
%+ require-authorization:app inbound-request
|
||||||
poke-handle-http-request:cc
|
poke-handle-http-request:cc
|
||||||
|
%json
|
||||||
|
=+ !<(jon=json vase)
|
||||||
|
:_ this
|
||||||
|
(poke-handle-json:cc jon)
|
||||||
::
|
::
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
@ -187,6 +191,12 @@
|
|||||||
(pairs:enjs [[%elevators %a p.bsa] ~])
|
(pairs:enjs [[%elevators %a p.bsa] ~])
|
||||||
(with-json-handler response handler)
|
(with-json-handler response handler)
|
||||||
::
|
::
|
||||||
|
++ poke-handle-json
|
||||||
|
|= jon=json
|
||||||
|
^- (list card)
|
||||||
|
~& jon
|
||||||
|
[~]
|
||||||
|
::
|
||||||
++ poke-handle-http-request
|
++ poke-handle-http-request
|
||||||
|= =inbound-request:eyre
|
|= =inbound-request:eyre
|
||||||
^- simple-payload:http
|
^- simple-payload:http
|
||||||
|
Loading…
Reference in New Issue
Block a user