From be8afa7aa3fd1c8922a4e02e16cdfef698b3df26 Mon Sep 17 00:00:00 2001 From: Zog Date: Thu, 21 Dec 2017 15:47:29 +0100 Subject: Refs #5361 @1H; Make company optional in Lines form And handle the case when it is nil in the views --- app/javascript/vehicle_journeys/components/Tools.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/vehicle_journeys/components/Tools.js b/app/javascript/vehicle_journeys/components/Tools.js index 7621dfc10..1ef576529 100644 --- a/app/javascript/vehicle_journeys/components/Tools.js +++ b/app/javascript/vehicle_journeys/components/Tools.js @@ -17,7 +17,7 @@ export default class Tools extends Component { hasPolicy(key) { // Check if the user has the policy to disable or not the action - return this.props.filters.policy[`vehicle_journeys.${key}`] + return this.props.filters.policy[`vehicle_journeys.${key}`] } render() { @@ -45,4 +45,4 @@ Tools.propTypes = { vehicleJourneys : PropTypes.array.isRequired, onCancelSelection: PropTypes.func.isRequired, filters: PropTypes.object.isRequired -} \ No newline at end of file +} -- cgit v1.2.3 From efabcb6c50b727b74513fcd14edc99e15c8b7c98 Mon Sep 17 00:00:00 2001 From: Zog Date: Fri, 22 Dec 2017 14:01:43 +0100 Subject: And fix the code --- app/javascript/routes/reducers/stopPoints.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/routes/reducers/stopPoints.js b/app/javascript/routes/reducers/stopPoints.js index eeec06327..0b42b504f 100644 --- a/app/javascript/routes/reducers/stopPoints.js +++ b/app/javascript/routes/reducers/stopPoints.js @@ -38,15 +38,15 @@ const stopPoints = (state = [], action) => { case 'MOVE_STOP_UP': return [ ...state.slice(0, action.index - 1), - _.assign({}, state[action.index], { stoppoint_id: state[action.index - 1].stoppoint_id }), - _.assign({}, state[action.index - 1], { stoppoint_id: state[action.index].stoppoint_id }), + _.assign({}, state[action.index], { index: action.index - 1 }), + _.assign({}, state[action.index - 1], { index: action.index }), ...state.slice(action.index + 1) ] case 'MOVE_STOP_DOWN': return [ ...state.slice(0, action.index), - _.assign({}, state[action.index + 1], { stoppoint_id: state[action.index].stoppoint_id }), - _.assign({}, state[action.index], { stoppoint_id: state[action.index + 1].stoppoint_id }), + _.assign({}, state[action.index + 1], { index: action.index }), + _.assign({}, state[action.index], { index: action.index + 1 }), ...state.slice(action.index + 2) ] case 'DELETE_STOP': @@ -141,4 +141,4 @@ const stopPoints = (state = [], action) => { } } -export default stopPoints \ No newline at end of file +export default stopPoints -- cgit v1.2.3 From 705676378698b457c051e5f7324a18ee0714bec6 Mon Sep 17 00:00:00 2001 From: Zog Date: Fri, 22 Dec 2017 14:32:13 +0100 Subject: Fix FormHelper There is no spec (yet) --- app/javascript/routes/form_helper.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/routes/form_helper.js b/app/javascript/routes/form_helper.js index 8a3277234..865722fb6 100644 --- a/app/javascript/routes/form_helper.js +++ b/app/javascript/routes/form_helper.js @@ -7,14 +7,14 @@ const formHelper = { input.setAttribute('name', formatedName) input.setAttribute('value', value) form.appendChild(input) - }, + }, addError: (ids) => { ids.forEach((id) => { if (!$(id).parents('.form-group').hasClass('has-error')) { $(id).parents('.form-group').addClass('has-error') $(id).parent().append(`${'doit être rempli(e)'}`) } - }) + }) }, cleanInputs: (ids) => { ids.forEach((id) =>{ @@ -28,21 +28,22 @@ const formHelper = { ids.forEach(id => { $(id).val() == "" ? blankInputs.push(id) : filledInputs.push(id) }) - + if (filledInputs.length > 0) formHelper.cleanInputs(filledInputs) - if (blankInputs.length > 0) formHelper.addError(blankInputs) + if (blankInputs.length > 0) formHelper.addError(blankInputs) }, handleStopPoints: (event, state) => { if (state.stopPoints.length >= 2) { state.stopPoints.map((stopPoint, i) => { formHelper.addInput('id', stopPoint.stoppoint_id ? stopPoint.stoppoint_id : '', i) formHelper.addInput('stop_area_id', stopPoint.stoparea_id, i) - formHelper.addInput('position', i, i) + formHelper.addInput('position', stopPoint.index, i) formHelper.addInput('for_boarding', stopPoint.for_boarding, i) formHelper.addInput('for_alighting', stopPoint.for_alighting, i) }) - if ($('.alert.alert-danger').length > 0) $('.alert.alert-danger').remove() - } else { + if ($('.alert.alert-danger').length > 0) $('.alert.alert-danger').remove() + } + else { event.preventDefault() let msg = "L'itinéraire doit comporter au moins deux arrêts" if ($('.alert.alert-danger').length == 0) { @@ -52,4 +53,4 @@ const formHelper = { } } -export default formHelper \ No newline at end of file +export default formHelper -- cgit v1.2.3 From d3445d085b607544dc6355956cd228835258d612 Mon Sep 17 00:00:00 2001 From: Zog Date: Tue, 26 Dec 2017 11:23:53 +0100 Subject: Refs #5382 @1h; Enable all area types for Stopareas in Routes Given that the organisation has the matching feature. --- app/javascript/routes/components/BSelect2.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/javascript') diff --git a/app/javascript/routes/components/BSelect2.js b/app/javascript/routes/components/BSelect2.js index 340d9df95..29983dd58 100644 --- a/app/javascript/routes/components/BSelect2.js +++ b/app/javascript/routes/components/BSelect2.js @@ -96,7 +96,7 @@ class BSelect2 extends Component{ data: function(params) { return { q: params.term, - target_type: 'zdep' + scope: 'route_editor' }; }, processResults: function(data, params) { -- cgit v1.2.3 From ee7610328bc3af35cadfe7c3fde6bf61ab8c9dbf Mon Sep 17 00:00:00 2001 From: cedricnjanga Date: Tue, 26 Dec 2017 12:36:13 +0100 Subject: #5408 Fix VJ tt color affectation --- app/javascript/vehicle_journeys/actions/index.js | 3 ++- app/javascript/vehicle_journeys/components/VehicleJourney.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/vehicle_journeys/actions/index.js b/app/javascript/vehicle_journeys/actions/index.js index ce4b9209d..adb93ddf1 100644 --- a/app/javascript/vehicle_journeys/actions/index.js +++ b/app/javascript/vehicle_journeys/actions/index.js @@ -84,7 +84,8 @@ const actions = { selectedItem:{ id: selectedTT.id, comment: selectedTT.comment, - objectid: selectedTT.objectid + objectid: selectedTT.objectid, + color: selectedTT.color } }), addSelectedTimetable: () => ({ diff --git a/app/javascript/vehicle_journeys/components/VehicleJourney.js b/app/javascript/vehicle_journeys/components/VehicleJourney.js index 929cbc5c4..5769a810a 100644 --- a/app/javascript/vehicle_journeys/components/VehicleJourney.js +++ b/app/javascript/vehicle_journeys/components/VehicleJourney.js @@ -22,7 +22,7 @@ export default class VehicleJourney extends Component { let ttURL = refURL + '/time_tables/' + tt.id return ( - + ) } -- cgit v1.2.3 From d749861d3849003e512b6ab0ef65be65f23bfffa Mon Sep 17 00:00:00 2001 From: cedricnjanga Date: Tue, 26 Dec 2017 12:41:55 +0100 Subject: Refs #5409 Add purchase windows to date filters --- app/javascript/date_filters/index.js | 2 ++ app/javascript/date_filters/purchase_window.js | 5 +++++ 2 files changed, 7 insertions(+) create mode 100644 app/javascript/date_filters/purchase_window.js (limited to 'app/javascript') diff --git a/app/javascript/date_filters/index.js b/app/javascript/date_filters/index.js index ee892a7fe..432166008 100644 --- a/app/javascript/date_filters/index.js +++ b/app/javascript/date_filters/index.js @@ -3,6 +3,7 @@ import complianceControlSetDF from './compliance_control_set' import complianceCheckSetDF from './compliance_check_set' import timetableDF from './time_table' import importDF from './import' +import purchaseWindowDF from './purchase_window' import workbenchDF from './workbench' const DateFilters = { @@ -11,6 +12,7 @@ const DateFilters = { complianceControlSetDF, importDF, timetableDF, + purchaseWindowDF, workbenchDF } diff --git a/app/javascript/date_filters/purchase_window.js b/app/javascript/date_filters/purchase_window.js new file mode 100644 index 000000000..2c46b6d52 --- /dev/null +++ b/app/javascript/date_filters/purchase_window.js @@ -0,0 +1,5 @@ +import DateFilter from '../helpers/date_filters' + +const purchaseWindowDF = new DateFilter("purchase_window_filter_btn", "Tous les champs du filtre de date doivent être remplis", "q_contains_date_NUMi") + +export default purchaseWindowDF \ No newline at end of file -- cgit v1.2.3 From 0b7805f0d7d9a8fba394fd81a861044a821595bd Mon Sep 17 00:00:00 2001 From: Alban Peignier Date: Tue, 26 Dec 2017 23:04:21 +0100 Subject: Include StopArea type in select2 text for routes#edit. Refs #5382 --- app/javascript/routes/components/BSelect2.js | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/routes/components/BSelect2.js b/app/javascript/routes/components/BSelect2.js index 29983dd58..0d8d7787f 100644 --- a/app/javascript/routes/components/BSelect2.js +++ b/app/javascript/routes/components/BSelect2.js @@ -101,12 +101,21 @@ class BSelect2 extends Component{ }, processResults: function(data, params) { return { - results: data.map( - item => _.assign( - {}, - item, - { text: item.name + ", " + item.zip_code + " " + item.short_city_name + " (" + item.user_objectid + ")" } - ) + results: data.map( + function(item) { + var text = item.name; + if (item.zip_code || item.short_city_name) { + text += "," + } + if (item.zip_code) { + text += ` ${item.zip_code}` + } + if (item.short_city_name) { + text += ` ${item.short_city_name}` + } + text += ` (${item.area_type.toUpperCase()}, ${item.user_objectid})`; + return _.assign({}, item, { text: text }); + } ) }; }, -- cgit v1.2.3 From 344c7f884f4c25ece7490c94dfcb82e66bff0b2d Mon Sep 17 00:00:00 2001 From: Zog Date: Tue, 26 Dec 2017 09:57:34 +0100 Subject: Refs #5376 @1h; Change the behaviour of the inputs on VehicleJourney#index We don't block user actions anymore. Instead, when the departure time is set prior to the arrival time, we shift the arrival time accordingly (and reversed when the user sets the arrival time) --- app/javascript/vehicle_journeys/actions/index.js | 14 ++++++++++++++ .../vehicle_journeys/components/VehicleJourney.js | 6 +++++- .../vehicle_journeys/reducers/vehicleJourneys.js | 14 ++++---------- 3 files changed, 23 insertions(+), 11 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/vehicle_journeys/actions/index.js b/app/javascript/vehicle_journeys/actions/index.js index ce4b9209d..c82f759d6 100644 --- a/app/javascript/vehicle_journeys/actions/index.js +++ b/app/javascript/vehicle_journeys/actions/index.js @@ -439,6 +439,20 @@ const actions = { vjas.delta = delta return vjas }, + adjustSchedule: (action, schedule) => { + // we enforce that the departure time remains after the arrival time + actions.getDelta(schedule) + if(schedule.delta < 0){ + if(action.isDeparture){ + schedule.arrival_time = schedule.departure_time + } + else{ + schedule.departure_time = schedule.arrival_time + } + actions.getDelta(schedule) + } + return schedule + }, getShiftedSchedule: ({departure_time, arrival_time}, additional_time) => { // We create dummy dates objects to manipulate time more easily let departureDT = new Date (Date.UTC(2017, 2, 1, parseInt(departure_time.hour), parseInt(departure_time.minute))) diff --git a/app/javascript/vehicle_journeys/components/VehicleJourney.js b/app/javascript/vehicle_journeys/components/VehicleJourney.js index 929cbc5c4..bde673345 100644 --- a/app/javascript/vehicle_journeys/components/VehicleJourney.js +++ b/app/javascript/vehicle_journeys/components/VehicleJourney.js @@ -83,6 +83,7 @@ export default class VehicleJourney extends Component { className='form-control' disabled={this.isDisabled(this.props.value.deletable, vj.dummy) || this.props.filters.policy['vehicle_journeys.update'] == false} readOnly={!this.props.editMode && !vj.dummy} + disabled={!this.props.editMode && !vj.dummy} onChange={(e) => {this.props.onUpdateTime(e, i, this.props.index, 'hour', false, false)}} value={vj.arrival_time['hour']} /> @@ -94,6 +95,7 @@ export default class VehicleJourney extends Component { className='form-control' disabled={this.isDisabled(this.props.value.deletable, vj.dummy) || this.props.filters.policy['vehicle_journeys.update'] == false} readOnly={!this.props.editMode && !vj.dummy} + disabled={!this.props.editMode && !vj.dummy} onChange={(e) => {this.props.onUpdateTime(e, i, this.props.index, 'minute', false, false)}} value={vj.arrival_time['minute']} /> @@ -114,6 +116,7 @@ export default class VehicleJourney extends Component { className='form-control' disabled={this.isDisabled(this.props.value.deletable, vj.dummy) || this.props.filters.policy['vehicle_journeys.update'] == false} readOnly={!this.props.editMode && !vj.dummy} + disabled={!this.props.editMode && !vj.dummy} onChange={(e) => {this.props.onUpdateTime(e, i, this.props.index, 'hour', true, this.props.filters.toggleArrivals)}} value={vj.departure_time['hour']} /> @@ -125,6 +128,7 @@ export default class VehicleJourney extends Component { className='form-control' disabled={this.isDisabled(this.props.value.deletable, vj.dummy) || this.props.filters.policy['vehicle_journeys.update'] == false} readOnly={!this.props.editMode && !vj.dummy} + disabled={!this.props.editMode && !vj.dummy} onChange={(e) => {this.props.onUpdateTime(e, i, this.props.index, "minute", true, this.props.filters.toggleArrivals)}} value={vj.departure_time['minute']} /> @@ -144,4 +148,4 @@ VehicleJourney.propTypes = { index: PropTypes.number.isRequired, onUpdateTime: PropTypes.func.isRequired, onSelectVehicleJourney: PropTypes.func.isRequired -} \ No newline at end of file +} diff --git a/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js b/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js index 136e1b41a..7fed867fa 100644 --- a/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js +++ b/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js @@ -79,18 +79,12 @@ const vehicleJourney= (state = {}, action, keep) => { if (action.isDeparture){ newSchedule.departure_time[action.timeUnit] = actions.pad(action.val, action.timeUnit) if(!action.isArrivalsToggled) - newSchedule.arrival_time[action.timeUnit] = actions.pad(action.val, action.timeUnit) - newSchedule = actions.getDelta(newSchedule) - if(newSchedule.delta < 0){ - return vjas - } + newSchedule.arrival_time[action.timeUnit] = newSchedule.departure_time[action.timeUnit] + newSchedule = actions.adjustSchedule(action, newSchedule) return _.assign({}, state.vehicle_journey_at_stops[action.subIndex], {arrival_time: newSchedule.arrival_time, departure_time: newSchedule.departure_time, delta: newSchedule.delta}) }else{ newSchedule.arrival_time[action.timeUnit] = actions.pad(action.val, action.timeUnit) - newSchedule = actions.getDelta(newSchedule) - if(newSchedule.delta < 0){ - return vjas - } + newSchedule = actions.adjustSchedule(action, newSchedule) return _.assign({}, state.vehicle_journey_at_stops[action.subIndex], {arrival_time: newSchedule.arrival_time, departure_time: newSchedule.departure_time, delta: newSchedule.delta}) } }else{ @@ -225,4 +219,4 @@ export default function vehicleJourneys(state = [], action) { default: return state } -} \ No newline at end of file +} -- cgit v1.2.3 From 43dd9a4abc58b9c7cf2203a5e7125a7788bb33b3 Mon Sep 17 00:00:00 2001 From: Zog Date: Wed, 27 Dec 2017 08:36:47 +0100 Subject: Refs #5419; Fix actions policies Fix actions conditions on VehicleJourney#index --- app/javascript/vehicle_journeys/components/Tools.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/vehicle_journeys/components/Tools.js b/app/javascript/vehicle_journeys/components/Tools.js index 1ef576529..99ce78eb1 100644 --- a/app/javascript/vehicle_journeys/components/Tools.js +++ b/app/javascript/vehicle_journeys/components/Tools.js @@ -25,13 +25,13 @@ export default class Tools extends Component { return (