diff options
| author | cedricnjanga | 2017-10-25 16:38:09 +0200 |
|---|---|---|
| committer | cedricnjanga | 2017-10-25 18:02:36 +0200 |
| commit | b0c1dd17d8e301ed2c3c22d84cf3620763b9fdf7 (patch) | |
| tree | 7539189c11fe8840838019ba2d6a1638f89463db | |
| parent | 75cd86bc42702fe63f4a8b18ae711a91353a5ad1 (diff) | |
| download | chouette-core-b0c1dd17d8e301ed2c3c22d84cf3620763b9fdf7.tar.bz2 | |
Refs #4016 disable validate button for duplication of VJ on conditions
| -rw-r--r-- | app/javascript/vehicle_journeys/components/tools/DuplicateVehicleJourney.js | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/app/javascript/vehicle_journeys/components/tools/DuplicateVehicleJourney.js b/app/javascript/vehicle_journeys/components/tools/DuplicateVehicleJourney.js index 0c1c81114..6cce3eaad 100644 --- a/app/javascript/vehicle_journeys/components/tools/DuplicateVehicleJourney.js +++ b/app/javascript/vehicle_journeys/components/tools/DuplicateVehicleJourney.js @@ -8,6 +8,7 @@ export default class DuplicateVehicleJourney extends Component { this.state = {} this.onFormChange = this.onFormChange.bind(this) this.handleSubmit = this.handleSubmit.bind(this) + this.disableValidateButton = this.disableValidateButton.bind(this) } componentWillReceiveProps() { @@ -58,6 +59,16 @@ export default class DuplicateVehicleJourney extends Component { return vjas.departure_time[type] } + disableValidateButton() { + /* We disable the button in two cases : + - if the additional_time_hh or additional_time_mm are above their input max value + - if if their is no change in the other inputs to avoid making a coping of the selected VJ + */ + let incorrectDT = isNaN(this.state.duplicate_time_hh) || isNaN(this.state.duplicate_time_mm) || this.state.duplicate_time_hh > 23 || this.state.duplicate_time_mm > 59 + let noInputChanges = this.state.additional_time == 0 && this.state.originalDT.hour == this.state.duplicate_time_hh && this.state.originalDT.minute == this.state.duplicate_time_mm + return incorrectDT || noInputChanges + } + render() { if(this.props.status.isFetching == true) { return false @@ -171,6 +182,7 @@ export default class DuplicateVehicleJourney extends Component { className={'btn btn-primary ' + (this.state.additional_time == 0 && this.state.originalDT.hour == this.state.duplicate_time_hh && this.state.originalDT.minute == this.state.duplicate_time_mm ? 'disabled' : '')} type='button' onClick={this.handleSubmit} + disabled={this.disableValidateButton()} > Valider </button> |
