Permalink
Browse files

Use more generic onChange handlers for PilotDetails dropdowns and inputs

  • Loading branch information...
markerikson committed Jan 7, 2017
1 parent af7e46e commit dad0aa71cbb090e3575f351ac54c3d90a20b8ab2
Showing with 9 additions and 5 deletions.
  1. +9 −5 src/features/pilots/PilotDetails/PilotDetails.jsx
@@ -70,15 +70,16 @@ const actions = {
export class PilotDetails extends Component {
onNameChanged = (e) => {
onInputChanged = (e) => {
const newValues = getValueFromEvent(e);
const {id} = this.props.pilot;
this.props.updateEntity("Pilot", id, newValues);
}
onRankChanged = (e, result) => {
const newValues = {rank : result.value};
onDropdownChanged = (e, result) => {
const {name, value} = result;
const newValues = { [name] : value};
const {id} = this.props.pilot;
this.props.updateEntity("Pilot", id, newValues);
@@ -109,7 +110,7 @@ export class PilotDetails extends Component {
placeholder="Name"
value={name}
disabled={!canStopEditing}
onChange={this.onNameChanged}
onChange={this.onInputChanged}
control="input"
/>
<Form.Field
@@ -121,7 +122,7 @@ export class PilotDetails extends Component {
selection
options={RANKS}
value={rank}
onChange={this.onRankChanged}
onChange={this.onDropdownChanged}
disabled={!canStopEditing}
/>
<Form.Field
@@ -131,6 +132,7 @@ export class PilotDetails extends Component {
placeholder="Age"
control="input"
value={age}
onChange={this.onInputChanged}
disabled={!canStopEditing}
/>
<Form.Field
@@ -142,6 +144,7 @@ export class PilotDetails extends Component {
selection
options={SKILL_VALUES}
value={gunnery}
onChange={this.onDropdownChanged}
disabled={!canStopEditing}
/>
<Form.Field
@@ -153,6 +156,7 @@ export class PilotDetails extends Component {
selection
options={SKILL_VALUES}
value={piloting}
onChange={this.onDropdownChanged}
disabled={!canStopEditing}
/>
<Form.Field

0 comments on commit dad0aa7

Please sign in to comment.