diff options
| author | Thomas Haddad | 2017-04-28 16:17:33 +0200 |
|---|---|---|
| committer | Thomas Haddad | 2017-04-28 16:17:54 +0200 |
| commit | 2ff455b793db7f5aa6408778e096df21f5918dd9 (patch) | |
| tree | b06776c02bc0ce6a6a037096322a2a4452693aaa /app | |
| parent | 84820f51a45ec278b6f0523261898b4a4b65ba8b (diff) | |
| download | chouette-core-2ff455b793db7f5aa6408778e096df21f5918dd9.tar.bz2 | |
Refs #3171: Fill departure input w/ proper data
Signed-off-by: Thomas Shawarma Haddad <thomas.haddad@af83.com>
Diffstat (limited to 'app')
4 files changed, 13 insertions, 11 deletions
diff --git a/app/assets/javascripts/es6_browserified/vehicle_journeys/actions/index.js b/app/assets/javascripts/es6_browserified/vehicle_journeys/actions/index.js index b436f92f8..65576f094 100644 --- a/app/assets/javascripts/es6_browserified/vehicle_journeys/actions/index.js +++ b/app/assets/javascripts/es6_browserified/vehicle_journeys/actions/index.js @@ -95,9 +95,8 @@ const actions = { openShiftModal : () => ({ type : 'SHIFT_VEHICLEJOURNEY_MODAL' }), - openDuplicateModal : (vj) => ({ - type : 'DUPLICATE_VEHICLEJOURNEY_MODAL', - vehicleJourney: vj + openDuplicateModal : () => ({ + type : 'DUPLICATE_VEHICLEJOURNEY_MODAL' }), selectVehicleJourney : (index) => ({ type : 'SELECT_VEHICLEJOURNEY', diff --git a/app/assets/javascripts/es6_browserified/vehicle_journeys/components/tools/DuplicateVehicleJourney.js b/app/assets/javascripts/es6_browserified/vehicle_journeys/components/tools/DuplicateVehicleJourney.js index 5ce94f8b9..200a10dbb 100644 --- a/app/assets/javascripts/es6_browserified/vehicle_journeys/components/tools/DuplicateVehicleJourney.js +++ b/app/assets/javascripts/es6_browserified/vehicle_journeys/components/tools/DuplicateVehicleJourney.js @@ -2,6 +2,7 @@ var React = require('react') var Component = require('react').Component var PropTypes = require('react').PropTypes var actions = require('../../actions') +var _ = require('lodash') class DuplicateVehicleJourney extends Component { constructor(props) { @@ -16,6 +17,10 @@ class DuplicateVehicleJourney extends Component { } } + getDefaultValue(type) { + let vjas = _.find(actions.getSelected(this.props.vehicleJourneys)[0].vehicle_journey_at_stops, {'dummy': false}) + return vjas.departure_time[type] + } render() { if(this.props.status.isFetching == true) { return false @@ -28,7 +33,7 @@ class DuplicateVehicleJourney extends Component { disabled={((actions.getSelected(this.props.vehicleJourneys).length >= 1 && this.props.filters.policy['vehicle_journeys.edit']) ? '' : 'disabled')} data-toggle='modal' data-target='#DuplicateVehicleJourneyModal' - onClick={() => this.props.onOpenDuplicateModal(actions.getSelected(this.props.vehicleJourneys)[0])} + onClick={this.props.onOpenDuplicateModal} > <span className='fa fa-files-o'></span> </button> @@ -58,7 +63,7 @@ class DuplicateVehicleJourney extends Component { min='00' max='23' className='form-control' - defaultValue={'00'} + defaultValue={this.getDefaultValue('hour')} /> <span>:</span> <input @@ -67,7 +72,7 @@ class DuplicateVehicleJourney extends Component { min='00' max='59' className='form-control' - defaultValue={'00'} + defaultValue={this.getDefaultValue('minute')} /> </span> </div> diff --git a/app/assets/javascripts/es6_browserified/vehicle_journeys/containers/tools/DuplicateVehicleJourney.js b/app/assets/javascripts/es6_browserified/vehicle_journeys/containers/tools/DuplicateVehicleJourney.js index 375456ebc..6cf6f4039 100644 --- a/app/assets/javascripts/es6_browserified/vehicle_journeys/containers/tools/DuplicateVehicleJourney.js +++ b/app/assets/javascripts/es6_browserified/vehicle_journeys/containers/tools/DuplicateVehicleJourney.js @@ -16,8 +16,8 @@ const mapDispatchToProps = (dispatch) => { onModalClose: () =>{ dispatch(actions.closeModal()) }, - onOpenDuplicateModal: (vj) =>{ - dispatch(actions.openDuplicateModal(vj)) + onOpenDuplicateModal: () =>{ + dispatch(actions.openDuplicateModal()) }, onDuplicateVehicleJourney: (data) =>{ dispatch(actions.duplicateVehicleJourney(data)) diff --git a/app/assets/javascripts/es6_browserified/vehicle_journeys/reducers/modal.js b/app/assets/javascripts/es6_browserified/vehicle_journeys/reducers/modal.js index 30164c3ef..3b13ab9de 100644 --- a/app/assets/javascripts/es6_browserified/vehicle_journeys/reducers/modal.js +++ b/app/assets/javascripts/es6_browserified/vehicle_journeys/reducers/modal.js @@ -116,9 +116,7 @@ const modal = (state = {}, action) => { case 'DUPLICATE_VEHICLEJOURNEY_MODAL': return { type: 'duplicate', - modalProps: { - vehicleJourney: action.vehicleJourney - }, + modalProps: {}, confirmModal: {} } case 'CLOSE_MODAL': |
