|
|
|
@ -12,7 +12,11 @@ import store from '../store'
|
|
|
|
|
import Input from './parts/Input' |
|
|
|
|
import AsyncSelect from 'react-select/lib/Async' |
|
|
|
|
import { components } from 'react-select' |
|
|
|
|
import { getStopsAsyncSelect, getFareAttrAsyncSelect } from '../utils' |
|
|
|
|
import { |
|
|
|
|
getStopsAsyncSelect, |
|
|
|
|
getFareAttrAsyncSelect, |
|
|
|
|
getRouteAsyncSelect |
|
|
|
|
} from '../utils' |
|
|
|
|
|
|
|
|
|
const StyledFareRulesForm = styled.div` |
|
|
|
|
padding: 1rem; |
|
|
|
@ -37,6 +41,16 @@ const FareAttrOption = (props) => {
|
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const RouteOption = (props) => { |
|
|
|
|
const { route_id, short_name, long_name} = props.data |
|
|
|
|
return ( |
|
|
|
|
<components.Option {...props}> |
|
|
|
|
<code>{route_id}</code> {short_name} |
|
|
|
|
<br/>{long_name} |
|
|
|
|
</components.Option> |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class FareRulesForm extends Component { |
|
|
|
|
|
|
|
|
@ -121,12 +135,26 @@ class FareRulesForm extends Component {
|
|
|
|
|
/> |
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
<Input |
|
|
|
|
label="Route ID" |
|
|
|
|
type="text" |
|
|
|
|
fieldName="route_id" |
|
|
|
|
value={one.route_id || ''} |
|
|
|
|
handleChange={this.handleChange} /> |
|
|
|
|
<div className="field"> |
|
|
|
|
<label className="label">Route</label> |
|
|
|
|
<AsyncSelect |
|
|
|
|
cacheOptions={true} |
|
|
|
|
defaultOptions |
|
|
|
|
defaultValue={one.route_id && {value: one.route_id, label: one.route_id}} |
|
|
|
|
loadOptions={getRouteAsyncSelect} |
|
|
|
|
components={{ Option: RouteOption }} |
|
|
|
|
onChange={(resp, evt) => { |
|
|
|
|
if (evt.action === 'select-option') { |
|
|
|
|
let evt = { |
|
|
|
|
target: { |
|
|
|
|
name: 'route_id', |
|
|
|
|
value: resp.route_id, |
|
|
|
|
}} |
|
|
|
|
this.handleChange(evt) |
|
|
|
|
} |
|
|
|
|
}} |
|
|
|
|
/> |
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
<div className="field"> |
|
|
|
|
<label className="label">Origin ID</label> |
|
|
|
@ -170,13 +198,26 @@ class FareRulesForm extends Component {
|
|
|
|
|
/> |
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
<Input |
|
|
|
|
label="Contains ID" |
|
|
|
|
type="text" |
|
|
|
|
fieldName="contains_id" |
|
|
|
|
value={one.contains_id || ''} |
|
|
|
|
handleChange={this.handleChange} /> |
|
|
|
|
|
|
|
|
|
<div className="field"> |
|
|
|
|
<label className="label">Contains ID</label> |
|
|
|
|
<AsyncSelect |
|
|
|
|
cacheOptions={true} |
|
|
|
|
defaultOptions |
|
|
|
|
defaultValue={one.contains_id && {value: one.contains_id, label: one.contains_id}} |
|
|
|
|
loadOptions={getStopsAsyncSelect} |
|
|
|
|
components={{ Option: StopOption }} |
|
|
|
|
onChange={(resp, evt) => { |
|
|
|
|
if (evt.action === 'select-option') { |
|
|
|
|
let evt = { |
|
|
|
|
target: { |
|
|
|
|
name: 'contains_id', |
|
|
|
|
value: resp.stop_id, |
|
|
|
|
}} |
|
|
|
|
this.handleChange(evt) |
|
|
|
|
} |
|
|
|
|
}} |
|
|
|
|
/> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
<div className="field is-grouped"> |
|
|
|
|