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 (
{actions.getSelected(vehicleJourneys).length} course(s) sélectionnée(s) -- cgit v1.2.3 From 78e2d256f895c1014a3def5f2ef6509086755215 Mon Sep 17 00:00:00 2001 From: Zog Date: Wed, 27 Dec 2017 09:10:56 +0100 Subject: Refs #5407 @4h; First UI implementation - Add most of the react code - And the specs where possible Still remains: - Link PurchaseWindows to VehicleJourneys in the model - Add an autocompletion endpoint --- app/javascript/packs/vehicle_journeys/index.js | 3 +- app/javascript/vehicle_journeys/actions/index.js | 34 +++++ .../components/SaveVehicleJourneys.js | 2 +- .../vehicle_journeys/components/Tools.js | 11 +- .../vehicle_journeys/components/VehicleJourney.js | 23 +++- .../vehicle_journeys/components/VehicleJourneys.js | 8 +- .../tools/PurchaseWindowsEditVehicleJourney.js | 150 +++++++++++++++++++++ .../tools/PurchaseWindowsEditVehicleJourney.js | 38 ++++++ app/javascript/vehicle_journeys/reducers/modal.js | 51 ++++++- .../vehicle_journeys/reducers/vehicleJourneys.js | 15 +++ 10 files changed, 328 insertions(+), 7 deletions(-) create mode 100644 app/javascript/vehicle_journeys/components/tools/PurchaseWindowsEditVehicleJourney.js create mode 100644 app/javascript/vehicle_journeys/containers/tools/PurchaseWindowsEditVehicleJourney.js (limited to 'app/javascript') diff --git a/app/javascript/packs/vehicle_journeys/index.js b/app/javascript/packs/vehicle_journeys/index.js index 38431af1d..7e57afb04 100644 --- a/app/javascript/packs/vehicle_journeys/index.js +++ b/app/javascript/packs/vehicle_journeys/index.js @@ -23,6 +23,7 @@ var initialState = { filters: { selectedJourneyPatterns : selectedJP, policy: window.perms, + features: window.features, toggleArrivals: false, queryString: '', query: { @@ -99,4 +100,4 @@ render( , document.getElementById('vehicle_journeys_wip') -) \ No newline at end of file +) diff --git a/app/javascript/vehicle_journeys/actions/index.js b/app/javascript/vehicle_journeys/actions/index.js index c82f759d6..d5eda629c 100644 --- a/app/javascript/vehicle_journeys/actions/index.js +++ b/app/javascript/vehicle_journeys/actions/index.js @@ -99,6 +99,30 @@ const actions = { vehicleJourneys, timetables }), + openPurchaseWindowsEditModal : (vehicleJourneys) => ({ + type : 'EDIT_PURCHASE_WINDOWS_VEHICLEJOURNEY_MODAL', + vehicleJourneys + }), + selectPurchaseWindowsModal: (selectedTT) =>({ + type: 'SELECT_PURCHASE_WINDOW_MODAL', + selectedItem:{ + id: selectedTT.id, + comment: selectedTT.comment, + objectid: selectedTT.objectid + } + }), + addSelectedPurchaseWindow: () => ({ + type: 'ADD_SELECTED_PURCHASE_WINDOW' + }), + deletePurchaseWindowsModal : (purchaseWindow) => ({ + type : 'DELETE_PURCHASE_WINDOW_MODAL', + purchaseWindow + }), + editVehicleJourneyPurchaseWindows : (vehicleJourneys, purchase_windows) => ({ + type: 'EDIT_VEHICLEJOURNEYS_PURCHASE_WINDOWS', + vehicleJourneys, + purchase_windows + }), openShiftModal : () => ({ type : 'SHIFT_VEHICLEJOURNEY_MODAL' }), @@ -313,6 +337,7 @@ const actions = { let val for (val of json.vehicle_journeys){ var timeTables = [] + var purchaseWindows = [] let tt for (tt of val.time_tables){ timeTables.push({ @@ -322,6 +347,14 @@ const actions = { color: tt.color }) } + for (tt of val.purchase_windows){ + purchaseWindows.push({ + objectid: tt.objectid, + name: tt.name, + id: tt.id, + color: tt.color + }) + } let vjasWithDelta = val.vehicle_journey_at_stops.map((vjas, i) => { actions.fillEmptyFields(vjas) return actions.getDelta(vjas) @@ -333,6 +366,7 @@ const actions = { short_id: val.short_id, footnotes: val.footnotes, time_tables: timeTables, + purchase_windows: purchaseWindows, vehicle_journey_at_stops: vjasWithDelta, deletable: false, selected: false, diff --git a/app/javascript/vehicle_journeys/components/SaveVehicleJourneys.js b/app/javascript/vehicle_journeys/components/SaveVehicleJourneys.js index e8c27f92e..285e2d506 100644 --- a/app/javascript/vehicle_journeys/components/SaveVehicleJourneys.js +++ b/app/javascript/vehicle_journeys/components/SaveVehicleJourneys.js @@ -39,4 +39,4 @@ SaveVehicleJourneys.propTypes = { filters: PropTypes.object.isRequired, onEnterEditMode: PropTypes.func.isRequired, onSubmitVehicleJourneys: PropTypes.func.isRequired -} \ No newline at end of file +} diff --git a/app/javascript/vehicle_journeys/components/Tools.js b/app/javascript/vehicle_journeys/components/Tools.js index 99ce78eb1..be32552b9 100644 --- a/app/javascript/vehicle_journeys/components/Tools.js +++ b/app/javascript/vehicle_journeys/components/Tools.js @@ -7,6 +7,7 @@ import DuplicateVehicleJourney from '../containers/tools/DuplicateVehicleJourney import EditVehicleJourney from '../containers/tools/EditVehicleJourney' import NotesEditVehicleJourney from '../containers/tools/NotesEditVehicleJourney' import TimetablesEditVehicleJourney from '../containers/tools/TimetablesEditVehicleJourney' +import PurchaseWindowsEditVehicleJourney from '../containers/tools/PurchaseWindowsEditVehicleJourney' export default class Tools extends Component { @@ -20,6 +21,11 @@ export default class Tools extends Component { return this.props.filters.policy[`vehicle_journeys.${key}`] } + hasFeature(key) { + // Check if the organisation has the given feature + return this.props.filters.features[key] + } + render() { let { vehicleJourneys, onCancelSelection, editMode } = this.props return ( @@ -30,6 +36,9 @@ export default class Tools extends Component { + { this.hasFeature('purchase_windows') && + + } @@ -44,5 +53,5 @@ export default class Tools extends Component { Tools.propTypes = { vehicleJourneys : PropTypes.array.isRequired, onCancelSelection: PropTypes.func.isRequired, - filters: PropTypes.object.isRequired + filters: PropTypes.object.isRequired, } diff --git a/app/javascript/vehicle_journeys/components/VehicleJourney.js b/app/javascript/vehicle_journeys/components/VehicleJourney.js index bde673345..7a89bcc66 100644 --- a/app/javascript/vehicle_journeys/components/VehicleJourney.js +++ b/app/javascript/vehicle_journeys/components/VehicleJourney.js @@ -17,6 +17,10 @@ export default class VehicleJourney extends Component { return bool } + hasFeature(key) { + return this.props.filters.features[key] + } + timeTableURL(tt) { let refURL = window.location.pathname.split('/', 3).join('/') let ttURL = refURL + '/time_tables/' + tt.id @@ -26,6 +30,15 @@ export default class VehicleJourney extends Component { ) } + purchaseWindowURL(tt) { + let refURL = window.location.pathname.split('/', 3).join('/') + let ttURL = refURL + '/purchase_windows/' + tt.id + + return ( + + ) + } + columnHasDelta() { let a = [] this.props.value.vehicle_journey_at_stops.map((vj, i) => { @@ -44,7 +57,7 @@ export default class VehicleJourney extends Component { render() { this.previousCity = undefined - let {time_tables} = this.props.value + let {time_tables, purchase_windows} = this.props.value return (
@@ -57,6 +70,14 @@ export default class VehicleJourney extends Component { )} {time_tables.length > 3 && + {time_tables.length - 3}}
+ { this.hasFeature('purchase_windows') && +
+ {purchase_windows.slice(0,3).map((tt, i)=> + {this.purchaseWindowURL(tt)} + )} + {purchase_windows.length > 3 && + {purchase_windows.length - 3}} +
+ }
ID course
ID mission
Calendriers
+ { this.hasFeature('purchase_windows') &&
Calendriers Commerciaux
}
{this.props.stopPointsList.map((sp, i) =>{ return ( @@ -132,6 +137,7 @@ export default class VehicleJourneys extends Component { index={index} editMode={this.props.editMode} filters={this.props.filters} + features={this.props.features} onUpdateTime={this.props.onUpdateTime} onSelectVehicleJourney={this.props.onSelectVehicleJourney} /> @@ -153,4 +159,4 @@ VehicleJourneys.propTypes = { onLoadFirstPage: PropTypes.func.isRequired, onUpdateTime: PropTypes.func.isRequired, onSelectVehicleJourney: PropTypes.func.isRequired -} \ No newline at end of file +} diff --git a/app/javascript/vehicle_journeys/components/tools/PurchaseWindowsEditVehicleJourney.js b/app/javascript/vehicle_journeys/components/tools/PurchaseWindowsEditVehicleJourney.js new file mode 100644 index 000000000..cf51e50f0 --- /dev/null +++ b/app/javascript/vehicle_journeys/components/tools/PurchaseWindowsEditVehicleJourney.js @@ -0,0 +1,150 @@ +import React, { PropTypes, Component } from 'react' +import actions from '../../actions' +import TimetableSelect2 from './select2s/TimetableSelect2' + +export default class PurchaseWindowsEditVehicleJourney extends Component { + constructor(props) { + super(props) + this.handleSubmit = this.handleSubmit.bind(this) + this.purchaseWindowURL = this.purchaseWindowURL.bind(this) + } + + handleSubmit() { + this.props.onTimetablesEditVehicleJourney(this.props.modal.modalProps.vehicleJourneys, this.props.modal.modalProps.purchase_windows) + this.props.onModalClose() + $('#PurchaseWindowsEditVehicleJourneyModal').modal('hide') + } + + purchaseWindowURL(tt) { + let refURL = window.location.pathname.split('/', 3).join('/') + return refURL + '/purchase_windows/' + tt.id + } + + render() { + if(this.props.status.isFetching == true) { + return false + } + if(this.props.status.fetchSuccess == true) { + return ( +
  • + + +
    +
    +
    +
    +
    +

    Calendriers commerciaux associés

    + × +
    + + {(this.props.modal.type == 'purchase_windows_edit') && ( +
    +
    +
    +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    + {this.props.modal.modalProps.purchase_windows.map((tt, i) => + + )} + { + this.props.editMode && +
    +
    +
    + +
    +
    +
    + } +
    +
    +
    +
    + { + this.props.editMode && +
    + + +
    + } +
    + )} + +
    +
    +
    +
    +
  • + ) + } else { + return false + } + } +} + +PurchaseWindowsEditVehicleJourney.propTypes = { + onOpenCalendarsEditModal: PropTypes.func.isRequired, + onModalClose: PropTypes.func.isRequired, + onTimetablesEditVehicleJourney: PropTypes.func.isRequired, + onDeleteCalendarModal: PropTypes.func.isRequired, + onSelect2Timetable: PropTypes.func.isRequired, + disabled: PropTypes.bool.isRequired +} diff --git a/app/javascript/vehicle_journeys/containers/tools/PurchaseWindowsEditVehicleJourney.js b/app/javascript/vehicle_journeys/containers/tools/PurchaseWindowsEditVehicleJourney.js new file mode 100644 index 000000000..f81c8fa72 --- /dev/null +++ b/app/javascript/vehicle_journeys/containers/tools/PurchaseWindowsEditVehicleJourney.js @@ -0,0 +1,38 @@ +import actions from '../../actions' +import { connect } from 'react-redux' +import PurchaseWindowsEditVehicleJourneyComponent from '../../components/tools/PurchaseWindowsEditVehicleJourney' + +const mapStateToProps = (state, ownProps) => { + return { + editMode: state.editMode, + modal: state.modal, + vehicleJourneys: state.vehicleJourneys, + status: state.status, + disabled: ownProps.disabled + } +} + +const mapDispatchToProps = (dispatch) => { + return { + onModalClose: () =>{ + dispatch(actions.closeModal()) + }, + onOpenCalendarsEditModal: (vehicleJourneys) =>{ + dispatch(actions.openPurchaseWindowsEditModal(vehicleJourneys)) + }, + onDeleteCalendarModal: (timetable) => { + dispatch(actions.deletePurchaseWindowsModal(timetable)) + }, + onTimetablesEditVehicleJourney: (vehicleJourneys, timetables) =>{ + dispatch(actions.editVehicleJourneyPurchaseWindows(vehicleJourneys, timetables)) + }, + onSelect2Timetable: (e) =>{ + dispatch(actions.selectPurchaseWindowsModal(e.params.data)) + dispatch(actions.addSelectedPurchaseWindow()) + } + } +} + +const PurchaseWindowsEditVehicleJourney = connect(mapStateToProps, mapDispatchToProps)(PurchaseWindowsEditVehicleJourneyComponent) + +export default PurchaseWindowsEditVehicleJourney diff --git a/app/javascript/vehicle_journeys/reducers/modal.js b/app/javascript/vehicle_journeys/reducers/modal.js index 57f54a144..862e27e1b 100644 --- a/app/javascript/vehicle_journeys/reducers/modal.js +++ b/app/javascript/vehicle_journeys/reducers/modal.js @@ -40,7 +40,6 @@ export default function modal(state = {}, action) { case 'EDIT_CALENDARS_VEHICLEJOURNEY_MODAL': vehicleJourneysModal = JSON.parse(JSON.stringify(action.vehicleJourneys)) let uniqTimetables = [] - let timetable = {} vehicleJourneysModal.map((vj, i) => { vj.time_tables.map((tt, j) =>{ if(!(_.find(uniqTimetables, tt))){ @@ -56,6 +55,24 @@ export default function modal(state = {}, action) { }, confirmModal: {} } + case 'EDIT_PURCHASE_WINDOWS_VEHICLEJOURNEY_MODAL': + var vehicleJourneys = JSON.parse(JSON.stringify(action.vehicleJourneys)) + let uniqPurchaseWindows = [] + vehicleJourneys.map((vj, i) => { + vj.purchase_windows.map((pw, j) =>{ + if(!(_.find(uniqPurchaseWindows, pw))){ + uniqPurchaseWindows.push(pw) + } + }) + }) + return { + type: 'purchase_windows_edit', + modalProps: { + vehicleJourneys: vehicleJourneys, + purchase_windows: uniqPurchaseWindows + }, + confirmModal: {} + } case 'SELECT_CP_EDIT_MODAL': newModalProps = _.assign({}, state.modalProps, {selectedCompany : action.selectedItem}) return _.assign({}, state, {modalProps: newModalProps}) @@ -65,6 +82,9 @@ export default function modal(state = {}, action) { case 'SELECT_TT_CALENDAR_MODAL': newModalProps = _.assign({}, state.modalProps, {selectedTimetable : action.selectedItem}) return _.assign({}, state, {modalProps: newModalProps}) + case 'SELECT_PURCHASE_WINDOW_MODAL': + newModalProps = _.assign({}, state.modalProps, {selectedPurchaseWindow : action.selectedItem}) + return _.assign({}, state, {modalProps: newModalProps}) case 'ADD_SELECTED_TIMETABLE': if(state.modalProps.selectedTimetable){ newModalProps = JSON.parse(JSON.stringify(state.modalProps)) @@ -73,6 +93,14 @@ export default function modal(state = {}, action) { } return _.assign({}, state, {modalProps: newModalProps}) } + case 'ADD_SELECTED_PURCHASE_WINDOW': + if(state.modalProps.selectedPurchaseWindow){ + newModalProps = JSON.parse(JSON.stringify(state.modalProps)) + if (!_.find(newModalProps.purchase_windows, newModalProps.selectedPurchaseWindow)){ + newModalProps.purchase_windows.push(newModalProps.selectedPurchaseWindow) + } + return _.assign({}, state, {modalProps: newModalProps}) + } case 'DELETE_CALENDAR_MODAL': newModalProps = JSON.parse(JSON.stringify(state.modalProps)) let timetablesModal = state.modalProps.timetables.slice(0) @@ -92,6 +120,25 @@ export default function modal(state = {}, action) { newModalProps.vehicleJourneys = vehicleJourneysModal newModalProps.timetables = timetablesModal return _.assign({}, state, {modalProps: newModalProps}) + case 'DELETE_PURCHASE_WINDOW_MODAL': + newModalProps = JSON.parse(JSON.stringify(state.modalProps)) + let purchase_windows = state.modalProps.purchase_windows.slice(0) + purchase_windows.map((tt, i) =>{ + if(tt == action.purchaseWindow){ + purchase_windows.splice(i, 1) + } + }) + vehicleJourneysModal = state.modalProps.vehicleJourneys.slice(0) + vehicleJourneysModal.map((vj) =>{ + vj.purchase_windows.map((tt, i) =>{ + if (_.isEqual(tt, action.purchaseWindow)){ + vj.purchase_windows.splice(i, 1) + } + }) + }) + newModalProps.vehicleJourneys = vehicleJourneysModal + newModalProps.purchase_windows = purchase_windows + return _.assign({}, state, {modalProps: newModalProps}) case 'CREATE_VEHICLEJOURNEY_MODAL': let selectedJP = {} if (window.jpOrigin){ @@ -135,4 +182,4 @@ export default function modal(state = {}, action) { default: return state } -} \ 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 7fed867fa..15d6abe38 100644 --- a/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js +++ b/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js @@ -155,6 +155,21 @@ export default function vehicleJourneys(state = [], action) { return vj } }) + case 'EDIT_VEHICLEJOURNEYS_PURCHASE_WINDOWS': + let newWindows = JSON.parse(JSON.stringify(action.purchase_windows)) + return state.map((vj,i) =>{ + if(vj.selected){ + let updatedVJ = _.assign({}, vj) + action.vehicleJourneys.map((vjm, j) =>{ + if(vj.objectid == vjm.objectid){ + updatedVJ.purchase_windows = newWindows + } + }) + return updatedVJ + }else{ + return vj + } + }) case 'SHIFT_VEHICLEJOURNEY': return state.map((vj, i) => { if (vj.selected){ -- cgit v1.2.3 From 607fa5e03289a10b60a773bc40af38f1d721bbea Mon Sep 17 00:00:00 2001 From: Zog Date: Wed, 27 Dec 2017 13:42:39 +0100 Subject: Refs #5407 @2h; Model implementation - Link PurchaseWindows to VehicleJourneys in the model - Add an autocompletion endpoint --- app/javascript/vehicle_journeys/actions/index.js | 3 ++- app/javascript/vehicle_journeys/components/Filters.js | 3 ++- .../components/tools/PurchaseWindowsEditVehicleJourney.js | 1 + .../components/tools/TimetablesEditVehicleJourney.js | 9 +++++---- .../components/tools/select2s/TimetableSelect2.js | 14 ++++++-------- 5 files changed, 16 insertions(+), 14 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/vehicle_journeys/actions/index.js b/app/javascript/vehicle_journeys/actions/index.js index d5eda629c..9a5ca940b 100644 --- a/app/javascript/vehicle_journeys/actions/index.js +++ b/app/javascript/vehicle_journeys/actions/index.js @@ -107,7 +107,8 @@ const actions = { type: 'SELECT_PURCHASE_WINDOW_MODAL', selectedItem:{ id: selectedTT.id, - comment: selectedTT.comment, + name: selectedTT.name, + color: selectedTT.color, objectid: selectedTT.objectid } }), diff --git a/app/javascript/vehicle_journeys/components/Filters.js b/app/javascript/vehicle_journeys/components/Filters.js index db6707520..3bc4f7ff7 100644 --- a/app/javascript/vehicle_journeys/components/Filters.js +++ b/app/javascript/vehicle_journeys/components/Filters.js @@ -33,6 +33,7 @@ export default function Filters({filters, pagination, onFilter, onResetFilters, onSelect2Timetable={onSelect2Timetable} hasRoute={true} chunkURL={("/autocomplete_time_tables.json?route_id=" + String(window.route_id))} + searchKey={"comment_or_objectid_cont_any"} filters={filters} isFilter={true} /> @@ -165,4 +166,4 @@ Filters.propTypes = { onSelect2Timetable: PropTypes.func.isRequired, onSelect2JourneyPattern: PropTypes.func.isRequired, onSelect2VehicleJourney: PropTypes.func.isRequired -} \ No newline at end of file +} diff --git a/app/javascript/vehicle_journeys/components/tools/PurchaseWindowsEditVehicleJourney.js b/app/javascript/vehicle_journeys/components/tools/PurchaseWindowsEditVehicleJourney.js index cf51e50f0..5465127e8 100644 --- a/app/javascript/vehicle_journeys/components/tools/PurchaseWindowsEditVehicleJourney.js +++ b/app/javascript/vehicle_journeys/components/tools/PurchaseWindowsEditVehicleJourney.js @@ -95,6 +95,7 @@ export default class PurchaseWindowsEditVehicleJourney extends Component { diff --git a/app/javascript/vehicle_journeys/components/tools/TimetablesEditVehicleJourney.js b/app/javascript/vehicle_journeys/components/tools/TimetablesEditVehicleJourney.js index 6629135dd..26377c0d5 100644 --- a/app/javascript/vehicle_journeys/components/tools/TimetablesEditVehicleJourney.js +++ b/app/javascript/vehicle_journeys/components/tools/TimetablesEditVehicleJourney.js @@ -67,7 +67,7 @@ export default class TimetablesEditVehicleJourney extends Component {
    {tt.comment}
    { - this.props.editMode && + this.props.editMode &&
    )} { - this.props.editMode && + this.props.editMode &&
    @@ -103,7 +104,7 @@ export default class TimetablesEditVehicleJourney extends Component {
    { - this.props.editMode && + this.props.editMode &&
    diff --git a/app/javascript/vehicle_journeys/components/tools/TimetablesEditVehicleJourney.js b/app/javascript/vehicle_journeys/components/tools/TimetablesEditVehicleJourney.js index 26377c0d5..56f80ebb5 100644 --- a/app/javascript/vehicle_journeys/components/tools/TimetablesEditVehicleJourney.js +++ b/app/javascript/vehicle_journeys/components/tools/TimetablesEditVehicleJourney.js @@ -33,6 +33,7 @@ export default class TimetablesEditVehicleJourney extends Component { data-toggle='modal' data-target='#CalendarsEditVehicleJourneyModal' onClick={() => this.props.onOpenCalendarsEditModal(actions.getSelected(this.props.vehicleJourneys))} + title='Calendriers' > -- cgit v1.2.3 From 590c63521cc29a3704e93f326e8f9b7c300b71d8 Mon Sep 17 00:00:00 2001 From: Zog Date: Wed, 27 Dec 2017 15:40:25 +0100 Subject: Refs #5407; Add cancel button on VehicleJourneys editor --- .../components/SaveVehicleJourneys.js | 32 +++++++++++++++------- .../containers/SaveVehicleJourneys.js | 4 +++ 2 files changed, 26 insertions(+), 10 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/vehicle_journeys/components/SaveVehicleJourneys.js b/app/javascript/vehicle_journeys/components/SaveVehicleJourneys.js index 285e2d506..5e69af301 100644 --- a/app/javascript/vehicle_journeys/components/SaveVehicleJourneys.js +++ b/app/javascript/vehicle_journeys/components/SaveVehicleJourneys.js @@ -14,16 +14,27 @@ export default class SaveVehicleJourneys extends Component{
    {e.preventDefault()}}> - +
    + + {this.props.editMode && + } +
    @@ -38,5 +49,6 @@ SaveVehicleJourneys.propTypes = { status: PropTypes.object.isRequired, filters: PropTypes.object.isRequired, onEnterEditMode: PropTypes.func.isRequired, + onExitEditMode: PropTypes.func.isRequired, onSubmitVehicleJourneys: PropTypes.func.isRequired } diff --git a/app/javascript/vehicle_journeys/containers/SaveVehicleJourneys.js b/app/javascript/vehicle_journeys/containers/SaveVehicleJourneys.js index 18f9e994e..f5f879ed8 100644 --- a/app/javascript/vehicle_journeys/containers/SaveVehicleJourneys.js +++ b/app/javascript/vehicle_journeys/containers/SaveVehicleJourneys.js @@ -17,6 +17,10 @@ const mapDispatchToProps = (dispatch) => { onEnterEditMode: () => { dispatch(actions.enterEditMode()) }, + onExitEditMode: () => { + dispatch(actions.cancelSelection()) + dispatch(actions.exitEditMode()) + }, onSubmitVehicleJourneys: (next, state) => { actions.submitVehicleJourneys(dispatch, state, next) } -- cgit v1.2.3 From 6f182a9e12094297818745752e592dc11511563e Mon Sep 17 00:00:00 2001 From: Zog Date: Wed, 27 Dec 2017 15:53:51 +0100 Subject: Refs #5407; Make Journeys easier to select --- app/javascript/vehicle_journeys/components/VehicleJourney.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'app/javascript') diff --git a/app/javascript/vehicle_journeys/components/VehicleJourney.js b/app/javascript/vehicle_journeys/components/VehicleJourney.js index 7a89bcc66..54fe1f1b6 100644 --- a/app/javascript/vehicle_journeys/components/VehicleJourney.js +++ b/app/javascript/vehicle_journeys/components/VehicleJourney.js @@ -61,7 +61,12 @@ export default class VehicleJourney extends Component { return (
    -
    +
    + ($(e.target).parents("a").length == 0) && this.props.editMode && this.props.onSelectVehicleJourney(this.props.index) + } + >
    {this.props.value.short_id || '-'}
    {this.props.value.journey_pattern.short_id || '-'}
    -- cgit v1.2.3 From 3792c128de8a2355ce6b4ceb28e7ee8afdf060c7 Mon Sep 17 00:00:00 2001 From: Zog Date: Wed, 27 Dec 2017 16:03:55 +0100 Subject: Refs #5407; Disable edition mode while editor is loading --- app/javascript/packs/vehicle_journeys/index.js | 2 +- app/javascript/vehicle_journeys/components/SaveVehicleJourneys.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/packs/vehicle_journeys/index.js b/app/javascript/packs/vehicle_journeys/index.js index 7e57afb04..53c5d5417 100644 --- a/app/javascript/packs/vehicle_journeys/index.js +++ b/app/javascript/packs/vehicle_journeys/index.js @@ -55,7 +55,7 @@ var initialState = { }, status: { - fetchSuccess: true, + fetchSuccess: false, isFetching: false }, vehicleJourneys: [], diff --git a/app/javascript/vehicle_journeys/components/SaveVehicleJourneys.js b/app/javascript/vehicle_journeys/components/SaveVehicleJourneys.js index 5e69af301..8bab5baa9 100644 --- a/app/javascript/vehicle_journeys/components/SaveVehicleJourneys.js +++ b/app/javascript/vehicle_journeys/components/SaveVehicleJourneys.js @@ -16,7 +16,7 @@ export default class SaveVehicleJourneys extends Component{
    {e.preventDefault()}}>
    - {this.props.editMode && - }
    -- cgit v1.2.3 From ad537be88672bc6472925685e3e204ef562ad8c9 Mon Sep 17 00:00:00 2001 From: Xinhui Date: Thu, 4 Jan 2018 14:22:45 +0100 Subject: Display checksum for journey patterns -m Refs --- app/javascript/journey_patterns/actions/index.js | 3 ++- app/javascript/journey_patterns/components/EditModal.js | 13 +++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/journey_patterns/actions/index.js b/app/javascript/journey_patterns/actions/index.js index 4ff3f77ea..1c2eb68b2 100644 --- a/app/javascript/journey_patterns/actions/index.js +++ b/app/javascript/journey_patterns/actions/index.js @@ -198,6 +198,7 @@ const actions = { name: val.name, object_id: val.object_id, short_id: val.short_id, + checksum: val.checksum, published_name: val.published_name, registration_number: val.registration_number, stop_points: val.route_short_description.stop_points, @@ -217,4 +218,4 @@ const actions = { } } -export default actions \ No newline at end of file +export default actions diff --git a/app/javascript/journey_patterns/components/EditModal.js b/app/javascript/journey_patterns/components/EditModal.js index e7ce24aa1..29154da3c 100644 --- a/app/javascript/journey_patterns/components/EditModal.js +++ b/app/javascript/journey_patterns/components/EditModal.js @@ -36,10 +36,19 @@ export default class EditModal extends Component { {this.renderModalTitle()} ×
    - {(this.props.modal.type == 'edit') && (
    +
    + + +
    {this.props.value.short_id || '-'}
    {this.props.value.published_journey_name && this.props.value.published_journey_name != "non renseigné" ? this.props.value.published_journey_name : '-'}
    +
    {this.props.value.company ? this.props.value.company.name : '-'}
    {this.props.value.journey_pattern.short_id || '-'}
    {time_tables.slice(0,3).map((tt, i)=> diff --git a/app/javascript/vehicle_journeys/components/VehicleJourneys.js b/app/javascript/vehicle_journeys/components/VehicleJourneys.js index dc480d6b4..0cac0344c 100644 --- a/app/javascript/vehicle_journeys/components/VehicleJourneys.js +++ b/app/javascript/vehicle_journeys/components/VehicleJourneys.js @@ -117,6 +117,7 @@ export default class VehicleJourneys extends Component {
    ID course
    Nom course
    ID mission
    +
    Transporteur
    Calendriers
    { this.hasFeature('purchase_windows') &&
    Calendriers Commerciaux
    }
    -- cgit v1.2.3 From 08a8710e0b723f3e1a418617c8e6168fc7bddb7f Mon Sep 17 00:00:00 2001 From: Xinhui Date: Thu, 4 Jan 2018 15:21:38 +0100 Subject: Display checksum for vehicle journeys -m Refs Templating display checksum Refs #5460 --- .../journey_patterns/components/EditModal.js | 20 ++++---- .../components/tools/EditVehicleJourney.js | 54 +++++++++++++--------- 2 files changed, 43 insertions(+), 31 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/journey_patterns/components/EditModal.js b/app/javascript/journey_patterns/components/EditModal.js index 29154da3c..7a5d24fba 100644 --- a/app/javascript/journey_patterns/components/EditModal.js +++ b/app/javascript/journey_patterns/components/EditModal.js @@ -39,16 +39,6 @@ export default class EditModal extends Component { {(this.props.modal.type == 'edit') && (
    -
    - - -
    +
    + + +
    { this.props.editMode && diff --git a/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js b/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js index f8d6add03..463967463 100644 --- a/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js +++ b/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js @@ -52,32 +52,44 @@ export default class EditVehicleJourney extends Component { {(this.props.modal.type == 'edit') && (
    -
    -
    +
    - - Signature métier + actions.resetValidation(e.currentTarget)} + disabled='disabled' + defaultValue={this.props.modal.modalProps.vehicleJourney.checksum} />
    -
    -
    - - +
    +
    +
    + + actions.resetValidation(e.currentTarget)} + /> +
    +
    +
    +
    + + +
    -
    @@ -133,7 +145,7 @@ export default class EditVehicleJourney extends Component {
    { - this.props.editMode && + this.props.editMode &&
    - } + } )} @@ -171,4 +183,4 @@ EditVehicleJourney.propTypes = { onOpenEditModal: PropTypes.func.isRequired, onModalClose: PropTypes.func.isRequired, disabled: PropTypes.bool.isRequired -} \ No newline at end of file +} -- cgit v1.2.3 From 31181301b50f2785db65715a781c313f0b5562ad Mon Sep 17 00:00:00 2001 From: Xinhui Date: Fri, 5 Jan 2018 16:58:43 +0100 Subject: Templating display checksum Refs #5460 --- .../components/tools/EditVehicleJourney.js | 23 +++++++++++----------- 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js b/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js index 463967463..cad04ed0e 100644 --- a/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js +++ b/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js @@ -52,18 +52,6 @@ export default class EditVehicleJourney extends Component { {(this.props.modal.type == 'edit') && (
    -
    -
    - - -
    -
    @@ -143,6 +131,17 @@ export default class EditVehicleJourney extends Component {
    +
    + + +
    +
    { this.props.editMode && -- cgit v1.2.3 From 913d6935727ace3ac94c08adb4e1ec378741fb19 Mon Sep 17 00:00:00 2001 From: Zog Date: Wed, 3 Jan 2018 16:31:33 +0100 Subject: Refs #5455 @6h; Add time and distance between stops in Journey Patterns - Adds a `JSON` attribute in the model - Adds the fields in the editor --- app/javascript/journey_patterns/actions/index.js | 14 +++++ .../journey_patterns/components/JourneyPattern.js | 73 ++++++++++++++++++++-- .../journey_patterns/components/JourneyPatterns.js | 3 +- .../containers/JourneyPatternList.js | 5 +- .../journey_patterns/reducers/journeyPatterns.js | 16 ++++- app/javascript/packs/journey_patterns/index.js | 1 + 6 files changed, 103 insertions(+), 9 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/journey_patterns/actions/index.js b/app/javascript/journey_patterns/actions/index.js index 1c2eb68b2..09e2001c1 100644 --- a/app/javascript/journey_patterns/actions/index.js +++ b/app/javascript/journey_patterns/actions/index.js @@ -64,6 +64,11 @@ const actions = { type : 'DELETE_JOURNEYPATTERN', index, }), + updateJourneyPatternCosts : (index, costs) => ({ + type : 'UPDATE_JOURNEYPATTERN_COSTS', + index, + costs + }), closeModal : () => ({ type : 'CLOSE_MODAL' }), @@ -194,6 +199,7 @@ const actions = { } }) } +<<<<<<< HEAD journeyPatterns.push({ name: val.name, object_id: val.object_id, @@ -204,6 +210,14 @@ const actions = { stop_points: val.route_short_description.stop_points, deletable: false }) +======= + journeyPatterns.push( + _.assign({}, val, { + stop_points: val.route_short_description.stop_points, + deletable: false + }) + ) +>>>>>>> Refs #5455 @6h; Add time and distance between stops in Journey Patterns } } window.currentItemsLength = journeyPatterns.length diff --git a/app/javascript/journey_patterns/components/JourneyPattern.js b/app/javascript/journey_patterns/components/JourneyPattern.js index d4c9816ec..40a6899e2 100644 --- a/app/javascript/journey_patterns/components/JourneyPattern.js +++ b/app/javascript/journey_patterns/components/JourneyPattern.js @@ -5,6 +5,17 @@ export default class JourneyPattern extends Component{ constructor(props){ super(props) this.previousCity = undefined + this.previousSpId = undefined + this.updateCosts = this.updateCosts.bind(this) + } + + updateCosts(e) { + let costs = { + [e.target.dataset.costsKey]: { + [e.target.name]: parseInt(e.target.value) + } + } + this.props.onUpdateJourneyPatternCosts(costs) } vehicleJourneyURL(jpOid) { @@ -16,16 +27,26 @@ export default class JourneyPattern extends Component{ ) } + hasFeature(key) { + return this.props.status.features[key] + } + cityNameChecker(sp) { let bool = false + if(sp.city_name != this.previousCity){ bool = true this.previousCity = sp.city_name } + return bool + } + + spNode(sp, headlined){ return (
    +
    this.props.onCheckboxChange(e)} @@ -61,9 +82,9 @@ export default class JourneyPattern extends Component{ render() { this.previousCity = undefined - + this.previousSpId = undefined return ( -
    +
    {/* Errors */} {/* this.props.value.errors ? this.getErrors(this.props.value.errors) : '' */} @@ -112,9 +133,49 @@ export default class JourneyPattern extends Component{
    {this.props.value.stop_points.map((stopPoint, i) =>{ + let costs = null + let costsKey = null + let time = null + let distance = null + let time_in_words = null + if(this.previousSpId && stopPoint.checked){ + costsKey = this.previousSpId + "-" + stopPoint.id + costs = this.props.value.costs[costsKey] || {distance: 0, time: 0} + time = costs['time'] || 0 + distance = costs['distance'] || 0 + if(time < 60){ + time_in_words = time + " min" + } + else{ + let hours = parseInt(time/60) + time_in_words = hours + " h " + (time - 60*hours) + " min" + } + } + if(stopPoint.checked){ + this.previousSpId = stopPoint.id + } + let headlined = this.cityNameChecker(stopPoint) return ( -
    - {this.cityNameChecker(stopPoint)} +
    +
    + {this.spNode(stopPoint, headlined)} +
    + {this.hasFeature('costs_in_journey_patterns') && costs &&
    + {this.props.editMode &&
    +

    + + km +

    +

    + + min +

    +
    } + {!this.props.editMode &&
    +

    {(costs['distance'] || 0) + " km"}

    +

    {time_in_words}

    +
    } +
    }
    ) })} @@ -129,4 +190,4 @@ JourneyPattern.propTypes = { onCheckboxChange: PropTypes.func.isRequired, onOpenEditModal: PropTypes.func.isRequired, onDeleteJourneyPattern: PropTypes.func.isRequired -} \ No newline at end of file +} diff --git a/app/javascript/journey_patterns/components/JourneyPatterns.js b/app/javascript/journey_patterns/components/JourneyPatterns.js index 4b2badabb..69024050f 100644 --- a/app/javascript/journey_patterns/components/JourneyPatterns.js +++ b/app/javascript/journey_patterns/components/JourneyPatterns.js @@ -131,6 +131,7 @@ export default class JourneyPatterns extends Component { onCheckboxChange= {(e) => this.props.onCheckboxChange(e, index)} onOpenEditModal= {() => this.props.onOpenEditModal(index, journeyPattern)} onDeleteJourneyPattern={() => this.props.onDeleteJourneyPattern(index)} + onUpdateJourneyPatternCosts={(costs) => this.props.onUpdateJourneyPatternCosts(index, costs)} status= {this.props.status} editMode= {this.props.editMode} /> @@ -152,4 +153,4 @@ JourneyPatterns.propTypes = { onCheckboxChange: PropTypes.func.isRequired, onLoadFirstPage: PropTypes.func.isRequired, onOpenEditModal: PropTypes.func.isRequired -} \ No newline at end of file +} diff --git a/app/javascript/journey_patterns/containers/JourneyPatternList.js b/app/javascript/journey_patterns/containers/JourneyPatternList.js index d98734407..d338345f2 100644 --- a/app/javascript/journey_patterns/containers/JourneyPatternList.js +++ b/app/javascript/journey_patterns/containers/JourneyPatternList.js @@ -25,7 +25,10 @@ const mapDispatchToProps = (dispatch) => { }, onDeleteJourneyPattern: (index) =>{ dispatch(actions.deleteJourneyPattern(index)) - } + }, + onUpdateJourneyPatternCosts: (index, costs) =>{ + dispatch(actions.updateJourneyPatternCosts(index, costs)) + }, } } diff --git a/app/javascript/journey_patterns/reducers/journeyPatterns.js b/app/javascript/journey_patterns/reducers/journeyPatterns.js index 0bbcba976..1ce069522 100644 --- a/app/javascript/journey_patterns/reducers/journeyPatterns.js +++ b/app/javascript/journey_patterns/reducers/journeyPatterns.js @@ -17,6 +17,7 @@ const journeyPattern = (state = {}, action) =>{ published_name: action.data.published_name.value, registration_number: action.data.registration_number.value, stop_points: stopPoints, + costs: {}, deletable: false } case 'UPDATE_CHECKBOX_VALUE': @@ -67,6 +68,19 @@ export default function journeyPatterns (state = [], action) { return j } }) + case 'UPDATE_JOURNEYPATTERN_COSTS': + return state.map((j, i) =>{ + if(i == action.index) { + const new_costs = Object.assign({}, j.costs) + Object.keys(action.costs).map((key) => { + let new_costs_for_key = Object.assign({}, j.costs[key] || {}, action.costs[key]) + new_costs[key] = new_costs_for_key + }) + return _.assign({}, j, {costs: new_costs}) + } else { + return j + } + }) case 'ADD_JOURNEYPATTERN': return [ journeyPattern(state, action), @@ -87,4 +101,4 @@ export default function journeyPatterns (state = [], action) { default: return state } -} \ No newline at end of file +} diff --git a/app/javascript/packs/journey_patterns/index.js b/app/javascript/packs/journey_patterns/index.js index fde28b45d..367a8830f 100644 --- a/app/javascript/packs/journey_patterns/index.js +++ b/app/javascript/packs/journey_patterns/index.js @@ -16,6 +16,7 @@ var initialState = { editMode: false, status: { policy: window.perms, + features: window.features, fetchSuccess: true, isFetching: false }, -- cgit v1.2.3 From bd0ccefe3b876bc9513966b20d3afa01631a72e1 Mon Sep 17 00:00:00 2001 From: Zog Date: Wed, 3 Jan 2018 18:33:31 +0100 Subject: Refs #5455; Fix JourneyPattern editor --- app/javascript/journey_patterns/actions/index.js | 1 + 1 file changed, 1 insertion(+) (limited to 'app/javascript') diff --git a/app/javascript/journey_patterns/actions/index.js b/app/javascript/journey_patterns/actions/index.js index 09e2001c1..9f1c1c8d3 100644 --- a/app/javascript/journey_patterns/actions/index.js +++ b/app/javascript/journey_patterns/actions/index.js @@ -214,6 +214,7 @@ const actions = { journeyPatterns.push( _.assign({}, val, { stop_points: val.route_short_description.stop_points, + costs: val.costs || {}, deletable: false }) ) -- cgit v1.2.3 From 2fdcfb30655599c19629d8f0afc96f64b430358f Mon Sep 17 00:00:00 2001 From: Zog Date: Fri, 5 Jan 2018 16:34:40 +0100 Subject: Refs #45455 @1h; CR updates #1 --- app/javascript/journey_patterns/components/JourneyPattern.js | 4 ++-- app/javascript/journey_patterns/components/JourneyPatterns.js | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/journey_patterns/components/JourneyPattern.js b/app/javascript/journey_patterns/components/JourneyPattern.js index 40a6899e2..69eff978e 100644 --- a/app/javascript/journey_patterns/components/JourneyPattern.js +++ b/app/javascript/journey_patterns/components/JourneyPattern.js @@ -12,7 +12,7 @@ export default class JourneyPattern extends Component{ updateCosts(e) { let costs = { [e.target.dataset.costsKey]: { - [e.target.name]: parseInt(e.target.value) + [e.target.name]: parseFloat(e.target.value) } } this.props.onUpdateJourneyPatternCosts(costs) @@ -163,7 +163,7 @@ export default class JourneyPattern extends Component{ {this.hasFeature('costs_in_journey_patterns') && costs &&
    {this.props.editMode &&

    - + km

    diff --git a/app/javascript/journey_patterns/components/JourneyPatterns.js b/app/javascript/journey_patterns/components/JourneyPatterns.js index 69024050f..1e391b0c2 100644 --- a/app/javascript/journey_patterns/components/JourneyPatterns.js +++ b/app/javascript/journey_patterns/components/JourneyPatterns.js @@ -54,6 +54,10 @@ export default class JourneyPatterns extends Component { } } + hasFeature(key) { + return this.props.status.features[key] + } + cityNameChecker(sp) { let bool = false if(sp.city_name != this.previousCity){ @@ -115,7 +119,7 @@ export default class JourneyPatterns extends Component {

    {this.props.stopPointsList.map((sp, i) =>{ return ( -
    +
    {this.cityNameChecker(sp)}
    ) -- cgit v1.2.3 From 5134b83b0bd07d62b6ab1e334977962addfebf47 Mon Sep 17 00:00:00 2001 From: Zog Date: Mon, 8 Jan 2018 08:21:25 +0100 Subject: Rebase master --- app/javascript/journey_patterns/actions/index.js | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/journey_patterns/actions/index.js b/app/javascript/journey_patterns/actions/index.js index 9f1c1c8d3..a70a2e6f2 100644 --- a/app/javascript/journey_patterns/actions/index.js +++ b/app/javascript/journey_patterns/actions/index.js @@ -199,18 +199,6 @@ const actions = { } }) } -<<<<<<< HEAD - journeyPatterns.push({ - name: val.name, - object_id: val.object_id, - short_id: val.short_id, - checksum: val.checksum, - published_name: val.published_name, - registration_number: val.registration_number, - stop_points: val.route_short_description.stop_points, - deletable: false - }) -======= journeyPatterns.push( _.assign({}, val, { stop_points: val.route_short_description.stop_points, @@ -218,7 +206,6 @@ const actions = { deletable: false }) ) ->>>>>>> Refs #5455 @6h; Add time and distance between stops in Journey Patterns } } window.currentItemsLength = journeyPatterns.length -- cgit v1.2.3 From 415e8e14b52e125fd1b38d28e16afea7c4a62f83 Mon Sep 17 00:00:00 2001 From: Zog Date: Tue, 9 Jan 2018 15:17:00 +0100 Subject: Fix disabled fields in VJs editor --- app/javascript/vehicle_journeys/components/VehicleJourney.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/vehicle_journeys/components/VehicleJourney.js b/app/javascript/vehicle_journeys/components/VehicleJourney.js index 7ac2a7ce7..e1935ff10 100644 --- a/app/javascript/vehicle_journeys/components/VehicleJourney.js +++ b/app/javascript/vehicle_journeys/components/VehicleJourney.js @@ -109,9 +109,8 @@ export default class VehicleJourney extends Component { min='00' max='23' className='form-control' - disabled={this.isDisabled(this.props.value.deletable, vj.dummy) || this.props.filters.policy['vehicle_journeys.update'] == false} + disabled={!this.props.editMode || 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']} /> @@ -121,9 +120,8 @@ export default class VehicleJourney extends Component { min='00' max='59' className='form-control' - disabled={this.isDisabled(this.props.value.deletable, vj.dummy) || this.props.filters.policy['vehicle_journeys.update'] == false} + disabled={!this.props.editMode || 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']} /> @@ -142,9 +140,8 @@ export default class VehicleJourney extends Component { min='00' max='23' className='form-control' - disabled={this.isDisabled(this.props.value.deletable, vj.dummy) || this.props.filters.policy['vehicle_journeys.update'] == false} + disabled={!this.props.editMode || 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']} /> @@ -154,9 +151,8 @@ export default class VehicleJourney extends Component { min='00' max='59' className='form-control' - disabled={this.isDisabled(this.props.value.deletable, vj.dummy) || this.props.filters.policy['vehicle_journeys.update'] == false} + disabled={!this.props.editMode || 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']} /> -- cgit v1.2.3 From 23b415c7dfddc46f828047402879389100181049 Mon Sep 17 00:00:00 2001 From: cedricnjanga Date: Tue, 9 Jan 2018 15:22:08 +0100 Subject: Fix display order or VJ metadatas --- app/javascript/vehicle_journeys/components/VehicleJourney.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/javascript') diff --git a/app/javascript/vehicle_journeys/components/VehicleJourney.js b/app/javascript/vehicle_journeys/components/VehicleJourney.js index e1935ff10..8344a951a 100644 --- a/app/javascript/vehicle_journeys/components/VehicleJourney.js +++ b/app/javascript/vehicle_journeys/components/VehicleJourney.js @@ -69,8 +69,8 @@ export default class VehicleJourney extends Component { >
    {this.props.value.short_id || '-'}
    {this.props.value.published_journey_name && this.props.value.published_journey_name != "non renseigné" ? this.props.value.published_journey_name : '-'}
    -
    {this.props.value.company ? this.props.value.company.name : '-'}
    {this.props.value.journey_pattern.short_id || '-'}
    +
    {this.props.value.company ? this.props.value.company.name : '-'}
    {time_tables.slice(0,3).map((tt, i)=> {this.timeTableURL(tt)} -- cgit v1.2.3 From 2b72125bd3f3393c92b4e3d8680eb0ea9aa40e6e Mon Sep 17 00:00:00 2001 From: Zog Date: Tue, 9 Jan 2018 16:39:44 +0100 Subject: Refs #5502 @4h; Don't use Ajax in JP selector in VJs editor When the number of possible values is low (<10), display the values right away, don't use an Ajax query --- app/javascript/packs/vehicle_journeys/index.js | 3 +- app/javascript/vehicle_journeys/actions/index.js | 1 + .../vehicle_journeys/components/Filters.js | 3 +- .../components/tools/CreateModal.js | 6 +- .../components/tools/select2s/MissionSelect2.js | 136 +++++++++++++++------ .../vehicle_journeys/containers/Filters.js | 3 +- .../containers/tools/AddVehicleJourney.js | 1 + app/javascript/vehicle_journeys/reducers/index.js | 4 +- .../vehicle_journeys/reducers/missions.js | 6 + app/javascript/vehicle_journeys/reducers/modal.js | 3 +- 10 files changed, 123 insertions(+), 43 deletions(-) create mode 100644 app/javascript/vehicle_journeys/reducers/missions.js (limited to 'app/javascript') diff --git a/app/javascript/packs/vehicle_journeys/index.js b/app/javascript/packs/vehicle_journeys/index.js index 53c5d5417..ab28371fe 100644 --- a/app/javascript/packs/vehicle_journeys/index.js +++ b/app/javascript/packs/vehicle_journeys/index.js @@ -70,7 +70,8 @@ var initialState = { type: '', modalProps: {}, confirmModal: {} - } + }, + missions: window.all_missions } if (window.jpOrigin){ diff --git a/app/javascript/vehicle_journeys/actions/index.js b/app/javascript/vehicle_journeys/actions/index.js index 40c8006f1..9aa426237 100644 --- a/app/javascript/vehicle_journeys/actions/index.js +++ b/app/javascript/vehicle_journeys/actions/index.js @@ -57,6 +57,7 @@ const actions = { selectedItem: { id: selectedJP.id, objectid: selectedJP.object_id, + short_id: selectedJP.short_id, name: selectedJP.name, published_name: selectedJP.published_name, stop_areas: selectedJP.stop_area_short_descriptions diff --git a/app/javascript/vehicle_journeys/components/Filters.js b/app/javascript/vehicle_journeys/components/Filters.js index 3bc4f7ff7..125c27311 100644 --- a/app/javascript/vehicle_journeys/components/Filters.js +++ b/app/javascript/vehicle_journeys/components/Filters.js @@ -3,7 +3,7 @@ import MissionSelect2 from'./tools/select2s/MissionSelect2' import VJSelect2 from'./tools/select2s/VJSelect2' import TimetableSelect2 from'./tools/select2s/TimetableSelect2' -export default function Filters({filters, pagination, onFilter, onResetFilters, onUpdateStartTimeFilter, onUpdateEndTimeFilter, onToggleWithoutSchedule, onToggleWithoutTimeTable, onSelect2Timetable, onSelect2JourneyPattern, onSelect2VehicleJourney}) { +export default function Filters({filters, pagination, missions, onFilter, onResetFilters, onUpdateStartTimeFilter, onUpdateEndTimeFilter, onToggleWithoutSchedule, onToggleWithoutTimeTable, onSelect2Timetable, onSelect2JourneyPattern, onSelect2VehicleJourney}) { return (
    @@ -24,6 +24,7 @@ export default function Filters({filters, pagination, onFilter, onResetFilters, onSelect2JourneyPattern={onSelect2JourneyPattern} filters={filters} isFilter={true} + values={missions} />
    diff --git a/app/javascript/vehicle_journeys/components/tools/CreateModal.js b/app/javascript/vehicle_journeys/components/tools/CreateModal.js index cd593cdff..c402dcd84 100644 --- a/app/javascript/vehicle_journeys/components/tools/CreateModal.js +++ b/app/javascript/vehicle_journeys/components/tools/CreateModal.js @@ -10,7 +10,7 @@ export default class CreateModal extends Component { handleSubmit() { if (actions.validateFields(...this.refs, $('.vjCreateSelectJP')[0]) && this.props.modal.modalProps.selectedJPModal) { - this.props.onAddVehicleJourney(this.refs, this.props.modal.modalProps.selectedJPModal, this.props.stopPointsList, this.props.modal.modalProps.selectedCompany) + this.props.onAddVehicleJourney(this.refs, this.props.modal.modalProps.selectedJPModal, this.props.stopPointsList, this.props.modal.modalProps.vehicleJourney.company) this.props.onModalClose() $('#NewVehicleJourneyModal').modal('hide') } @@ -72,6 +72,7 @@ export default class CreateModal extends Component {
    @@ -129,5 +130,6 @@ CreateModal.propTypes = { onModalClose: PropTypes.func.isRequired, onAddVehicleJourney: PropTypes.func.isRequired, onSelect2JourneyPattern: PropTypes.func.isRequired, - disabled: PropTypes.bool.isRequired + disabled: PropTypes.bool.isRequired, + missions: PropTypes.array.isRequired } diff --git a/app/javascript/vehicle_journeys/components/tools/select2s/MissionSelect2.js b/app/javascript/vehicle_journeys/components/tools/select2s/MissionSelect2.js index fa847886c..8ad60daa3 100644 --- a/app/javascript/vehicle_journeys/components/tools/select2s/MissionSelect2.js +++ b/app/javascript/vehicle_journeys/components/tools/select2s/MissionSelect2.js @@ -11,50 +11,114 @@ let path = window.location.pathname.split('/', 7).join('/') export default class BSelect4 extends Component { constructor(props) { super(props) + this.onSelect = this.onSelect.bind(this) + } + + useAjax(){ + return this.props.values == undefined || this.props.values.length == 0 + } + + value(){ + let val = undefined + if(this.props.isFilter) { + val = this.props.filters.query.journeyPattern + } + else{ + if(this.props.selection.selectedJPModal){ + val = this.props.selection.selectedJPModal + } + } + if(this.useAjax()){ + val = val.published_name + } + else{ + if(val){ + val = val.id + } + } + return val + } + + data(){ + if(!this.useAjax()){ + let values = [{}] + values.push(...this.props.values) + return values + } + if(this.props.isFilter){ + return [this.props.filters.query.journeyPattern.published_name] + } + + return (this.props.selection.selectedJPModal) ? [this.props.selection.selectedJPModal.published_name] : undefined + } + + onSelect(e){ + if(this.useAjax()){ + this.props.onSelect2JourneyPattern(e) + } + else{ + let data = JSON.parse(e.currentTarget.selectedOptions[0].dataset.item) + + this.props.onSelect2JourneyPattern({params: + { + data: _.assign({}, e.params.data, data) + } + }) + } + } + + options(){ + let options = { + theme: 'bootstrap', + width: '100%', + escapeMarkup: function (markup) { return markup; }, + templateResult: formatRepo, + placeholder: 'Filtrer par code, nom ou OID de mission...', + language: require('./fr'), + allowClear: false, + escapeMarkup: function (markup) { return markup; }, + } + if(this.useAjax()){ + options = _.assign({}, options, { + ajax: { + url: origin + path + '/journey_patterns_collection.json', + dataType: 'json', + delay: '500', + data: function(params) { + return { + q: { published_name_or_objectid_or_registration_number_cont: params.term}, + }; + }, + processResults: function(data, params) { + return { + results: data.map( + item => _.assign( + {}, + item, + { text: "" + item.published_name + " - " + item.short_id + "
    " + item.registration_number + "" } + ) + ) + }; + }, + cache: true + }, + minimumInputLength: 1 + }) + } + return options } render() { return ( this.props.onSelect2JourneyPattern(e)} + data={this.data()} + value={this.value()} + onSelect={this.onSelect} multiple={false} ref='journey_pattern_id' className={!this.props.isFilter ? "vjCreateSelectJP" : null} required={!this.props.isFilter} - options={{ - allowClear: false, - theme: 'bootstrap', - placeholder: 'Filtrer par code, nom ou OID de mission...', - language: require('./fr'), - width: '100%', - ajax: { - url: origin + path + '/journey_patterns_collection.json', - dataType: 'json', - delay: '500', - data: function(params) { - return { - q: { published_name_or_objectid_or_registration_number_cont: params.term}, - }; - }, - processResults: function(data, params) { - return { - results: data.map( - item => _.assign( - {}, - item, - { text: "" + item.published_name + " - " + item.short_id + "
    " + item.registration_number + "" } - ) - ) - }; - }, - cache: true - }, - minimumInputLength: 1, - escapeMarkup: function (markup) { return markup; }, - templateResult: formatRepo - }} + options={this.options()} /> ) } @@ -62,4 +126,4 @@ export default class BSelect4 extends Component { const formatRepo = (props) => { if(props.text) return props.text -} \ No newline at end of file +} diff --git a/app/javascript/vehicle_journeys/containers/Filters.js b/app/javascript/vehicle_journeys/containers/Filters.js index bec3527f4..a41c599f7 100644 --- a/app/javascript/vehicle_journeys/containers/Filters.js +++ b/app/javascript/vehicle_journeys/containers/Filters.js @@ -5,7 +5,8 @@ import Filters from '../components/Filters' const mapStateToProps = (state) => { return { filters: state.filters, - pagination: state.pagination + pagination: state.pagination, + missions: state.missions, } } diff --git a/app/javascript/vehicle_journeys/containers/tools/AddVehicleJourney.js b/app/javascript/vehicle_journeys/containers/tools/AddVehicleJourney.js index 5da0bd3e9..0f4a0ea7d 100644 --- a/app/javascript/vehicle_journeys/containers/tools/AddVehicleJourney.js +++ b/app/javascript/vehicle_journeys/containers/tools/AddVehicleJourney.js @@ -9,6 +9,7 @@ const mapStateToProps = (state, ownProps) => { vehicleJourneys: state.vehicleJourneys, status: state.status, stopPointsList: state.stopPointsList, + missions: state.missions, } } diff --git a/app/javascript/vehicle_journeys/reducers/index.js b/app/javascript/vehicle_journeys/reducers/index.js index bb24aa185..862c864ae 100644 --- a/app/javascript/vehicle_journeys/reducers/index.js +++ b/app/javascript/vehicle_journeys/reducers/index.js @@ -6,6 +6,7 @@ import status from './status' import filters from './filters' import editMode from './editMode' import stopPointsList from './stopPointsList' +import missions from './missions' const vehicleJourneysApp = combineReducers({ vehicleJourneys, @@ -14,7 +15,8 @@ const vehicleJourneysApp = combineReducers({ status, filters, editMode, - stopPointsList + stopPointsList, + missions }) export default vehicleJourneysApp diff --git a/app/javascript/vehicle_journeys/reducers/missions.js b/app/javascript/vehicle_journeys/reducers/missions.js new file mode 100644 index 000000000..7c1a355c7 --- /dev/null +++ b/app/javascript/vehicle_journeys/reducers/missions.js @@ -0,0 +1,6 @@ +export default function missions(state = [], action) { + switch (action.type) { + default: + return state + } +} diff --git a/app/javascript/vehicle_journeys/reducers/modal.js b/app/javascript/vehicle_journeys/reducers/modal.js index eae3314e8..c2556303d 100644 --- a/app/javascript/vehicle_journeys/reducers/modal.js +++ b/app/javascript/vehicle_journeys/reducers/modal.js @@ -152,7 +152,8 @@ export default function modal(state = {}, action) { name: window.jpOrigin.name, published_name: window.jpOrigin.published_name, objectid: window.jpOrigin.objectid, - stop_areas: stopAreas + stop_areas: stopAreas, + missions: state.missions } } return { -- cgit v1.2.3 From 071bfaf78735b18d5dcc7f6fa31005be42a719ac Mon Sep 17 00:00:00 2001 From: Zog Date: Tue, 9 Jan 2018 16:54:24 +0100 Subject: Refs #5520 @0.25h; Fix company assignment in VJs editor --- .../vehicle_journeys/components/tools/EditVehicleJourney.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js b/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js index cad04ed0e..dc10b641a 100644 --- a/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js +++ b/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js @@ -9,14 +9,12 @@ export default class EditVehicleJourney extends Component { handleSubmit() { if(actions.validateFields(this.refs) == true) { - var company; + var company = undefined if(this.props.modal.modalProps.selectedCompany) { company = this.props.modal.modalProps.selectedCompany - } else if (typeof this.props.modal.modalProps.vehicleJourney.company === Object) { + } else if (typeof this.props.modal.modalProps.vehicleJourney.company === "object") { company = this.props.modal.modalProps.vehicleJourney.company - } else { - company = undefined - } + } this.props.onEditVehicleJourney(this.refs, company) this.props.onModalClose() $('#EditVehicleJourneyModal').modal('hide') -- cgit v1.2.3 From 56df55a4d3ffc65b483fe05b800299f04b61077f Mon Sep 17 00:00:00 2001 From: Zog Date: Wed, 10 Jan 2018 08:42:25 +0100 Subject: Refs #5465 @0.25h; Dezoom map if stop areas are too cleose to borders --- app/javascript/packs/routes/show.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'app/javascript') diff --git a/app/javascript/packs/routes/show.js b/app/javascript/packs/routes/show.js index 4d91ace13..71777c379 100644 --- a/app/javascript/packs/routes/show.js +++ b/app/javascript/packs/routes/show.js @@ -105,3 +105,17 @@ const boundaries = ol.extent.applyTransform( ol.extent.boundingExtent(area), ol.proj.getTransform('EPSG:4326', 'EPSG:3857') ) map.getView().fit(boundaries, map.getSize()); +let tooCloseToBounds = false +const mapBoundaries = map.getView().calculateExtent(map.getSize()) +const mapWidth = mapBoundaries[2] - mapBoundaries[0] +const mapHeight = mapBoundaries[3] - mapBoundaries[1] +const marginSize = 0.1 +const heightMargin = marginSize * mapHeight +const widthMargin = marginSize * mapWidth +tooCloseToBounds = tooCloseToBounds || (boundaries[0] - mapBoundaries[0]) < widthMargin +tooCloseToBounds = tooCloseToBounds || (mapBoundaries[2] - boundaries[2]) < widthMargin +tooCloseToBounds = tooCloseToBounds || (boundaries[1] - mapBoundaries[1]) < heightMargin +tooCloseToBounds = tooCloseToBounds || (mapBoundaries[3] - boundaries[3]) < heightMargin +if(tooCloseToBounds){ + map.getView().setZoom(map.getView().getZoom() - 1) +} -- cgit v1.2.3 From b4d016c8aa2e671e2b5a492d7e742d5166069495 Mon Sep 17 00:00:00 2001 From: Zog Date: Thu, 28 Dec 2017 17:05:48 +0100 Subject: Refs #5437 @2h; Update Rect to v16 Because it is needed to test the components. Major issue: Proptype now lives in a separate package, hence the huge diff --- app/javascript/journey_patterns/components/ConfirmModal.js | 4 +++- app/javascript/journey_patterns/components/CreateModal.js | 3 ++- app/javascript/journey_patterns/components/EditModal.js | 3 ++- app/javascript/journey_patterns/components/JourneyPattern.js | 3 ++- app/javascript/journey_patterns/components/JourneyPatterns.js | 3 ++- app/javascript/journey_patterns/components/Navigate.js | 3 ++- app/javascript/journey_patterns/components/SaveJourneyPattern.js | 3 ++- app/javascript/packs/routes/edit.js | 4 +++- app/javascript/routes/components/BSelect2.js | 2 +- app/javascript/routes/components/StopPoint.js | 4 +++- app/javascript/routes/components/StopPointList.js | 4 +++- app/javascript/time_tables/components/ConfirmModal.js | 4 +++- app/javascript/time_tables/components/ErrorModal.js | 4 +++- app/javascript/time_tables/components/ExceptionsInDay.js | 3 ++- app/javascript/time_tables/components/Metas.js | 4 +++- app/javascript/time_tables/components/Navigate.js | 3 ++- app/javascript/time_tables/components/PeriodForm.js | 4 +++- app/javascript/time_tables/components/PeriodManager.js | 3 ++- app/javascript/time_tables/components/PeriodsInDay.js | 3 ++- app/javascript/time_tables/components/SaveTimetable.js | 3 ++- app/javascript/time_tables/components/TagsSelect2.js | 5 +++-- app/javascript/time_tables/components/TimeTableDay.js | 3 ++- app/javascript/time_tables/components/Timetable.js | 3 ++- app/javascript/time_tables/containers/App.js | 3 ++- app/javascript/vehicle_journeys/components/App.js | 2 +- app/javascript/vehicle_journeys/components/ConfirmModal.js | 3 ++- app/javascript/vehicle_journeys/components/Filters.js | 4 +++- app/javascript/vehicle_journeys/components/Navigate.js | 3 ++- app/javascript/vehicle_journeys/components/SaveVehicleJourneys.js | 3 ++- app/javascript/vehicle_journeys/components/ToggleArrivals.js | 6 ++++-- app/javascript/vehicle_journeys/components/Tools.js | 3 ++- app/javascript/vehicle_journeys/components/VehicleJourney.js | 3 ++- app/javascript/vehicle_journeys/components/tools/CreateModal.js | 3 ++- .../vehicle_journeys/components/tools/DeleteVehicleJourneys.js | 4 +++- .../vehicle_journeys/components/tools/DuplicateVehicleJourney.js | 3 ++- .../vehicle_journeys/components/tools/EditVehicleJourney.js | 3 ++- .../vehicle_journeys/components/tools/NotesEditVehicleJourney.js | 3 ++- .../components/tools/PurchaseWindowsEditVehicleJourney.js | 3 ++- .../vehicle_journeys/components/tools/ShiftVehicleJourney.js | 3 ++- .../components/tools/TimetablesEditVehicleJourney.js | 3 ++- .../vehicle_journeys/components/tools/select2s/CompanySelect2.js | 5 +++-- .../vehicle_journeys/components/tools/select2s/MissionSelect2.js | 5 +++-- .../vehicle_journeys/components/tools/select2s/TimetableSelect2.js | 5 +++-- .../vehicle_journeys/components/tools/select2s/VJSelect2.js | 5 +++-- 44 files changed, 103 insertions(+), 50 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/journey_patterns/components/ConfirmModal.js b/app/javascript/journey_patterns/components/ConfirmModal.js index 2cc1bef44..ccd0a9384 100644 --- a/app/javascript/journey_patterns/components/ConfirmModal.js +++ b/app/javascript/journey_patterns/components/ConfirmModal.js @@ -1,4 +1,6 @@ -import React, { PropTypes } from 'react' +import React from 'react' +import PropTypes from 'prop-types' + export default function ConfirmModal({dispatch, modal, onModalAccept, onModalCancel, journeyPatterns}) { return ( diff --git a/app/javascript/journey_patterns/components/CreateModal.js b/app/javascript/journey_patterns/components/CreateModal.js index d0eff6e57..a6c1b608a 100644 --- a/app/javascript/journey_patterns/components/CreateModal.js +++ b/app/javascript/journey_patterns/components/CreateModal.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' import actions from '../actions' export default class CreateModal extends Component { diff --git a/app/javascript/journey_patterns/components/EditModal.js b/app/javascript/journey_patterns/components/EditModal.js index 7a5d24fba..c960cb41c 100644 --- a/app/javascript/journey_patterns/components/EditModal.js +++ b/app/javascript/journey_patterns/components/EditModal.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' import actions from '../actions' export default class EditModal extends Component { diff --git a/app/javascript/journey_patterns/components/JourneyPattern.js b/app/javascript/journey_patterns/components/JourneyPattern.js index 69eff978e..52641c94e 100644 --- a/app/javascript/journey_patterns/components/JourneyPattern.js +++ b/app/javascript/journey_patterns/components/JourneyPattern.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' import actions from '../actions' export default class JourneyPattern extends Component{ diff --git a/app/javascript/journey_patterns/components/JourneyPatterns.js b/app/javascript/journey_patterns/components/JourneyPatterns.js index 1e391b0c2..67315346d 100644 --- a/app/javascript/journey_patterns/components/JourneyPatterns.js +++ b/app/javascript/journey_patterns/components/JourneyPatterns.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' import _ from 'lodash' import JourneyPattern from './JourneyPattern' diff --git a/app/javascript/journey_patterns/components/Navigate.js b/app/javascript/journey_patterns/components/Navigate.js index f2fdd668f..78f324a7d 100644 --- a/app/javascript/journey_patterns/components/Navigate.js +++ b/app/javascript/journey_patterns/components/Navigate.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' import actions from '../actions' export default function Navigate({ dispatch, journeyPatterns, pagination, status }) { diff --git a/app/javascript/journey_patterns/components/SaveJourneyPattern.js b/app/javascript/journey_patterns/components/SaveJourneyPattern.js index d071fa542..7e4492e0e 100644 --- a/app/javascript/journey_patterns/components/SaveJourneyPattern.js +++ b/app/javascript/journey_patterns/components/SaveJourneyPattern.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' import actions from '../actions' export default class SaveJourneyPattern extends Component { diff --git a/app/javascript/packs/routes/edit.js b/app/javascript/packs/routes/edit.js index d6ceed60f..d31e94878 100644 --- a/app/javascript/packs/routes/edit.js +++ b/app/javascript/packs/routes/edit.js @@ -1,4 +1,6 @@ -import React, { PropTypes } from 'react' +import React from 'react' +import PropTypes from 'prop-types' + import { render } from 'react-dom' import { Provider } from 'react-redux' import { createStore } from 'redux' diff --git a/app/javascript/routes/components/BSelect2.js b/app/javascript/routes/components/BSelect2.js index 0d8d7787f..2ec7cd710 100644 --- a/app/javascript/routes/components/BSelect2.js +++ b/app/javascript/routes/components/BSelect2.js @@ -1,6 +1,6 @@ import _ from'lodash' import React, { Component, PropTypes } from 'react' -import Select2 from 'react-select2' +import Select2 from 'react-select2-wrapper' // get JSON full path diff --git a/app/javascript/routes/components/StopPoint.js b/app/javascript/routes/components/StopPoint.js index 606121f99..2d47e802b 100644 --- a/app/javascript/routes/components/StopPoint.js +++ b/app/javascript/routes/components/StopPoint.js @@ -1,4 +1,6 @@ -import React, { PropTypes } from 'react' +import React from 'react' +import PropTypes from 'prop-types' + import BSelect2 from './BSelect2' import OlMap from './OlMap' diff --git a/app/javascript/routes/components/StopPointList.js b/app/javascript/routes/components/StopPointList.js index 68af16f57..43a027084 100644 --- a/app/javascript/routes/components/StopPointList.js +++ b/app/javascript/routes/components/StopPointList.js @@ -1,4 +1,6 @@ -import React, { PropTypes } from 'react' +import React from 'react' +import PropTypes from 'prop-types' + import StopPoint from './StopPoint' export default function StopPointList({ stopPoints, onDeleteClick, onMoveUpClick, onMoveDownClick, onChange, onSelectChange, onToggleMap, onToggleEdit, onSelectMarker, onUnselectMarker, onUpdateViaOlMap }, {I18n}) { diff --git a/app/javascript/time_tables/components/ConfirmModal.js b/app/javascript/time_tables/components/ConfirmModal.js index d89170ee7..845e7ed1b 100644 --- a/app/javascript/time_tables/components/ConfirmModal.js +++ b/app/javascript/time_tables/components/ConfirmModal.js @@ -1,4 +1,6 @@ -import React, { PropTypes } from 'react' +import React from 'react' +import PropTypes from 'prop-types' + export default function ConfirmModal({dispatch, modal, onModalAccept, onModalCancel, timetable, metas}, {I18n}) { return ( diff --git a/app/javascript/time_tables/components/ErrorModal.js b/app/javascript/time_tables/components/ErrorModal.js index e810f49ab..543177e54 100644 --- a/app/javascript/time_tables/components/ErrorModal.js +++ b/app/javascript/time_tables/components/ErrorModal.js @@ -1,4 +1,6 @@ -import React, { PropTypes } from 'react' +import React from 'react' +import PropTypes from 'prop-types' + import actions from '../actions' export default function ErrorModal({dispatch, modal, onModalClose}, {I18n}) { diff --git a/app/javascript/time_tables/components/ExceptionsInDay.js b/app/javascript/time_tables/components/ExceptionsInDay.js index 3335ee89d..f5ed625be 100644 --- a/app/javascript/time_tables/components/ExceptionsInDay.js +++ b/app/javascript/time_tables/components/ExceptionsInDay.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' import actions from '../actions' export default class ExceptionsInDay extends Component { diff --git a/app/javascript/time_tables/components/Metas.js b/app/javascript/time_tables/components/Metas.js index 7098d2b82..4170ba493 100644 --- a/app/javascript/time_tables/components/Metas.js +++ b/app/javascript/time_tables/components/Metas.js @@ -1,4 +1,6 @@ -import React, { PropTypes } from 'react' +import React from 'react' +import PropTypes from 'prop-types' + import actions from '../actions' import TagsSelect2 from './TagsSelect2' diff --git a/app/javascript/time_tables/components/Navigate.js b/app/javascript/time_tables/components/Navigate.js index 7307d819b..64f05cb41 100644 --- a/app/javascript/time_tables/components/Navigate.js +++ b/app/javascript/time_tables/components/Navigate.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' import map from 'lodash/map' import actions from '../actions' diff --git a/app/javascript/time_tables/components/PeriodForm.js b/app/javascript/time_tables/components/PeriodForm.js index d9f1d3437..085654a88 100644 --- a/app/javascript/time_tables/components/PeriodForm.js +++ b/app/javascript/time_tables/components/PeriodForm.js @@ -1,4 +1,6 @@ -import React, { PropTypes } from 'react' +import React from 'react' +import PropTypes from 'prop-types' + import filter from 'lodash/filter' let monthsArray = ['Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre'] diff --git a/app/javascript/time_tables/components/PeriodManager.js b/app/javascript/time_tables/components/PeriodManager.js index 9922ce2c4..6b817fe73 100644 --- a/app/javascript/time_tables/components/PeriodManager.js +++ b/app/javascript/time_tables/components/PeriodManager.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' import actions from '../actions' export default class PeriodManager extends Component { diff --git a/app/javascript/time_tables/components/PeriodsInDay.js b/app/javascript/time_tables/components/PeriodsInDay.js index 888537579..1aed5c969 100644 --- a/app/javascript/time_tables/components/PeriodsInDay.js +++ b/app/javascript/time_tables/components/PeriodsInDay.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' import PeriodManager from './PeriodManager' export default class PeriodsInDay extends Component { diff --git a/app/javascript/time_tables/components/SaveTimetable.js b/app/javascript/time_tables/components/SaveTimetable.js index d5a57bd1c..704590abd 100644 --- a/app/javascript/time_tables/components/SaveTimetable.js +++ b/app/javascript/time_tables/components/SaveTimetable.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' import actions from '../actions' export default class SaveTimetable extends Component{ diff --git a/app/javascript/time_tables/components/TagsSelect2.js b/app/javascript/time_tables/components/TagsSelect2.js index 70a748a04..dc3739d58 100644 --- a/app/javascript/time_tables/components/TagsSelect2.js +++ b/app/javascript/time_tables/components/TagsSelect2.js @@ -1,9 +1,10 @@ -import React, { PropTypes, Component } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' import mapKeys from 'lodash/mapKeys' import map from 'lodash/map' import filter from 'lodash/filter' import assign from 'lodash/assign' -import Select2 from 'react-select2' +import Select2 from 'react-select2-wrapper' // get JSON full path let origin = window.location.origin diff --git a/app/javascript/time_tables/components/TimeTableDay.js b/app/javascript/time_tables/components/TimeTableDay.js index 165c7b848..498e7d0cd 100644 --- a/app/javascript/time_tables/components/TimeTableDay.js +++ b/app/javascript/time_tables/components/TimeTableDay.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' export default class TimeTableDay extends Component { constructor(props) { diff --git a/app/javascript/time_tables/components/Timetable.js b/app/javascript/time_tables/components/Timetable.js index df6e6016b..c44f2a134 100644 --- a/app/javascript/time_tables/components/Timetable.js +++ b/app/javascript/time_tables/components/Timetable.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' import actions from '../actions' import TimeTableDay from './TimeTableDay' import PeriodsInDay from './PeriodsInDay' diff --git a/app/javascript/time_tables/containers/App.js b/app/javascript/time_tables/containers/App.js index 235dccb50..5963f8f1d 100644 --- a/app/javascript/time_tables/containers/App.js +++ b/app/javascript/time_tables/containers/App.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' import { connect } from'react-redux' import actions from '../actions' import Metas from './Metas' diff --git a/app/javascript/vehicle_journeys/components/App.js b/app/javascript/vehicle_journeys/components/App.js index 8e5f7aa9d..44559c7c6 100644 --- a/app/javascript/vehicle_journeys/components/App.js +++ b/app/javascript/vehicle_journeys/components/App.js @@ -35,4 +35,4 @@ export default function App() {
    ) -} \ No newline at end of file +} diff --git a/app/javascript/vehicle_journeys/components/ConfirmModal.js b/app/javascript/vehicle_journeys/components/ConfirmModal.js index df3c96c48..3bfc852fb 100644 --- a/app/javascript/vehicle_journeys/components/ConfirmModal.js +++ b/app/javascript/vehicle_journeys/components/ConfirmModal.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' export default function ConfirmModal({dispatch, modal, onModalAccept, onModalCancel, vehicleJourneys}) { return ( diff --git a/app/javascript/vehicle_journeys/components/Filters.js b/app/javascript/vehicle_journeys/components/Filters.js index 3bc4f7ff7..b6c255c53 100644 --- a/app/javascript/vehicle_journeys/components/Filters.js +++ b/app/javascript/vehicle_journeys/components/Filters.js @@ -1,4 +1,6 @@ -import React, { PropTypes } from 'react' +import React from 'react' +import PropTypes from 'prop-types' + import MissionSelect2 from'./tools/select2s/MissionSelect2' import VJSelect2 from'./tools/select2s/VJSelect2' import TimetableSelect2 from'./tools/select2s/TimetableSelect2' diff --git a/app/javascript/vehicle_journeys/components/Navigate.js b/app/javascript/vehicle_journeys/components/Navigate.js index 7493b705b..0158b8392 100644 --- a/app/javascript/vehicle_journeys/components/Navigate.js +++ b/app/javascript/vehicle_journeys/components/Navigate.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' import actions from'../actions' export default function Navigate({ dispatch, vehicleJourneys, pagination, status, filters}) { diff --git a/app/javascript/vehicle_journeys/components/SaveVehicleJourneys.js b/app/javascript/vehicle_journeys/components/SaveVehicleJourneys.js index 6dba5618c..c5161b917 100644 --- a/app/javascript/vehicle_journeys/components/SaveVehicleJourneys.js +++ b/app/javascript/vehicle_journeys/components/SaveVehicleJourneys.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' import actions from '../actions' export default class SaveVehicleJourneys extends Component{ diff --git a/app/javascript/vehicle_journeys/components/ToggleArrivals.js b/app/javascript/vehicle_journeys/components/ToggleArrivals.js index e26ceec3a..9e7089be5 100644 --- a/app/javascript/vehicle_journeys/components/ToggleArrivals.js +++ b/app/javascript/vehicle_journeys/components/ToggleArrivals.js @@ -1,4 +1,6 @@ -import React, { PropTypes } from 'react' +import React from 'react' +import PropTypes from 'prop-types' + export default function ToggleArrivals({filters, onToggleArrivals}) { return ( @@ -24,4 +26,4 @@ export default function ToggleArrivals({filters, onToggleArrivals}) { ToggleArrivals.propTypes = { filters : PropTypes.object.isRequired, onToggleArrivals: PropTypes.func.isRequired -} \ No newline at end of file +} diff --git a/app/javascript/vehicle_journeys/components/Tools.js b/app/javascript/vehicle_journeys/components/Tools.js index d6e04f00e..ee02e5a68 100644 --- a/app/javascript/vehicle_journeys/components/Tools.js +++ b/app/javascript/vehicle_journeys/components/Tools.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' import actions from '../actions' import AddVehicleJourney from '../containers/tools/AddVehicleJourney' import DeleteVehicleJourneys from '../containers/tools/DeleteVehicleJourneys' diff --git a/app/javascript/vehicle_journeys/components/VehicleJourney.js b/app/javascript/vehicle_journeys/components/VehicleJourney.js index 8344a951a..93cdc1b10 100644 --- a/app/javascript/vehicle_journeys/components/VehicleJourney.js +++ b/app/javascript/vehicle_journeys/components/VehicleJourney.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' import actions from '../actions' export default class VehicleJourney extends Component { diff --git a/app/javascript/vehicle_journeys/components/tools/CreateModal.js b/app/javascript/vehicle_journeys/components/tools/CreateModal.js index cd593cdff..61012d199 100644 --- a/app/javascript/vehicle_journeys/components/tools/CreateModal.js +++ b/app/javascript/vehicle_journeys/components/tools/CreateModal.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' import actions from '../../actions' import MissionSelect2 from './select2s/MissionSelect2' import CompanySelect2 from './select2s/CompanySelect2' diff --git a/app/javascript/vehicle_journeys/components/tools/DeleteVehicleJourneys.js b/app/javascript/vehicle_journeys/components/tools/DeleteVehicleJourneys.js index fc13ae964..4815003d3 100644 --- a/app/javascript/vehicle_journeys/components/tools/DeleteVehicleJourneys.js +++ b/app/javascript/vehicle_journeys/components/tools/DeleteVehicleJourneys.js @@ -1,4 +1,6 @@ -import React, { PropTypes } from 'react' +import React from 'react' +import PropTypes from 'prop-types' + import actions from '../../actions' export default function DeleteVehicleJourneys({onDeleteVehicleJourneys, vehicleJourneys, disabled}) { diff --git a/app/javascript/vehicle_journeys/components/tools/DuplicateVehicleJourney.js b/app/javascript/vehicle_journeys/components/tools/DuplicateVehicleJourney.js index 8083defb9..102a87d85 100644 --- a/app/javascript/vehicle_journeys/components/tools/DuplicateVehicleJourney.js +++ b/app/javascript/vehicle_journeys/components/tools/DuplicateVehicleJourney.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' import actions from '../../actions' import _ from 'lodash' diff --git a/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js b/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js index cad04ed0e..36dbb98d5 100644 --- a/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js +++ b/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' import actions from '../../actions' import CompanySelect2 from './select2s/CompanySelect2' diff --git a/app/javascript/vehicle_journeys/components/tools/NotesEditVehicleJourney.js b/app/javascript/vehicle_journeys/components/tools/NotesEditVehicleJourney.js index de97bc403..880542216 100644 --- a/app/javascript/vehicle_journeys/components/tools/NotesEditVehicleJourney.js +++ b/app/javascript/vehicle_journeys/components/tools/NotesEditVehicleJourney.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' import actions from '../../actions' import _ from 'lodash' diff --git a/app/javascript/vehicle_journeys/components/tools/PurchaseWindowsEditVehicleJourney.js b/app/javascript/vehicle_journeys/components/tools/PurchaseWindowsEditVehicleJourney.js index d61c7a34b..ce9a4cde9 100644 --- a/app/javascript/vehicle_journeys/components/tools/PurchaseWindowsEditVehicleJourney.js +++ b/app/javascript/vehicle_journeys/components/tools/PurchaseWindowsEditVehicleJourney.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' import actions from '../../actions' import TimetableSelect2 from './select2s/TimetableSelect2' diff --git a/app/javascript/vehicle_journeys/components/tools/ShiftVehicleJourney.js b/app/javascript/vehicle_journeys/components/tools/ShiftVehicleJourney.js index a54e40502..6574bfa2d 100644 --- a/app/javascript/vehicle_journeys/components/tools/ShiftVehicleJourney.js +++ b/app/javascript/vehicle_journeys/components/tools/ShiftVehicleJourney.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' import actions from '../../actions' export default class ShiftVehicleJourney extends Component { diff --git a/app/javascript/vehicle_journeys/components/tools/TimetablesEditVehicleJourney.js b/app/javascript/vehicle_journeys/components/tools/TimetablesEditVehicleJourney.js index fdaa5aeed..e2fcd27d5 100644 --- a/app/javascript/vehicle_journeys/components/tools/TimetablesEditVehicleJourney.js +++ b/app/javascript/vehicle_journeys/components/tools/TimetablesEditVehicleJourney.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' import actions from '../../actions' import TimetableSelect2 from './select2s/TimetableSelect2' diff --git a/app/javascript/vehicle_journeys/components/tools/select2s/CompanySelect2.js b/app/javascript/vehicle_journeys/components/tools/select2s/CompanySelect2.js index 79ba8f094..28a092945 100644 --- a/app/javascript/vehicle_journeys/components/tools/select2s/CompanySelect2.js +++ b/app/javascript/vehicle_journeys/components/tools/select2s/CompanySelect2.js @@ -1,6 +1,7 @@ import _ from 'lodash' -import React, { PropTypes, Component } from 'react' -import Select2 from 'react-select2' +import React, { Component } from 'react' +import PropTypes from 'prop-types' +import Select2 from 'react-select2-wrapper' import actions from '../../../actions' // get JSON full path diff --git a/app/javascript/vehicle_journeys/components/tools/select2s/MissionSelect2.js b/app/javascript/vehicle_journeys/components/tools/select2s/MissionSelect2.js index fa847886c..2a06df77e 100644 --- a/app/javascript/vehicle_journeys/components/tools/select2s/MissionSelect2.js +++ b/app/javascript/vehicle_journeys/components/tools/select2s/MissionSelect2.js @@ -1,6 +1,7 @@ import _ from 'lodash' -import React, { PropTypes, Component } from 'react' -import Select2 from 'react-select2' +import React, { Component } from 'react' +import PropTypes from 'prop-types' +import Select2 from 'react-select2-wrapper' import actions from '../../../actions' // get JSON full path diff --git a/app/javascript/vehicle_journeys/components/tools/select2s/TimetableSelect2.js b/app/javascript/vehicle_journeys/components/tools/select2s/TimetableSelect2.js index eb8651be2..0339455ca 100644 --- a/app/javascript/vehicle_journeys/components/tools/select2s/TimetableSelect2.js +++ b/app/javascript/vehicle_journeys/components/tools/select2s/TimetableSelect2.js @@ -1,6 +1,7 @@ import _ from 'lodash' -import React, { PropTypes, Component } from 'react' -import Select2 from 'react-select2' +import React, { Component } from 'react' +import PropTypes from 'prop-types' +import Select2 from 'react-select2-wrapper' import actions from '../../../actions' // get JSON full path diff --git a/app/javascript/vehicle_journeys/components/tools/select2s/VJSelect2.js b/app/javascript/vehicle_journeys/components/tools/select2s/VJSelect2.js index b063abeca..ccb4c9595 100644 --- a/app/javascript/vehicle_journeys/components/tools/select2s/VJSelect2.js +++ b/app/javascript/vehicle_journeys/components/tools/select2s/VJSelect2.js @@ -1,6 +1,7 @@ import _ from 'lodash' -import React, { PropTypes, Component } from 'react' -import Select2 from 'react-select2' +import React, { Component } from 'react' +import PropTypes from 'prop-types' +import Select2 from 'react-select2-wrapper' import actions from '../../../actions' // get JSON full path -- cgit v1.2.3 From 3bc583b1e727f0cf27e0aef8ef94121dd693cd86 Mon Sep 17 00:00:00 2001 From: Zog Date: Thu, 28 Dec 2017 17:07:37 +0100 Subject: Refs #5437 @0.5h; Show country name instead of city in the journeys editor When the organisation has the "long_distance_routes" features. Mind the `StopArea#country_name` method which is pending until we merge the branch which adds the countries support. --- .../vehicle_journeys/components/VehicleJourneys.js | 26 +++++++++++++--------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/vehicle_journeys/components/VehicleJourneys.js b/app/javascript/vehicle_journeys/components/VehicleJourneys.js index 0cac0344c..0b2029dcb 100644 --- a/app/javascript/vehicle_journeys/components/VehicleJourneys.js +++ b/app/javascript/vehicle_journeys/components/VehicleJourneys.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' import _ from 'lodash' import VehicleJourney from './VehicleJourney' @@ -6,7 +7,7 @@ import VehicleJourney from './VehicleJourney' export default class VehicleJourneys extends Component { constructor(props){ super(props) - this.previousCity = undefined + this.previousBreakpoint = undefined } componentDidMount() { this.props.onLoadFirstPage(this.props.filters) @@ -59,16 +60,19 @@ export default class VehicleJourneys extends Component { } } - cityNameChecker(sp) { - let bool = false - if(sp.city_name != this.previousCity){ - bool = true - this.previousCity = sp.city_name + stopPointHeader(sp) { + let showHeadline = false + let headline = "" + let attribute_to_check = this.hasFeature('long_distance_routes') ? "country_code" : "city_name" + if(sp[attribute_to_check] != this.previousBreakpoint){ + showHeadline = true + headline = this.hasFeature('long_distance_routes') ? sp.country_name : sp.city_name + this.previousBreakpoint = sp[attribute_to_check] } return (
    {sp.name} @@ -77,7 +81,7 @@ export default class VehicleJourneys extends Component { } render() { - this.previousCity = undefined + this.previousBreakpoint = undefined if(this.props.status.isFetching == true) { return ( @@ -124,7 +128,7 @@ export default class VehicleJourneys extends Component { {this.props.stopPointsList.map((sp, i) =>{ return (
    - {this.cityNameChecker(sp)} + {this.stopPointHeader(sp)}
    ) })} -- cgit v1.2.3 From 314c706183146099e385b224e316fdf06f6f91cd Mon Sep 17 00:00:00 2001 From: Zog Date: Wed, 10 Jan 2018 09:28:50 +0100 Subject: Refs #5437; Refactor headers computing Share a method between the components VehicleJourneys and VehicleJourney to compute the header to be shown (or not) --- .../vehicle_journeys/components/VehicleJourney.js | 11 +++-------- .../vehicle_journeys/components/VehicleJourneys.js | 18 +++++++++++++----- 2 files changed, 16 insertions(+), 13 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/vehicle_journeys/components/VehicleJourney.js b/app/javascript/vehicle_journeys/components/VehicleJourney.js index 93cdc1b10..d240757a3 100644 --- a/app/javascript/vehicle_journeys/components/VehicleJourney.js +++ b/app/javascript/vehicle_journeys/components/VehicleJourney.js @@ -9,13 +9,7 @@ export default class VehicleJourney extends Component { } cityNameChecker(sp) { - let bool = false - if(sp.stop_area_cityname != this.previousCity){ - bool = true - this.previousCity = sp.stop_area_cityname - } - - return bool + return this.props.vehicleJourneys.showHeader(sp.stop_point_objectid) } hasFeature(key) { @@ -172,5 +166,6 @@ VehicleJourney.propTypes = { filters: PropTypes.object.isRequired, index: PropTypes.number.isRequired, onUpdateTime: PropTypes.func.isRequired, - onSelectVehicleJourney: PropTypes.func.isRequired + onSelectVehicleJourney: PropTypes.func.isRequired, + vehicleJourneys: PropTypes.object.isRequired, } diff --git a/app/javascript/vehicle_journeys/components/VehicleJourneys.js b/app/javascript/vehicle_journeys/components/VehicleJourneys.js index 0b2029dcb..5a7f13028 100644 --- a/app/javascript/vehicle_journeys/components/VehicleJourneys.js +++ b/app/javascript/vehicle_journeys/components/VehicleJourneys.js @@ -7,7 +7,7 @@ import VehicleJourney from './VehicleJourney' export default class VehicleJourneys extends Component { constructor(props){ super(props) - this.previousBreakpoint = undefined + this.stopPointsIds = _.map(this.props.stopPointsList, (sp)=>{return sp.object_id}) } componentDidMount() { this.props.onLoadFirstPage(this.props.filters) @@ -60,19 +60,26 @@ export default class VehicleJourneys extends Component { } } - stopPointHeader(sp) { + showHeader(object_id) { let showHeadline = false let headline = "" let attribute_to_check = this.hasFeature('long_distance_routes') ? "country_code" : "city_name" - if(sp[attribute_to_check] != this.previousBreakpoint){ + let index = this.stopPointsIds.indexOf(object_id) + let sp = this.props.stopPointsList[index] + let previousBreakpoint = this.props.stopPointsList[index - 1] + if(previousBreakpoint && (sp[attribute_to_check] != previousBreakpoint[attribute_to_check])){ showHeadline = true headline = this.hasFeature('long_distance_routes') ? sp.country_name : sp.city_name - this.previousBreakpoint = sp[attribute_to_check] } + return showHeadline ? headline : null + } + + stopPointHeader(sp) { + let showHeadline = this.showHeader(sp.object_id) return (
    {sp.name} @@ -146,6 +153,7 @@ export default class VehicleJourneys extends Component { features={this.props.features} onUpdateTime={this.props.onUpdateTime} onSelectVehicleJourney={this.props.onSelectVehicleJourney} + vehicleJourneys={this} /> )}
    -- cgit v1.2.3 From d0e51ea2058163b76863797a4e337ba3f5d6611d Mon Sep 17 00:00:00 2001 From: Zog Date: Wed, 10 Jan 2018 10:08:34 +0100 Subject: Refs #5437 @0.5h; Propagate behaviour to the JourneyPatterns editor --- .../journey_patterns/components/JourneyPattern.js | 11 ++----- .../journey_patterns/components/JourneyPatterns.js | 37 +++++++++++++++------- .../vehicle_journeys/components/VehicleJourneys.js | 4 +-- 3 files changed, 30 insertions(+), 22 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/journey_patterns/components/JourneyPattern.js b/app/javascript/journey_patterns/components/JourneyPattern.js index 52641c94e..47fb6882d 100644 --- a/app/javascript/journey_patterns/components/JourneyPattern.js +++ b/app/javascript/journey_patterns/components/JourneyPattern.js @@ -33,13 +33,7 @@ export default class JourneyPattern extends Component{ } cityNameChecker(sp) { - let bool = false - - if(sp.city_name != this.previousCity){ - bool = true - this.previousCity = sp.city_name - } - return bool + return this.props.journeyPatterns.showHeader(sp.object_id) } spNode(sp, headlined){ @@ -190,5 +184,6 @@ JourneyPattern.propTypes = { index: PropTypes.number, onCheckboxChange: PropTypes.func.isRequired, onOpenEditModal: PropTypes.func.isRequired, - onDeleteJourneyPattern: PropTypes.func.isRequired + onDeleteJourneyPattern: PropTypes.func.isRequired, + journeyPatterns: PropTypes.object.isRequired } diff --git a/app/javascript/journey_patterns/components/JourneyPatterns.js b/app/javascript/journey_patterns/components/JourneyPatterns.js index 67315346d..c261b408a 100644 --- a/app/javascript/journey_patterns/components/JourneyPatterns.js +++ b/app/javascript/journey_patterns/components/JourneyPatterns.js @@ -7,11 +7,13 @@ import JourneyPattern from './JourneyPattern' export default class JourneyPatterns extends Component { constructor(props){ super(props) - this.previousCity = undefined + this.stopPointsIds = _.map(this.props.stopPointsList, (sp)=>{return sp.stop_area_object_id}) } + componentDidMount() { this.props.onLoadFirstPage() } + componentDidUpdate(prevProps, prevState) { if(this.props.status.isFetching == false){ $('.table-2entries').each(function() { @@ -55,20 +57,26 @@ export default class JourneyPatterns extends Component { } } - hasFeature(key) { - return this.props.status.features[key] + showHeader(object_id) { + let showHeadline = false + let headline = "" + let attribute_to_check = this.hasFeature('long_distance_routes') ? "country_code" : "city_name" + let index = this.stopPointsIds.indexOf(object_id) + let sp = this.props.stopPointsList[index] + let previousBreakpoint = this.props.stopPointsList[index - 1] + if(index == 0 || (sp[attribute_to_check] != previousBreakpoint[attribute_to_check])){ + showHeadline = true + headline = this.hasFeature('long_distance_routes') ? sp.country_name : sp.city_name + } + return showHeadline ? headline : "" } - cityNameChecker(sp) { - let bool = false - if(sp.city_name != this.previousCity){ - bool = true - this.previousCity = sp.city_name - } + stopPointHeader(sp) { + let showHeadline = this.showHeader(sp.stop_area_object_id) return (
    {sp.name} @@ -76,6 +84,10 @@ export default class JourneyPatterns extends Component { ) } + hasFeature(key) { + return this.props.status.features[key] + } + render() { this.previousCity = undefined @@ -121,7 +133,7 @@ export default class JourneyPatterns extends Component { {this.props.stopPointsList.map((sp, i) =>{ return (
    - {this.cityNameChecker(sp)} + {this.stopPointHeader(sp)}
    ) })} @@ -139,6 +151,7 @@ export default class JourneyPatterns extends Component { onUpdateJourneyPatternCosts={(costs) => this.props.onUpdateJourneyPatternCosts(index, costs)} status= {this.props.status} editMode= {this.props.editMode} + journeyPatterns= {this} /> )}
    diff --git a/app/javascript/vehicle_journeys/components/VehicleJourneys.js b/app/javascript/vehicle_journeys/components/VehicleJourneys.js index 5a7f13028..3f5a51093 100644 --- a/app/javascript/vehicle_journeys/components/VehicleJourneys.js +++ b/app/javascript/vehicle_journeys/components/VehicleJourneys.js @@ -67,11 +67,11 @@ export default class VehicleJourneys extends Component { let index = this.stopPointsIds.indexOf(object_id) let sp = this.props.stopPointsList[index] let previousBreakpoint = this.props.stopPointsList[index - 1] - if(previousBreakpoint && (sp[attribute_to_check] != previousBreakpoint[attribute_to_check])){ + if(index == 0 || (sp[attribute_to_check] != previousBreakpoint[attribute_to_check])){ showHeadline = true headline = this.hasFeature('long_distance_routes') ? sp.country_name : sp.city_name } - return showHeadline ? headline : null + return showHeadline ? headline : "" } stopPointHeader(sp) { -- cgit v1.2.3 From aaa9ee2fabe87209df028bb225339108bf389f64 Mon Sep 17 00:00:00 2001 From: Zog Date: Wed, 10 Jan 2018 10:47:23 +0100 Subject: Refs #5437 @1h; Refactor code --- app/javascript/helpers/stop_area_header_manager.js | 42 ++++++++++++++++++++++ .../journey_patterns/components/JourneyPattern.js | 6 ++-- .../journey_patterns/components/JourneyPatterns.js | 35 +++++------------- .../vehicle_journeys/components/VehicleJourneys.js | 42 +++++++--------------- 4 files changed, 65 insertions(+), 60 deletions(-) create mode 100644 app/javascript/helpers/stop_area_header_manager.js (limited to 'app/javascript') diff --git a/app/javascript/helpers/stop_area_header_manager.js b/app/javascript/helpers/stop_area_header_manager.js new file mode 100644 index 000000000..54d957be9 --- /dev/null +++ b/app/javascript/helpers/stop_area_header_manager.js @@ -0,0 +1,42 @@ +import React, { Component } from 'react' + +export default class StopAreaHeaderManager { + constructor(ids_list, stopPointsList, features) { + this.ids_list = ids_list + this.stopPointsList = stopPointsList + this.features = features + } + + hasFeature(key) { + return this.features[key] + } + + stopPointHeader(object_id) { + let index = this.ids_list.indexOf(object_id) + let sp = this.stopPointsList[index] + let showHeadline = this.showHeader(object_id) + return ( +
    + {sp.name} +
    + ) + } + + showHeader(object_id) { + let showHeadline = false + let headline = "" + let attribute_to_check = this.hasFeature('long_distance_routes') ? "country_code" : "city_name" + let index = this.ids_list.indexOf(object_id) + let sp = this.stopPointsList[index] + let previousBreakpoint = this.stopPointsList[index - 1] + if(index == 0 || (sp[attribute_to_check] != previousBreakpoint[attribute_to_check])){ + showHeadline = true + headline = this.hasFeature('long_distance_routes') ? sp.country_name : sp.city_name + } + return showHeadline ? headline : "" + } +} diff --git a/app/javascript/journey_patterns/components/JourneyPattern.js b/app/javascript/journey_patterns/components/JourneyPattern.js index 47fb6882d..2ae9f5552 100644 --- a/app/javascript/journey_patterns/components/JourneyPattern.js +++ b/app/javascript/journey_patterns/components/JourneyPattern.js @@ -32,8 +32,8 @@ export default class JourneyPattern extends Component{ return this.props.status.features[key] } - cityNameChecker(sp) { - return this.props.journeyPatterns.showHeader(sp.object_id) + cityNameChecker(sp, i) { + return this.props.journeyPatterns.showHeader(sp.object_id + "-" + i) } spNode(sp, headlined){ @@ -149,7 +149,7 @@ export default class JourneyPattern extends Component{ if(stopPoint.checked){ this.previousSpId = stopPoint.id } - let headlined = this.cityNameChecker(stopPoint) + let headlined = this.cityNameChecker(stopPoint, i) return (
    diff --git a/app/javascript/journey_patterns/components/JourneyPatterns.js b/app/javascript/journey_patterns/components/JourneyPatterns.js index c261b408a..31727fefc 100644 --- a/app/javascript/journey_patterns/components/JourneyPatterns.js +++ b/app/javascript/journey_patterns/components/JourneyPatterns.js @@ -2,12 +2,16 @@ import React, { Component } from 'react' import PropTypes from 'prop-types' import _ from 'lodash' import JourneyPattern from './JourneyPattern' - +import StopAreaHeaderManager from '../../helpers/stop_area_header_manager' export default class JourneyPatterns extends Component { constructor(props){ super(props) - this.stopPointsIds = _.map(this.props.stopPointsList, (sp)=>{return sp.stop_area_object_id}) + this.headerManager = new StopAreaHeaderManager( + _.map(this.props.stopPointsList, (sp, i)=>{return sp.stop_area_object_id + "-" + i}), + this.props.stopPointsList, + this.props.status.features + ) } componentDidMount() { @@ -58,30 +62,7 @@ export default class JourneyPatterns extends Component { } showHeader(object_id) { - let showHeadline = false - let headline = "" - let attribute_to_check = this.hasFeature('long_distance_routes') ? "country_code" : "city_name" - let index = this.stopPointsIds.indexOf(object_id) - let sp = this.props.stopPointsList[index] - let previousBreakpoint = this.props.stopPointsList[index - 1] - if(index == 0 || (sp[attribute_to_check] != previousBreakpoint[attribute_to_check])){ - showHeadline = true - headline = this.hasFeature('long_distance_routes') ? sp.country_name : sp.city_name - } - return showHeadline ? headline : "" - } - - stopPointHeader(sp) { - let showHeadline = this.showHeader(sp.stop_area_object_id) - return ( -
    - {sp.name} -
    - ) + return this.headerManager.showHeader(object_id) } hasFeature(key) { @@ -133,7 +114,7 @@ export default class JourneyPatterns extends Component { {this.props.stopPointsList.map((sp, i) =>{ return (
    - {this.stopPointHeader(sp)} + {this.headerManager.stopPointHeader(sp.stop_area_object_id + "-" + i)}
    ) })} diff --git a/app/javascript/vehicle_journeys/components/VehicleJourneys.js b/app/javascript/vehicle_journeys/components/VehicleJourneys.js index 3f5a51093..b188962c2 100644 --- a/app/javascript/vehicle_journeys/components/VehicleJourneys.js +++ b/app/javascript/vehicle_journeys/components/VehicleJourneys.js @@ -2,13 +2,18 @@ import React, { Component } from 'react' import PropTypes from 'prop-types' import _ from 'lodash' import VehicleJourney from './VehicleJourney' - +import StopAreaHeaderManager from '../../helpers/stop_area_header_manager' export default class VehicleJourneys extends Component { constructor(props){ super(props) - this.stopPointsIds = _.map(this.props.stopPointsList, (sp)=>{return sp.object_id}) + this.headerManager = new StopAreaHeaderManager( + _.map(this.props.stopPointsList, (sp)=>{return sp.object_id}), + this.props.stopPointsList, + this.props.filters.features + ) } + componentDidMount() { this.props.onLoadFirstPage(this.props.filters) } @@ -17,6 +22,10 @@ export default class VehicleJourneys extends Component { return this.props.filters.features[key] } + showHeader(object_id) { + return this.headerManager.showHeader(object_id) + } + componentDidUpdate(prevProps, prevState) { if(this.props.status.isFetching == false){ $('.table-2entries').each(function() { @@ -60,33 +69,6 @@ export default class VehicleJourneys extends Component { } } - showHeader(object_id) { - let showHeadline = false - let headline = "" - let attribute_to_check = this.hasFeature('long_distance_routes') ? "country_code" : "city_name" - let index = this.stopPointsIds.indexOf(object_id) - let sp = this.props.stopPointsList[index] - let previousBreakpoint = this.props.stopPointsList[index - 1] - if(index == 0 || (sp[attribute_to_check] != previousBreakpoint[attribute_to_check])){ - showHeadline = true - headline = this.hasFeature('long_distance_routes') ? sp.country_name : sp.city_name - } - return showHeadline ? headline : "" - } - - stopPointHeader(sp) { - let showHeadline = this.showHeader(sp.object_id) - return ( -
    - {sp.name} -
    - ) - } - render() { this.previousBreakpoint = undefined @@ -135,7 +117,7 @@ export default class VehicleJourneys extends Component { {this.props.stopPointsList.map((sp, i) =>{ return (
    - {this.stopPointHeader(sp)} + {this.headerManager.stopPointHeader(sp.object_id)}
    ) })} -- cgit v1.2.3 From 8309461a4303de66c726e7b9d876d0eb5efafe59 Mon Sep 17 00:00:00 2001 From: Alban Peignier Date: Wed, 10 Jan 2018 15:54:55 +0100 Subject: import PropTypes from prop-types. Refs #5156 --- app/javascript/routes/components/App.js | 7 ++++--- app/javascript/routes/components/BSelect2.js | 3 ++- app/javascript/routes/components/OlMap.js | 3 ++- 3 files changed, 8 insertions(+), 5 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/routes/components/App.js b/app/javascript/routes/components/App.js index 0f5786407..26e69bf53 100644 --- a/app/javascript/routes/components/App.js +++ b/app/javascript/routes/components/App.js @@ -1,4 +1,5 @@ -import React, { Component, PropTypes } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' import AddStopPoint from '../containers/AddStopPoint' import VisibleStopPoints from'../containers/VisibleStopPoints' import clone from '../../helpers/clone' @@ -16,8 +17,8 @@ export default class App extends Component {
    - ) - } + ) + } } App.childContextTypes = { diff --git a/app/javascript/routes/components/BSelect2.js b/app/javascript/routes/components/BSelect2.js index 2ec7cd710..158deaa17 100644 --- a/app/javascript/routes/components/BSelect2.js +++ b/app/javascript/routes/components/BSelect2.js @@ -1,5 +1,6 @@ import _ from'lodash' -import React, { Component, PropTypes } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' import Select2 from 'react-select2-wrapper' diff --git a/app/javascript/routes/components/OlMap.js b/app/javascript/routes/components/OlMap.js index 2c01dfa7f..056bddbcb 100644 --- a/app/javascript/routes/components/OlMap.js +++ b/app/javascript/routes/components/OlMap.js @@ -1,5 +1,6 @@ import _ from 'lodash' -import React, { Component, PropTypes } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' export default class OlMap extends Component{ constructor(props, context){ -- cgit v1.2.3 From 18d6fa534a33cf9d3b3d8a7ab680851b2a0afff4 Mon Sep 17 00:00:00 2001 From: Alban Peignier Date: Wed, 10 Jan 2018 15:55:08 +0100 Subject: Import createLogger. Refs #5156 --- app/javascript/packs/routes/edit.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/javascript') diff --git a/app/javascript/packs/routes/edit.js b/app/javascript/packs/routes/edit.js index d31e94878..b787bec97 100644 --- a/app/javascript/packs/routes/edit.js +++ b/app/javascript/packs/routes/edit.js @@ -14,7 +14,7 @@ datas = JSON.parse(decodeURIComponent(datas)) // logger, DO NOT REMOVE var applyMiddleware = require('redux').applyMiddleware -var createLogger = require('redux-logger') +import {createLogger} from 'redux-logger'; var thunkMiddleware = require('redux-thunk').default var promise = require('redux-promise') -- cgit v1.2.3 From c8a2e2ce194d3d051bb96522c40c4d34392bdf8e Mon Sep 17 00:00:00 2001 From: Zog Date: Wed, 10 Jan 2018 18:24:54 +0100 Subject: Refs #5535 @2H; Automatically fill VJs tilmes when possible --- app/javascript/vehicle_journeys/actions/index.js | 4 ++- .../components/tools/CreateModal.js | 25 ++++++++++++++++++ .../vehicle_journeys/reducers/vehicleJourneys.js | 30 +++++++++++++++++++--- 3 files changed, 54 insertions(+), 5 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/vehicle_journeys/actions/index.js b/app/javascript/vehicle_journeys/actions/index.js index 40c8006f1..95e56cd76 100644 --- a/app/javascript/vehicle_journeys/actions/index.js +++ b/app/javascript/vehicle_journeys/actions/index.js @@ -59,7 +59,9 @@ const actions = { objectid: selectedJP.object_id, name: selectedJP.name, published_name: selectedJP.published_name, - stop_areas: selectedJP.stop_area_short_descriptions + stop_areas: selectedJP.stop_area_short_descriptions, + costs: selectedJP.costs, + full_schedule: selectedJP.full_schedule } }), openEditModal : (vehicleJourney) => ({ diff --git a/app/javascript/vehicle_journeys/components/tools/CreateModal.js b/app/javascript/vehicle_journeys/components/tools/CreateModal.js index 61012d199..afc4bc42b 100644 --- a/app/javascript/vehicle_journeys/components/tools/CreateModal.js +++ b/app/javascript/vehicle_journeys/components/tools/CreateModal.js @@ -88,6 +88,31 @@ export default class CreateModal extends Component { />
    + { this.props.modal.modalProps.selectedJPModal && this.props.modal.modalProps.selectedJPModal.full_schedule &&
    +
    + +
    + actions.resetValidation(e.currentTarget)} + /> + actions.resetValidation(e.currentTarget)} + /> +
    +
    +
    + } +
    diff --git a/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js b/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js index d057bf704..0549c7adc 100644 --- a/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js +++ b/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js @@ -9,16 +9,37 @@ const vehicleJourney= (state = {}, action, keep) => { return _.assign({}, state, {selected: false}) case 'ADD_VEHICLEJOURNEY': let pristineVjasList = [] + let prevSp = action.stopPointsList[0] + let current_time = { + hour: 0, + minute: 0 + } + if(action.data["start_time.hour"] && action.data["start_time.minute"] && action.selectedJourneyPattern.full_schedule){ + current_time.hour = parseInt(action.data["start_time.hour"].value) + current_time.minute = parseInt(action.data["start_time.minute"].value) + } _.each(action.stopPointsList, (sp) =>{ + if(action.selectedJourneyPattern.full_schedule && action.selectedJourneyPattern.costs && action.selectedJourneyPattern.costs[prevSp.stop_area_id + "-" + sp.stop_area_id]){ + let delta = parseInt(action.selectedJourneyPattern.costs[prevSp.stop_area_id + "-" + sp.stop_area_id].time) + let delta_hour = parseInt(delta/60) + let delta_minute = delta - 60*delta_hour + current_time.hour += delta_hour + current_time.minute += delta_minute + let extra_hours = parseInt(current_time.minute/60) + current_time.hour += extra_hours + current_time.minute -= extra_hours*60 + current_time.hour = current_time.hour % 24 + prevSp = sp + } let newVjas = { delta: 0, departure_time:{ - hour: '00', - minute: '00' + hour: current_time.hour, + minute: current_time.minute }, arrival_time:{ - hour: '00', - minute: '00' + hour: current_time.hour, + minute: current_time.minute }, stop_point_objectid: sp.object_id, stop_area_cityname: sp.city_name, @@ -31,6 +52,7 @@ const vehicleJourney= (state = {}, action, keep) => { } }) pristineVjasList.push(newVjas) + }) return { company: action.selectedCompany, -- cgit v1.2.3 From f7ed3ca6615bb4950b644d56136016c4482395a8 Mon Sep 17 00:00:00 2001 From: Zog Date: Thu, 11 Jan 2018 10:49:46 +0100 Subject: Refs #5536; Fix JourneyPattern creation --- app/javascript/journey_patterns/components/JourneyPattern.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/journey_patterns/components/JourneyPattern.js b/app/javascript/journey_patterns/components/JourneyPattern.js index 2ae9f5552..8dc542bc8 100644 --- a/app/javascript/journey_patterns/components/JourneyPattern.js +++ b/app/javascript/journey_patterns/components/JourneyPattern.js @@ -5,7 +5,6 @@ import actions from '../actions' export default class JourneyPattern extends Component{ constructor(props){ super(props) - this.previousCity = undefined this.previousSpId = undefined this.updateCosts = this.updateCosts.bind(this) } @@ -33,7 +32,7 @@ export default class JourneyPattern extends Component{ } cityNameChecker(sp, i) { - return this.props.journeyPatterns.showHeader(sp.object_id + "-" + i) + return this.props.journeyPatterns.showHeader((sp.stop_area_object_id || sp.object_id) + "-" + i) } spNode(sp, headlined){ @@ -76,7 +75,6 @@ export default class JourneyPattern extends Component{ } render() { - this.previousCity = undefined this.previousSpId = undefined return (
    -- cgit v1.2.3 From 25ddf5946b9e0e5412e6e0db5f0b6be264b59a72 Mon Sep 17 00:00:00 2001 From: Zog Date: Thu, 11 Jan 2018 11:30:04 +0100 Subject: Refs #5544; Fix bug preventing VJ creation When the company has not been set --- app/javascript/vehicle_journeys/components/tools/CreateModal.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/javascript') diff --git a/app/javascript/vehicle_journeys/components/tools/CreateModal.js b/app/javascript/vehicle_journeys/components/tools/CreateModal.js index 9ab87af3f..07c684760 100644 --- a/app/javascript/vehicle_journeys/components/tools/CreateModal.js +++ b/app/javascript/vehicle_journeys/components/tools/CreateModal.js @@ -11,7 +11,7 @@ export default class CreateModal extends Component { handleSubmit() { if (actions.validateFields(...this.refs, $('.vjCreateSelectJP')[0]) && this.props.modal.modalProps.selectedJPModal) { - this.props.onAddVehicleJourney(this.refs, this.props.modal.modalProps.selectedJPModal, this.props.stopPointsList, this.props.modal.modalProps.vehicleJourney.company) + this.props.onAddVehicleJourney(this.refs, this.props.modal.modalProps.selectedJPModal, this.props.stopPointsList, this.props.modal.modalProps.vehicleJourney && this.props.modal.modalProps.vehicleJourney.company) this.props.onModalClose() $('#NewVehicleJourneyModal').modal('hide') } -- cgit v1.2.3 From cb0564d4d7d35c8a43e166b68d8c7dc94341fc9d Mon Sep 17 00:00:00 2001 From: Zog Date: Thu, 11 Jan 2018 14:37:14 +0100 Subject: Refs #5551 @1.5h; Implement Custom fields edition RBD: implement the same in the creation modal --- .../components/tools/EditVehicleJourney.js | 22 ++++++++++++++++++++-- .../vehicle_journeys/reducers/vehicleJourneys.js | 7 +++++++ 2 files changed, 27 insertions(+), 2 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js b/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js index 08d74baba..b46857d19 100644 --- a/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js +++ b/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js @@ -2,10 +2,12 @@ import React, { Component } from 'react' import PropTypes from 'prop-types' import actions from '../../actions' import CompanySelect2 from './select2s/CompanySelect2' +import Select2 from 'react-select2-wrapper' export default class EditVehicleJourney extends Component { constructor(props) { super(props) + this.custom_fields = {} } handleSubmit() { @@ -15,8 +17,8 @@ export default class EditVehicleJourney extends Component { company = this.props.modal.modalProps.selectedCompany } else if (typeof this.props.modal.modalProps.vehicleJourney.company === "object") { company = this.props.modal.modalProps.vehicleJourney.company - } - this.props.onEditVehicleJourney(this.refs, company) + } + this.props.onEditVehicleJourney(_.assign({}, this.refs, {custom_fields: this.custom_fields}), company) this.props.onModalClose() $('#EditVehicleJourneyModal').modal('hide') } @@ -140,6 +142,22 @@ export default class EditVehicleJourney extends Component { defaultValue={this.props.modal.modalProps.vehicleJourney.checksum} />
    + {_.map(this.props.modal.modalProps.vehicleJourney.custom_fields, (cf, code) => +
    + + { + return {id: k, text: v} + })} + ref={'custom_fields.' + code} + className='form-control' + value={cf.value} + disabled={!this.props.editMode} + options={{theme: 'bootstrap'}} + onSelect={(e) => this.custom_fields[code] = e.params.data.id } + /> +
    + )}
    { diff --git a/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js b/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js index 0549c7adc..4ed85316f 100644 --- a/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js +++ b/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js @@ -144,10 +144,17 @@ export default function vehicleJourneys(state = [], action) { case 'EDIT_VEHICLEJOURNEY': return state.map((vj, i) => { if (vj.selected){ + let custom_fields = _.assign({}, vj.custom_fields) + _.each(custom_fields, (cf, code) => { + console.log(action.data.custom_fields) + let value = action.data.custom_fields[code] + custom_fields[code] = _.assign({}, custom_fields[code], {value}) + }) return _.assign({}, vj, { company: action.selectedCompany, published_journey_name: action.data.published_journey_name.value, published_journey_identifier: action.data.published_journey_identifier.value, + custom_fields: custom_fields, }) }else{ return vj -- cgit v1.2.3 From ed0faeaaa7bddc135c7b55f6d12fd09a739afacc Mon Sep 17 00:00:00 2001 From: Zog Date: Thu, 11 Jan 2018 15:42:37 +0100 Subject: Refs #5551 @0.5h; Implement the custom fields in the creation modal And Refactor the component in the process --- app/javascript/packs/vehicle_journeys/index.js | 3 +- .../components/tools/CreateModal.js | 9 +++- .../components/tools/CustomFieldsInputs.js | 50 ++++++++++++++++++++++ .../components/tools/EditVehicleJourney.js | 27 ++++-------- .../containers/tools/AddVehicleJourney.js | 1 + .../vehicle_journeys/reducers/custom_fields.js | 6 +++ app/javascript/vehicle_journeys/reducers/index.js | 4 +- .../vehicle_journeys/reducers/vehicleJourneys.js | 7 +-- 8 files changed, 83 insertions(+), 24 deletions(-) create mode 100644 app/javascript/vehicle_journeys/components/tools/CustomFieldsInputs.js create mode 100644 app/javascript/vehicle_journeys/reducers/custom_fields.js (limited to 'app/javascript') diff --git a/app/javascript/packs/vehicle_journeys/index.js b/app/javascript/packs/vehicle_journeys/index.js index ab28371fe..aa5738d59 100644 --- a/app/javascript/packs/vehicle_journeys/index.js +++ b/app/javascript/packs/vehicle_journeys/index.js @@ -71,7 +71,8 @@ var initialState = { modalProps: {}, confirmModal: {} }, - missions: window.all_missions + missions: window.all_missions, + custom_fields: window.custom_fields } if (window.jpOrigin){ diff --git a/app/javascript/vehicle_journeys/components/tools/CreateModal.js b/app/javascript/vehicle_journeys/components/tools/CreateModal.js index 07c684760..90328458b 100644 --- a/app/javascript/vehicle_journeys/components/tools/CreateModal.js +++ b/app/javascript/vehicle_journeys/components/tools/CreateModal.js @@ -3,15 +3,17 @@ import PropTypes from 'prop-types' import actions from '../../actions' import MissionSelect2 from './select2s/MissionSelect2' import CompanySelect2 from './select2s/CompanySelect2' +import CustomFieldsInputs from './CustomFieldsInputs' export default class CreateModal extends Component { constructor(props) { super(props) + this.custom_fields = _.assign({}, this.props.custom_fields) } handleSubmit() { if (actions.validateFields(...this.refs, $('.vjCreateSelectJP')[0]) && this.props.modal.modalProps.selectedJPModal) { - this.props.onAddVehicleJourney(this.refs, this.props.modal.modalProps.selectedJPModal, this.props.stopPointsList, this.props.modal.modalProps.vehicleJourney && this.props.modal.modalProps.vehicleJourney.company) + this.props.onAddVehicleJourney(_.assign({}, this.refs, {custom_fields: this.custom_fields}), this.props.modal.modalProps.selectedJPModal, this.props.stopPointsList, this.props.modal.modalProps.vehicleJourney && this.props.modal.modalProps.vehicleJourney.company) this.props.onModalClose() $('#NewVehicleJourneyModal').modal('hide') } @@ -89,6 +91,11 @@ export default class CreateModal extends Component { />
    + this.custom_fields[code]["value"] = value} + disabled={false} + /> { this.props.modal.modalProps.selectedJPModal && this.props.modal.modalProps.selectedJPModal.full_schedule &&
    diff --git a/app/javascript/vehicle_journeys/components/tools/CustomFieldsInputs.js b/app/javascript/vehicle_journeys/components/tools/CustomFieldsInputs.js new file mode 100644 index 000000000..eb8eb7080 --- /dev/null +++ b/app/javascript/vehicle_journeys/components/tools/CustomFieldsInputs.js @@ -0,0 +1,50 @@ +import _ from 'lodash' +import Select2 from 'react-select2-wrapper' +import React, { Component } from 'react' +import PropTypes from 'prop-types' + +export default class CustomFieldsInputs extends Component { + constructor(props) { + super(props) + } + + listInput(cf){ + return( + { + return {id: k, text: (v.length > 0 ? v : '\u00A0')} + })} + ref={'custom_fields.' + cf.code} + className='form-control' + value={cf.value} + disabled={this.props.disabled} + options={{ + theme: 'bootstrap', + width: '100%' + }} + onSelect={(e) => this.props.onUpdate(cf.code, e.params.data.id) } + /> + ) + } + + render() { + return ( +
    + {_.map(this.props.values, (cf, code) => +
    +
    + + {this[cf.field_type + "Input"](cf)} +
    +
    + )} +
    + ) + } +} + +CustomFieldsInputs.propTypes = { + onUpdate: PropTypes.func.isRequired, + values: PropTypes.object.isRequired, + disabled: PropTypes.bool.isRequired +} diff --git a/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js b/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js index b46857d19..1ac161485 100644 --- a/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js +++ b/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js @@ -2,7 +2,7 @@ import React, { Component } from 'react' import PropTypes from 'prop-types' import actions from '../../actions' import CompanySelect2 from './select2s/CompanySelect2' -import Select2 from 'react-select2-wrapper' +import CustomFieldsInputs from './CustomFieldsInputs' export default class EditVehicleJourney extends Component { constructor(props) { @@ -142,24 +142,15 @@ export default class EditVehicleJourney extends Component { defaultValue={this.props.modal.modalProps.vehicleJourney.checksum} />
    - {_.map(this.props.modal.modalProps.vehicleJourney.custom_fields, (cf, code) => -
    - - { - return {id: k, text: v} - })} - ref={'custom_fields.' + code} - className='form-control' - value={cf.value} - disabled={!this.props.editMode} - options={{theme: 'bootstrap'}} - onSelect={(e) => this.custom_fields[code] = e.params.data.id } - /> -
    - )} - +
    + this.custom_fields[code] = value} + disabled={!this.props.editMode} + /> +
    + { this.props.editMode &&
    diff --git a/app/javascript/vehicle_journeys/containers/tools/AddVehicleJourney.js b/app/javascript/vehicle_journeys/containers/tools/AddVehicleJourney.js index 0f4a0ea7d..0db7628be 100644 --- a/app/javascript/vehicle_journeys/containers/tools/AddVehicleJourney.js +++ b/app/javascript/vehicle_journeys/containers/tools/AddVehicleJourney.js @@ -10,6 +10,7 @@ const mapStateToProps = (state, ownProps) => { status: state.status, stopPointsList: state.stopPointsList, missions: state.missions, + custom_fields: state.custom_fields, } } diff --git a/app/javascript/vehicle_journeys/reducers/custom_fields.js b/app/javascript/vehicle_journeys/reducers/custom_fields.js new file mode 100644 index 000000000..482fd91cb --- /dev/null +++ b/app/javascript/vehicle_journeys/reducers/custom_fields.js @@ -0,0 +1,6 @@ +export default function custom_fields(state = [], action) { + switch (action.type) { + default: + return state + } +} diff --git a/app/javascript/vehicle_journeys/reducers/index.js b/app/javascript/vehicle_journeys/reducers/index.js index 862c864ae..1963f7c6d 100644 --- a/app/javascript/vehicle_journeys/reducers/index.js +++ b/app/javascript/vehicle_journeys/reducers/index.js @@ -7,6 +7,7 @@ import filters from './filters' import editMode from './editMode' import stopPointsList from './stopPointsList' import missions from './missions' +import custom_fields from './custom_fields' const vehicleJourneysApp = combineReducers({ vehicleJourneys, @@ -16,7 +17,8 @@ const vehicleJourneysApp = combineReducers({ filters, editMode, stopPointsList, - missions + missions, + custom_fields }) export default vehicleJourneysApp diff --git a/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js b/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js index 4ed85316f..8d68ad2db 100644 --- a/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js +++ b/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js @@ -54,6 +54,7 @@ const vehicleJourney= (state = {}, action, keep) => { pristineVjasList.push(newVjas) }) + return { company: action.selectedCompany, journey_pattern: action.selectedJourneyPattern, @@ -68,7 +69,8 @@ const vehicleJourney= (state = {}, action, keep) => { selected: false, deletable: false, transport_mode: window.transportMode ? window.transportMode : 'undefined', - transport_submode: window.transportSubmode ? window.transportSubmode : 'undefined' + transport_submode: window.transportSubmode ? window.transportSubmode : 'undefined', + custom_fields: action.data.custom_fields } case 'DUPLICATE_VEHICLEJOURNEY': case 'SHIFT_VEHICLEJOURNEY': @@ -144,9 +146,8 @@ export default function vehicleJourneys(state = [], action) { case 'EDIT_VEHICLEJOURNEY': return state.map((vj, i) => { if (vj.selected){ - let custom_fields = _.assign({}, vj.custom_fields) + let custom_fields = _.assign({}, action.data.custom_fields) _.each(custom_fields, (cf, code) => { - console.log(action.data.custom_fields) let value = action.data.custom_fields[code] custom_fields[code] = _.assign({}, custom_fields[code], {value}) }) -- cgit v1.2.3 From 69f4fe0c2ef6426282bb8315b185f2e13e37310c Mon Sep 17 00:00:00 2001 From: Zog Date: Thu, 11 Jan 2018 17:47:21 +0100 Subject: Refs #5556 @0.25h; Show total time and distance in JP editor --- .../journey_patterns/components/JourneyPattern.js | 65 ++++++++++++++++------ 1 file changed, 49 insertions(+), 16 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/journey_patterns/components/JourneyPattern.js b/app/javascript/journey_patterns/components/JourneyPattern.js index 8dc542bc8..b951b4445 100644 --- a/app/javascript/journey_patterns/components/JourneyPattern.js +++ b/app/javascript/journey_patterns/components/JourneyPattern.js @@ -74,18 +74,60 @@ export default class JourneyPattern extends Component{ return !this.props.status.policy[`journey_patterns.${action}`] } + totals(){ + let totalTime = 0 + let totalDistance = 0 + let from = null + this.props.value.stop_points.map((stopPoint, i) =>{ + if(from && stopPoint.checked){ + let [costsKey, costs, time, distance] = this.getTimeAndDistanceBetweenStops(from, stopPoint.id) + totalTime += time + totalDistance += distance + } + if(stopPoint.checked){ + from = stopPoint.id + } + }) + return [this.formatTime(totalTime), this.formatDistance(totalDistance)] + } + + getTimeAndDistanceBetweenStops(from, to){ + let costsKey = from + "-" + to + let costs = this.props.value.costs[costsKey] || {distance: 0, time: 0} + let time = costs['time'] || 0 + let distance = costs['distance'] || 0 + return [costsKey, costs, time, distance] + } + + formatDistance(distance){ + return parseFloat(Math.round(distance * 100) / 100).toFixed(2) + " km" + } + + formatTime(time){ + if(time < 60){ + return time + " min" + } + else{ + let hours = parseInt(time/60) + return hours + " h " + (time - 60*hours) + " min" + } + } + render() { this.previousSpId = undefined + let [totalTime, totalDistance] = this.totals() return (
    - {/* Errors */} - {/* this.props.value.errors ? this.getErrors(this.props.value.errors) : '' */} -
    {this.props.value.object_id ? this.props.value.short_id : '-'}
    {this.props.value.registration_number}
    {actions.getChecked(this.props.value.stop_points).length} arrêt(s)
    - + {this.hasFeature('costs_in_journey_patterns') && +
    + {totalTime} + {totalDistance} +
    + }
    } {!this.props.editMode &&
    -

    {(costs['distance'] || 0) + " km"}

    +

    {this.formatDistance(costs['distance'] || 0)}

    {time_in_words}

    }
    } -- cgit v1.2.3 From 5844565ac4e4fe6cc6572bbe42b850e3cce0b541 Mon Sep 17 00:00:00 2001 From: Alban Peignier Date: Thu, 11 Jan 2018 18:58:42 +0100 Subject: Fixes icons and order of total. Refs #5556 --- app/javascript/journey_patterns/components/JourneyPattern.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/journey_patterns/components/JourneyPattern.js b/app/javascript/journey_patterns/components/JourneyPattern.js index b951b4445..ecbebe2cc 100644 --- a/app/javascript/journey_patterns/components/JourneyPattern.js +++ b/app/javascript/journey_patterns/components/JourneyPattern.js @@ -124,8 +124,8 @@ export default class JourneyPattern extends Component{
    {actions.getChecked(this.props.value.stop_points).length} arrêt(s)
    {this.hasFeature('costs_in_journey_patterns') &&
    - {totalTime} - {totalDistance} + {totalDistance} + {totalTime}
    }
    -- cgit v1.2.3 From dab42556bd956aa07fa2e423e85a647c166b9e0e Mon Sep 17 00:00:00 2001 From: Zog Date: Thu, 11 Jan 2018 21:09:50 +0100 Subject: Refs #5551; Fix bug when the user reopens the modal --- .../vehicle_journeys/components/tools/CustomFieldsInputs.js | 2 +- .../vehicle_journeys/components/tools/EditVehicleJourney.js | 6 ++++-- app/javascript/vehicle_journeys/reducers/vehicleJourneys.js | 7 +------ 3 files changed, 6 insertions(+), 9 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/vehicle_journeys/components/tools/CustomFieldsInputs.js b/app/javascript/vehicle_journeys/components/tools/CustomFieldsInputs.js index eb8eb7080..90d72a801 100644 --- a/app/javascript/vehicle_journeys/components/tools/CustomFieldsInputs.js +++ b/app/javascript/vehicle_journeys/components/tools/CustomFieldsInputs.js @@ -16,7 +16,7 @@ export default class CustomFieldsInputs extends Component { })} ref={'custom_fields.' + cf.code} className='form-control' - value={cf.value} + defaultValue={cf.value} disabled={this.props.disabled} options={{ theme: 'bootstrap', diff --git a/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js b/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js index 1ac161485..2893422f8 100644 --- a/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js +++ b/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js @@ -7,7 +7,6 @@ import CustomFieldsInputs from './CustomFieldsInputs' export default class EditVehicleJourney extends Component { constructor(props) { super(props) - this.custom_fields = {} } handleSubmit() { @@ -29,6 +28,9 @@ export default class EditVehicleJourney extends Component { return false } if(this.props.status.fetchSuccess == true) { + if(this.props.modal.modalProps.vehicleJourney){ + this.custom_fields = _.assign({}, this.props.modal.modalProps.vehicleJourney.custom_fields) + } return (
  • diff --git a/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js b/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js index 8d68ad2db..62b846d9a 100644 --- a/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js +++ b/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js @@ -146,16 +146,11 @@ export default function vehicleJourneys(state = [], action) { case 'EDIT_VEHICLEJOURNEY': return state.map((vj, i) => { if (vj.selected){ - let custom_fields = _.assign({}, action.data.custom_fields) - _.each(custom_fields, (cf, code) => { - let value = action.data.custom_fields[code] - custom_fields[code] = _.assign({}, custom_fields[code], {value}) - }) return _.assign({}, vj, { company: action.selectedCompany, published_journey_name: action.data.published_journey_name.value, published_journey_identifier: action.data.published_journey_identifier.value, - custom_fields: custom_fields, + custom_fields: action.data.custom_fields, }) }else{ return vj -- cgit v1.2.3 From ef3942099583f86d3f355a1bac8d99ce16cd2de3 Mon Sep 17 00:00:00 2001 From: Zog Date: Mon, 8 Jan 2018 11:06:20 +0100 Subject: Refs #5493 @1h; Use local time in the Journeys editor We store UTC times in the database though --- app/javascript/helpers/stop_area_header_manager.js | 9 ++++++++- app/javascript/vehicle_journeys/components/VehicleJourneys.js | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/helpers/stop_area_header_manager.js b/app/javascript/helpers/stop_area_header_manager.js index 54d957be9..c9f397dee 100644 --- a/app/javascript/helpers/stop_area_header_manager.js +++ b/app/javascript/helpers/stop_area_header_manager.js @@ -21,7 +21,14 @@ export default class StopAreaHeaderManager { data-headline={showHeadline} title={sp.city_name + ' (' + sp.zip_code +')'} > - {sp.name} + + + {sp.name} + {sp.time_zone_formatted_offset && +  ({sp.time_zone_formatted_offset}) + } + +
    ) } diff --git a/app/javascript/vehicle_journeys/components/VehicleJourneys.js b/app/javascript/vehicle_journeys/components/VehicleJourneys.js index b188962c2..36721b55b 100644 --- a/app/javascript/vehicle_journeys/components/VehicleJourneys.js +++ b/app/javascript/vehicle_journeys/components/VehicleJourneys.js @@ -109,8 +109,8 @@ export default class VehicleJourneys extends Component {
    ID course
    Nom course
    -
    ID mission
    Transporteur
    +
    ID mission
    Calendriers
    { this.hasFeature('purchase_windows') &&
    Calendriers Commerciaux
    }
    -- cgit v1.2.3 From f2f3302307dd51504855573a29a64ae694b55a37 Mon Sep 17 00:00:00 2001 From: Zog Date: Thu, 11 Jan 2018 22:33:07 +0100 Subject: Fix specs --- app/javascript/vehicle_journeys/components/VehicleJourneys.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/javascript') diff --git a/app/javascript/vehicle_journeys/components/VehicleJourneys.js b/app/javascript/vehicle_journeys/components/VehicleJourneys.js index 36721b55b..b188962c2 100644 --- a/app/javascript/vehicle_journeys/components/VehicleJourneys.js +++ b/app/javascript/vehicle_journeys/components/VehicleJourneys.js @@ -109,8 +109,8 @@ export default class VehicleJourneys extends Component {
    ID course
    Nom course
    -
    Transporteur
    ID mission
    +
    Transporteur
    Calendriers
    { this.hasFeature('purchase_windows') &&
    Calendriers Commerciaux
    }
    -- cgit v1.2.3 From bc322675d206ff666e4e6ab577f193d67673639b Mon Sep 17 00:00:00 2001 From: Zog Date: Thu, 11 Jan 2018 21:37:13 +0100 Subject: Refs #5535; Don't generate time for disabled stops --- app/javascript/vehicle_journeys/reducers/vehicleJourneys.js | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'app/javascript') diff --git a/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js b/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js index 62b846d9a..a64966da4 100644 --- a/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js +++ b/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js @@ -18,6 +18,7 @@ const vehicleJourney= (state = {}, action, keep) => { current_time.hour = parseInt(action.data["start_time.hour"].value) current_time.minute = parseInt(action.data["start_time.minute"].value) } + console.log(state) _.each(action.stopPointsList, (sp) =>{ if(action.selectedJourneyPattern.full_schedule && action.selectedJourneyPattern.costs && action.selectedJourneyPattern.costs[prevSp.stop_area_id + "-" + sp.stop_area_id]){ let delta = parseInt(action.selectedJourneyPattern.costs[prevSp.stop_area_id + "-" + sp.stop_area_id].time) @@ -45,12 +46,18 @@ const vehicleJourney= (state = {}, action, keep) => { stop_area_cityname: sp.city_name, dummy: true } + _.each(action.selectedJourneyPattern.stop_areas, (jp) =>{ if (jp.stop_area_short_description.id == sp.id){ newVjas.dummy = false return } }) + + if(newVjas.dummy){ + newVjas.departure_time = {hour: "00", minute: "00"} + newVjas.arrival_time = {hour: "00", minute: "00"} + } pristineVjasList.push(newVjas) }) -- cgit v1.2.3 From 37fc636a9073498b464bd2b9f3be1fa2258f9828 Mon Sep 17 00:00:00 2001 From: Zog Date: Thu, 11 Jan 2018 21:51:45 +0100 Subject: :fire: log --- app/javascript/vehicle_journeys/reducers/vehicleJourneys.js | 1 - 1 file changed, 1 deletion(-) (limited to 'app/javascript') diff --git a/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js b/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js index a64966da4..68bbe18d2 100644 --- a/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js +++ b/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js @@ -18,7 +18,6 @@ const vehicleJourney= (state = {}, action, keep) => { current_time.hour = parseInt(action.data["start_time.hour"].value) current_time.minute = parseInt(action.data["start_time.minute"].value) } - console.log(state) _.each(action.stopPointsList, (sp) =>{ if(action.selectedJourneyPattern.full_schedule && action.selectedJourneyPattern.costs && action.selectedJourneyPattern.costs[prevSp.stop_area_id + "-" + sp.stop_area_id]){ let delta = parseInt(action.selectedJourneyPattern.costs[prevSp.stop_area_id + "-" + sp.stop_area_id].time) -- cgit v1.2.3 From 3e0591073505eb24b27dfe24b433f2bfece0daa7 Mon Sep 17 00:00:00 2001 From: Zog Date: Thu, 11 Jan 2018 22:12:47 +0100 Subject: Refs #5535; Apply timezones during schedule calculation --- app/javascript/vehicle_journeys/reducers/vehicleJourneys.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js b/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js index 68bbe18d2..149b3e23f 100644 --- a/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js +++ b/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js @@ -31,15 +31,17 @@ const vehicleJourney= (state = {}, action, keep) => { current_time.hour = current_time.hour % 24 prevSp = sp } + let offsetHours = sp.time_zone_offset / 3600 + let offsetminutes = sp.time_zone_offset/60 - 60*offsetHours let newVjas = { delta: 0, departure_time:{ - hour: current_time.hour, - minute: current_time.minute + hour: (current_time.hour + offsetHours) % 24, + minute: current_time.minute + offsetminutes }, arrival_time:{ - hour: current_time.hour, - minute: current_time.minute + hour: (current_time.hour + offsetHours) % 24, + minute: current_time.minute + offsetminutes }, stop_point_objectid: sp.object_id, stop_area_cityname: sp.city_name, -- cgit v1.2.3 From ba82ba8a00455eaaaa0e0c3c708cfcaf11ef0b0e Mon Sep 17 00:00:00 2001 From: Zog Date: Thu, 11 Jan 2018 22:23:40 +0100 Subject: Refs #5535; set day offsets when needed --- app/javascript/vehicle_journeys/reducers/vehicleJourneys.js | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'app/javascript') diff --git a/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js b/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js index 149b3e23f..737faaf4a 100644 --- a/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js +++ b/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js @@ -47,6 +47,14 @@ const vehicleJourney= (state = {}, action, keep) => { stop_area_cityname: sp.city_name, dummy: true } + if(current_time.hour + offsetHours > 24){ + vjas.departure_day_offset = 1 + vjas.arrival_day_offset = 1 + } + if(current_time.hour + offsetHours < 0){ + vjas.departure_day_offset = -1 + vjas.arrival_day_offset = -1 + } _.each(action.selectedJourneyPattern.stop_areas, (jp) =>{ if (jp.stop_area_short_description.id == sp.id){ -- cgit v1.2.3 From 216821cbc5410a1377dd57b09ee2753aee13e37c Mon Sep 17 00:00:00 2001 From: Zog Date: Thu, 11 Jan 2018 22:48:40 +0100 Subject: Refs #5535; Fix specs --- app/javascript/vehicle_journeys/reducers/vehicleJourneys.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js b/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js index 737faaf4a..501c01175 100644 --- a/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js +++ b/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js @@ -36,11 +36,11 @@ const vehicleJourney= (state = {}, action, keep) => { let newVjas = { delta: 0, departure_time:{ - hour: (current_time.hour + offsetHours) % 24, + hour: (24 + current_time.hour + offsetHours) % 24, minute: current_time.minute + offsetminutes }, arrival_time:{ - hour: (current_time.hour + offsetHours) % 24, + hour: (24 + current_time.hour + offsetHours) % 24, minute: current_time.minute + offsetminutes }, stop_point_objectid: sp.object_id, @@ -48,12 +48,12 @@ const vehicleJourney= (state = {}, action, keep) => { dummy: true } if(current_time.hour + offsetHours > 24){ - vjas.departure_day_offset = 1 - vjas.arrival_day_offset = 1 + newVjas.departure_day_offset = 1 + newVjas.arrival_day_offset = 1 } if(current_time.hour + offsetHours < 0){ - vjas.departure_day_offset = -1 - vjas.arrival_day_offset = -1 + newVjas.departure_day_offset = -1 + newVjas.arrival_day_offset = -1 } _.each(action.selectedJourneyPattern.stop_areas, (jp) =>{ -- cgit v1.2.3 From 853c7494b908c8b9dea3b91332ab1265aa40f428 Mon Sep 17 00:00:00 2001 From: Zog Date: Wed, 10 Jan 2018 15:21:42 +0100 Subject: Refs #5529 @0.5h; Prevent double submitting of react forms --- .../journey_patterns/components/SaveJourneyPattern.js | 17 +++++++++++++++-- .../vehicle_journeys/components/SaveVehicleJourneys.js | 15 ++++++++++++++- 2 files changed, 29 insertions(+), 3 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/journey_patterns/components/SaveJourneyPattern.js b/app/javascript/journey_patterns/components/SaveJourneyPattern.js index 7e4492e0e..d973147a0 100644 --- a/app/javascript/journey_patterns/components/SaveJourneyPattern.js +++ b/app/javascript/journey_patterns/components/SaveJourneyPattern.js @@ -7,6 +7,18 @@ export default class SaveJourneyPattern extends Component { super(props) } + btnDisabled(){ + return !this.props.status.fetchSuccess || this.props.status.isFetching + } + + btnClass(){ + let className = ['btn btn-default'] + if(this.btnDisabled()){ + className.push('disabled') + } + return className.join(' ') + } + render() { if(this.props.status.policy['journey_patterns.update'] == false) { return false @@ -16,8 +28,9 @@ export default class SaveJourneyPattern extends Component {
    {e.preventDefault()}}> +
    + +
    +
    + ) + } + } +} diff --git a/app/javascript/journey_patterns/components/SaveJourneyPattern.js b/app/javascript/journey_patterns/components/SaveJourneyPattern.js index d973147a0..4bb6a73a0 100644 --- a/app/javascript/journey_patterns/components/SaveJourneyPattern.js +++ b/app/javascript/journey_patterns/components/SaveJourneyPattern.js @@ -1,48 +1,19 @@ import React, { Component } from 'react' import PropTypes from 'prop-types' +import SaveButton from '../../helpers/save_button' import actions from '../actions' -export default class SaveJourneyPattern extends Component { - constructor(props){ - super(props) +export default class SaveJourneyPattern extends SaveButton { + hasPolicy(){ + return this.props.status.policy['journey_patterns.update'] == true } - btnDisabled(){ - return !this.props.status.fetchSuccess || this.props.status.isFetching + formClassName(){ + return 'jp_collection' } - btnClass(){ - let className = ['btn btn-default'] - if(this.btnDisabled()){ - className.push('disabled') - } - return className.join(' ') - } - - render() { - if(this.props.status.policy['journey_patterns.update'] == false) { - return false - }else{ - return ( -
    -
    -
    {e.preventDefault()}}> - -
    -
    -
    - ) - } + submitForm(){ + this.props.onSubmitJourneyPattern(this.props.dispatch, this.props.journeyPatterns) } } diff --git a/app/javascript/vehicle_journeys/components/SaveVehicleJourneys.js b/app/javascript/vehicle_journeys/components/SaveVehicleJourneys.js index 64fd7310e..6e94b04a3 100644 --- a/app/javascript/vehicle_journeys/components/SaveVehicleJourneys.js +++ b/app/javascript/vehicle_journeys/components/SaveVehicleJourneys.js @@ -1,50 +1,19 @@ import React, { Component } from 'react' import PropTypes from 'prop-types' +import SaveButton from '../../helpers/save_button' import actions from '../actions' -export default class SaveVehicleJourneys extends Component{ - constructor(props){ - super(props) +export default class SaveVehicleJourneys extends SaveButton{ + hasPolicy(){ + return this.props.filters.policy['vehicle_journeys.update'] == true } - btnDisabled(){ - return !this.props.status.fetchSuccess || this.props.status.isFetching + formClassName(){ + return 'vehicle_journeys' } - btnClass(){ - let className = ['btn btn-default'] - if(this.btnDisabled()){ - className.push('disabled') - } - return className.join(' ') - } - - render() { - if (this.props.filters.policy['vehicle_journeys.update'] == false) { - return false - }else{ - return ( -
    -
    -
    {e.preventDefault()}}> -
    - -
    -
    -
    -
    - ) - } + submitForm(){ + this.props.onSubmitVehicleJourneys(this.props.dispatch, this.props.vehicleJourneys) } } -- cgit v1.2.3 From 351af77182537dbb53e7bbd99d37dde50cd11ffe Mon Sep 17 00:00:00 2001 From: Zog Date: Wed, 17 Jan 2018 11:44:15 +0100 Subject: Refs #5614 @0.5h; Fix schedule computation when departure minutes are not set --- app/javascript/vehicle_journeys/reducers/vehicleJourneys.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/javascript') diff --git a/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js b/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js index 501c01175..ae45993a8 100644 --- a/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js +++ b/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js @@ -16,7 +16,7 @@ const vehicleJourney= (state = {}, action, keep) => { } if(action.data["start_time.hour"] && action.data["start_time.minute"] && action.selectedJourneyPattern.full_schedule){ current_time.hour = parseInt(action.data["start_time.hour"].value) - current_time.minute = parseInt(action.data["start_time.minute"].value) + current_time.minute = parseInt(action.data["start_time.minute"].value) || 0 } _.each(action.stopPointsList, (sp) =>{ if(action.selectedJourneyPattern.full_schedule && action.selectedJourneyPattern.costs && action.selectedJourneyPattern.costs[prevSp.stop_area_id + "-" + sp.stop_area_id]){ -- cgit v1.2.3 From 2eb5225e23c91656f0f35087adfd1545218ecb23 Mon Sep 17 00:00:00 2001 From: Zog Date: Wed, 17 Jan 2018 12:36:15 +0100 Subject: Refs #5623; Show journey departure time inputs when JP is prefilled --- app/javascript/vehicle_journeys/reducers/modal.js | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/vehicle_journeys/reducers/modal.js b/app/javascript/vehicle_journeys/reducers/modal.js index c2556303d..fb7e16547 100644 --- a/app/javascript/vehicle_journeys/reducers/modal.js +++ b/app/javascript/vehicle_journeys/reducers/modal.js @@ -147,14 +147,7 @@ export default function modal(state = {}, action) { let stopAreas = _.map(window.jpOriginStopPoints, (sa, i) =>{ return _.assign({}, {stop_area_short_description : {id : sa.stop_area_id}}) }) - selectedJP = { - id: window.jpOrigin.id, - name: window.jpOrigin.name, - published_name: window.jpOrigin.published_name, - objectid: window.jpOrigin.objectid, - stop_areas: stopAreas, - missions: state.missions - } + selectedJP = _.assign({}, window.jpOrigin, {stop_areas: stopAreas}) } return { type: 'create', -- cgit v1.2.3 From 050772225bdff8ef165c1e8e841b1eec664d6c99 Mon Sep 17 00:00:00 2001 From: Zog Date: Thu, 25 Jan 2018 11:39:32 +0100 Subject: Refs #5598; Enable button to view a JourneyPattern when the user is not allowed to edit it --- app/javascript/journey_patterns/components/JourneyPattern.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/journey_patterns/components/JourneyPattern.js b/app/javascript/journey_patterns/components/JourneyPattern.js index ecbebe2cc..01734f3a3 100644 --- a/app/javascript/journey_patterns/components/JourneyPattern.js +++ b/app/javascript/journey_patterns/components/JourneyPattern.js @@ -136,10 +136,9 @@ export default class JourneyPattern extends Component{
      -
    • +
      - {actions.monthName(month) + ' ' + new Date(month).getFullYear()} + {actions.monthName(month) + ' ' + new Date(month).getUTCFullYear()} ))} @@ -86,4 +86,4 @@ Navigate.propTypes = { status: PropTypes.object.isRequired, pagination: PropTypes.object.isRequired, dispatch: PropTypes.func.isRequired -} \ No newline at end of file +} -- cgit v1.2.3 From f6f52147fcec3b9283dc2890cfb05b0fb19bff33 Mon Sep 17 00:00:00 2001 From: Zog Date: Fri, 26 Jan 2018 12:49:23 +0100 Subject: Refs #5741 @2h; Add a map of all routes on a line#show --- app/javascript/helpers/routes_map.coffee | 157 ++++++++++++++++++++++ app/javascript/packs/referential_lines/show.js | 10 ++ app/javascript/packs/routes/show.js | 123 +---------------- app/javascript/routes/components/StopPointList.js | 4 +- 4 files changed, 174 insertions(+), 120 deletions(-) create mode 100644 app/javascript/helpers/routes_map.coffee create mode 100644 app/javascript/packs/referential_lines/show.js (limited to 'app/javascript') diff --git a/app/javascript/helpers/routes_map.coffee b/app/javascript/helpers/routes_map.coffee new file mode 100644 index 000000000..85def1390 --- /dev/null +++ b/app/javascript/helpers/routes_map.coffee @@ -0,0 +1,157 @@ +class RoutesMap + constructor: (@target)-> + @initMap() + @area = [] + @seenStopIds = [] + @routes = {} + + initMap: -> + @map = new ol.Map + target: @target, + layers: [ new ol.layer.Tile(source: new ol.source.OSM()) ] + controls: [ new ol.control.ScaleLine(), new ol.control.Zoom(), new ol.control.ZoomSlider() ], + interactions: ol.interaction.defaults(zoom: true) + view: new ol.View() + + addRoutes: (routes)-> + for route in routes + @addRoute route + + addRoute: (route)-> + geoColPts = [] + geoColLns = [] + @routes[route.id] = route if route.id + stops = route.stops || route + geoColEdges = [ + new ol.Feature({ + geometry: new ol.geom.Point(ol.proj.fromLonLat([parseFloat(stops[0].longitude), parseFloat(stops[0].latitude)])) + }), + new ol.Feature({ + geometry: new ol.geom.Point(ol.proj.fromLonLat([parseFloat(stops[stops.length - 1].longitude), parseFloat(stops[stops.length - 1].latitude)])) + }) + ] + stops.forEach (stop, i) => + if i < stops.length - 1 + geoColLns.push new ol.Feature + geometry: new ol.geom.LineString([ + ol.proj.fromLonLat([parseFloat(stops[i].longitude), parseFloat(stops[i].latitude)]), + ol.proj.fromLonLat([parseFloat(stops[i + 1].longitude), parseFloat(stops[i + 1].latitude)]) + ]) + + geoColPts.push(new ol.Feature({ + geometry: new ol.geom.Point(ol.proj.fromLonLat([parseFloat(stop.longitude), parseFloat(stop.latitude)])) + })) + unless @seenStopIds.indexOf(stop.stoparea_id) > 0 + @area.push [parseFloat(stop.longitude), parseFloat(stop.latitude)] + @seenStopIds.push stop.stoparea_id + + vectorPtsLayer = new ol.layer.Vector({ + source: new ol.source.Vector({ + features: geoColPts + }), + style: @defaultStyles(), + zIndex: 2 + }) + route.vectorPtsLayer = vectorPtsLayer if route.id + vectorEdgesLayer = new ol.layer.Vector({ + source: new ol.source.Vector({ + features: geoColEdges + }), + style: @edgeStyles(), + zIndex: 3 + }) + route.vectorEdgesLayer = vectorEdgesLayer if route.id + vectorLnsLayer = new ol.layer.Vector({ + source: new ol.source.Vector({ + features: geoColLns + }), + style: [@lineStyle()], + zIndex: 1 + }) + route.vectorLnsLayer = vectorLnsLayer if route.id + @map.addLayer vectorPtsLayer + @map.addLayer vectorEdgesLayer + @map.addLayer vectorLnsLayer + + lineStyle: (highlighted=false)-> + new ol.style.Style + stroke: new ol.style.Stroke + color: if highlighted then "#ed7f00" else '#007fbb' + width: 3 + + edgeStyles: (highlighted=false)-> + new ol.style.Style + image: new ol.style.Circle + radius: 5 + stroke: new ol.style.Stroke + color: if highlighted then "#ed7f00" else '#007fbb' + width: 2 + fill: new ol.style.Fill + color: if highlighted then "#ed7f00" else '#007fbb' + width: 2 + + defaultStyles: (highlighted=false)-> + new ol.style.Style + image: new ol.style.Circle + radius: 4 + stroke: new ol.style.Stroke + color: if highlighted then "#ed7f00" else '#007fbb' + width: 2 + fill: new ol.style.Fill + color: '#ffffff' + width: 2 + + addRoutesLabels: -> + labelsContainer = $("
        ") + labelsContainer.appendTo $("##{@target}") + @vectorPtsLayer = null + @vectorEdgesLayer = null + @vectorLnsLayer = null + Object.keys(@routes).forEach (id)=> + route = @routes[id] + label = $("
      • #{route.name}
      ") + label.appendTo labelsContainer + label.mouseleave => + route.vectorPtsLayer.setStyle @defaultStyles(false) + route.vectorEdgesLayer.setStyle @edgeStyles(false) + route.vectorLnsLayer.setStyle @lineStyle(false) + route.vectorPtsLayer.setZIndex 2 + route.vectorEdgesLayer.setZIndex 3 + route.vectorLnsLayer.setZIndex 1 + @fitZoom() + label.mouseenter => + route.vectorPtsLayer.setStyle @defaultStyles(true) + route.vectorEdgesLayer.setStyle @edgeStyles(true) + route.vectorLnsLayer.setStyle @lineStyle(true) + route.vectorPtsLayer.setZIndex 11 + route.vectorEdgesLayer.setZIndex 12 + route.vectorLnsLayer.setZIndex 10 + @fitZoom(route) + + fitZoom: (route)-> + if route + area = [] + route.stops.forEach (stop, i) => + area.push [parseFloat(stop.longitude), parseFloat(stop.latitude)] + else + area = @area + boundaries = ol.extent.applyTransform( + ol.extent.boundingExtent(area), ol.proj.getTransform('EPSG:4326', 'EPSG:3857') + ) + @map.getView().fit boundaries, @map.getSize() + tooCloseToBounds = false + mapBoundaries = @map.getView().calculateExtent @map.getSize() + mapWidth = mapBoundaries[2] - mapBoundaries[0] + mapHeight = mapBoundaries[3] - mapBoundaries[1] + marginSize = 0.1 + heightMargin = marginSize * mapHeight + widthMargin = marginSize * mapWidth + tooCloseToBounds = tooCloseToBounds || (boundaries[0] - mapBoundaries[0]) < widthMargin + tooCloseToBounds = tooCloseToBounds || (mapBoundaries[2] - boundaries[2]) < widthMargin + tooCloseToBounds = tooCloseToBounds || (boundaries[1] - mapBoundaries[1]) < heightMargin + tooCloseToBounds = tooCloseToBounds || (mapBoundaries[3] - boundaries[3]) < heightMargin + if tooCloseToBounds + @map.getView().setZoom(@map.getView().getZoom() - 1) + + +export default RoutesMap diff --git a/app/javascript/packs/referential_lines/show.js b/app/javascript/packs/referential_lines/show.js new file mode 100644 index 000000000..99c5072ef --- /dev/null +++ b/app/javascript/packs/referential_lines/show.js @@ -0,0 +1,10 @@ +import clone from '../../helpers/clone' +import RoutesMap from '../../helpers/routes_map' + +let routes = clone(window, "routes", true) +routes = JSON.parse(decodeURIComponent(routes)) + +var map = new RoutesMap('routes_map') +map.addRoutes(routes) +map.addRoutesLabels() +map.fitZoom() diff --git a/app/javascript/packs/routes/show.js b/app/javascript/packs/routes/show.js index 71777c379..c20de0800 100644 --- a/app/javascript/packs/routes/show.js +++ b/app/javascript/packs/routes/show.js @@ -1,121 +1,8 @@ import clone from '../../helpers/clone' +import RoutesMap from '../../helpers/routes_map' + let route = clone(window, "route", true) route = JSON.parse(decodeURIComponent(route)) - -const geoColPts = [] -const geoColLns = [] -const area = [] -const geoColEdges = [ - new ol.Feature({ - geometry: new ol.geom.Point(ol.proj.fromLonLat([parseFloat(route[0].longitude), parseFloat(route[0].latitude)])) - }), - new ol.Feature({ - geometry: new ol.geom.Point(ol.proj.fromLonLat([parseFloat(route[route.length - 1].longitude), parseFloat(route[route.length - 1].latitude)])) - }) -] -route.forEach(function (stop, i) { - if (i < route.length - 1) { - geoColLns.push(new ol.Feature({ - geometry: new ol.geom.LineString([ - ol.proj.fromLonLat([parseFloat(route[i].longitude), parseFloat(route[i].latitude)]), - ol.proj.fromLonLat([parseFloat(route[i + 1].longitude), parseFloat(route[i + 1].latitude)]) - ]) - })) - } - geoColPts.push(new ol.Feature({ - geometry: new ol.geom.Point(ol.proj.fromLonLat([parseFloat(stop.longitude), parseFloat(stop.latitude)])) - })) - area.push([parseFloat(stop.longitude), parseFloat(stop.latitude)]) -}) -var edgeStyles = new ol.style.Style({ - image: new ol.style.Circle(({ - radius: 5, - stroke: new ol.style.Stroke({ - color: '#007fbb', - width: 2 - }), - fill: new ol.style.Fill({ - color: '#007fbb', - width: 2 - }) - })) -}) -var defaultStyles = new ol.style.Style({ - image: new ol.style.Circle(({ - radius: 4, - stroke: new ol.style.Stroke({ - color: '#007fbb', - width: 2 - }), - fill: new ol.style.Fill({ - color: '#ffffff', - width: 2 - }) - })) -}) -var lineStyle = new ol.style.Style({ - stroke: new ol.style.Stroke({ - color: '#007fbb', - width: 3 - }) -}) - -var vectorPtsLayer = new ol.layer.Vector({ - source: new ol.source.Vector({ - features: geoColPts - }), - style: defaultStyles, - zIndex: 2 -}) -var vectorEdgesLayer = new ol.layer.Vector({ - source: new ol.source.Vector({ - features: geoColEdges - }), - style: edgeStyles, - zIndex: 3 -}) -var vectorLnsLayer = new ol.layer.Vector({ - source: new ol.source.Vector({ - features: geoColLns - }), - style: [lineStyle], - zIndex: 1 -}) - -var map = new ol.Map({ - target: 'route_map', - layers: [ - new ol.layer.Tile({ - source: new ol.source.OSM() - }), - vectorPtsLayer, - vectorEdgesLayer, - vectorLnsLayer - ], - controls: [new ol.control.ScaleLine(), new ol.control.Zoom(), new ol.control.ZoomSlider()], - interactions: ol.interaction.defaults({ - zoom: true - }), - view: new ol.View({ - center: ol.proj.fromLonLat([parseFloat(route[0].longitude), parseFloat(route[0].latitude)]), - zoom: 13 - }) -}); -const boundaries = ol.extent.applyTransform( - ol.extent.boundingExtent(area), ol.proj.getTransform('EPSG:4326', 'EPSG:3857') -) -map.getView().fit(boundaries, map.getSize()); -let tooCloseToBounds = false -const mapBoundaries = map.getView().calculateExtent(map.getSize()) -const mapWidth = mapBoundaries[2] - mapBoundaries[0] -const mapHeight = mapBoundaries[3] - mapBoundaries[1] -const marginSize = 0.1 -const heightMargin = marginSize * mapHeight -const widthMargin = marginSize * mapWidth -tooCloseToBounds = tooCloseToBounds || (boundaries[0] - mapBoundaries[0]) < widthMargin -tooCloseToBounds = tooCloseToBounds || (mapBoundaries[2] - boundaries[2]) < widthMargin -tooCloseToBounds = tooCloseToBounds || (boundaries[1] - mapBoundaries[1]) < heightMargin -tooCloseToBounds = tooCloseToBounds || (mapBoundaries[3] - boundaries[3]) < heightMargin -if(tooCloseToBounds){ - map.getView().setZoom(map.getView().getZoom() - 1) -} +var map = new RoutesMap('route_map') +map.addRoute(route) +map.fitZoom() diff --git a/app/javascript/routes/components/StopPointList.js b/app/javascript/routes/components/StopPointList.js index 43a027084..b39fa0c9c 100644 --- a/app/javascript/routes/components/StopPointList.js +++ b/app/javascript/routes/components/StopPointList.js @@ -56,7 +56,7 @@ export default function StopPointList({ stopPoints, onDeleteClick, onMoveUpClick ) } -StopPointList.PropTypes = { +StopPointList.propTypes = { stopPoints: PropTypes.array.isRequired, onDeleteClick: PropTypes.func.isRequired, onMoveUpClick: PropTypes.func.isRequired, @@ -68,4 +68,4 @@ StopPointList.PropTypes = { StopPointList.contextTypes = { I18n: PropTypes.object -} \ No newline at end of file +} -- cgit v1.2.3 From 22c38fb750843f0c74996175a6bd17a1f20a943c Mon Sep 17 00:00:00 2001 From: Zog Date: Fri, 26 Jan 2018 16:17:22 +0100 Subject: Refs #5750 @1h; Add a "kind" attribute to StopAreas This determines if the StopArea is commercial or not The useless fields are hidden in the form for the non-commercials ones --- app/javascript/helpers/master_slave.coffee | 18 ++++++++++++++++++ app/javascript/packs/stop_areas/new.js | 3 +++ 2 files changed, 21 insertions(+) create mode 100644 app/javascript/helpers/master_slave.coffee create mode 100644 app/javascript/packs/stop_areas/new.js (limited to 'app/javascript') diff --git a/app/javascript/helpers/master_slave.coffee b/app/javascript/helpers/master_slave.coffee new file mode 100644 index 000000000..11f6bca7e --- /dev/null +++ b/app/javascript/helpers/master_slave.coffee @@ -0,0 +1,18 @@ +class MasterSlave + constructor: (selector)-> + $(selector).find('[data-master]').each (i, slave)-> + $slave = $(slave) + master = $($slave.data().master) + console.log $slave.data().master + console.log master + toggle = -> + val = master.filter(":checked").val() if master.filter("[type=radio]").length > 0 + val ||= master.val() + selected = val == $slave.data().value + $slave.toggle selected + $slave.find("input, select").attr "disabled", !selected + master.change toggle + toggle() + # $slave.toggle master.val() == $slave.data().value + +export default MasterSlave diff --git a/app/javascript/packs/stop_areas/new.js b/app/javascript/packs/stop_areas/new.js new file mode 100644 index 000000000..ffe702cdb --- /dev/null +++ b/app/javascript/packs/stop_areas/new.js @@ -0,0 +1,3 @@ +import MasterSlave from "../../helpers/master_slave" + +new MasterSlave("form") -- cgit v1.2.3 From 05bc96db48a0a84fd2c50e457dc767f88950a9b4 Mon Sep 17 00:00:00 2001 From: Zog Date: Mon, 29 Jan 2018 08:45:02 +0100 Subject: Refs #5750 @1h; Manage non-commercial StopAreas - Add a `kind` attribute - Hide irrelevant fields in the form --- app/javascript/helpers/master_slave.coffee | 8 ++++---- app/javascript/helpers/stop_area_header_manager.js | 4 +++- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/helpers/master_slave.coffee b/app/javascript/helpers/master_slave.coffee index 11f6bca7e..4866a55e3 100644 --- a/app/javascript/helpers/master_slave.coffee +++ b/app/javascript/helpers/master_slave.coffee @@ -3,16 +3,16 @@ class MasterSlave $(selector).find('[data-master]').each (i, slave)-> $slave = $(slave) master = $($slave.data().master) - console.log $slave.data().master - console.log master + console.log $slave + console.log $slave.find("input:disabled, select:disabled") + $slave.find("input:disabled, select:disabled").attr "data-slave-force-disabled", "true" toggle = -> val = master.filter(":checked").val() if master.filter("[type=radio]").length > 0 val ||= master.val() selected = val == $slave.data().value $slave.toggle selected - $slave.find("input, select").attr "disabled", !selected + $slave.find("input, select").filter(":not([data-slave-force-disabled])").attr "disabled", !selected master.change toggle toggle() - # $slave.toggle master.val() == $slave.data().value export default MasterSlave diff --git a/app/javascript/helpers/stop_area_header_manager.js b/app/javascript/helpers/stop_area_header_manager.js index c9f397dee..2c820caf9 100644 --- a/app/javascript/helpers/stop_area_header_manager.js +++ b/app/javascript/helpers/stop_area_header_manager.js @@ -19,7 +19,7 @@ export default class StopAreaHeaderManager {
      @@ -27,6 +27,8 @@ export default class StopAreaHeaderManager { {sp.time_zone_formatted_offset &&  ({sp.time_zone_formatted_offset}) } + {sp.area_kind == 'non_commercial' && + }
      -- cgit v1.2.3 From ddd83906ce4fab3d6dce0c404ec39c3b500ba96f Mon Sep 17 00:00:00 2001 From: Zog Date: Mon, 29 Jan 2018 10:32:05 +0100 Subject: Refs #5750; Add a validation on VehicleJourneys Ensure a time is set for all non-commercial stops --- app/javascript/vehicle_journeys/actions/index.js | 26 ++++++++++++++++++++++ .../components/SaveVehicleJourneys.js | 2 +- .../vehicle_journeys/components/VehicleJourney.js | 3 +++ .../vehicle_journeys/components/VehicleJourneys.js | 2 +- .../containers/SaveVehicleJourneys.js | 3 +++ .../vehicle_journeys/reducers/vehicleJourneys.js | 2 ++ 6 files changed, 36 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 2675328e3..b01158212 100644 --- a/app/javascript/vehicle_journeys/actions/index.js +++ b/app/javascript/vehicle_journeys/actions/index.js @@ -380,6 +380,32 @@ const actions = { } }) }, + + validate : (dispatch, vehicleJourneys, next) => { + let valid = true + let vj, vjas + for (vj of vehicleJourneys){ + vj.errors = false + for(vjas of vj.vehicle_journey_at_stops){ + vjas.errors = null + if (vjas.area_kind == "non_commercial" && parseInt(vjas.departure_time.hour) == 0 && parseInt(vjas.departure_time.minute) == 0){ + vjas.errors = "Champ requis" + vj.errors = true + valid = false + } + } + } + dispatch(actions.didValidateVehicleJourneys(vehicleJourneys)) + if(valid){ + actions.submitVehicleJourneys(dispatch, vehicleJourneys, next) + } + }, + + didValidateVehicleJourneys : (vehicleJourneys) => ({ + type: 'DID_VALIDATE_VEHICLE_JOURNEYS', + vehicleJourneys + }), + submitVehicleJourneys : (dispatch, state, next) => { dispatch(actions.fetchingApi()) let urlJSON = window.location.pathname + "_collection.json" diff --git a/app/javascript/vehicle_journeys/components/SaveVehicleJourneys.js b/app/javascript/vehicle_journeys/components/SaveVehicleJourneys.js index 6e94b04a3..fb921df9c 100644 --- a/app/javascript/vehicle_journeys/components/SaveVehicleJourneys.js +++ b/app/javascript/vehicle_journeys/components/SaveVehicleJourneys.js @@ -13,7 +13,7 @@ export default class SaveVehicleJourneys extends SaveButton{ } submitForm(){ - this.props.onSubmitVehicleJourneys(this.props.dispatch, this.props.vehicleJourneys) + this.props.validate(this.props.vehicleJourneys, this.props.dispatch) } } diff --git a/app/javascript/vehicle_journeys/components/VehicleJourney.js b/app/javascript/vehicle_journeys/components/VehicleJourney.js index d240757a3..2b5783dda 100644 --- a/app/javascript/vehicle_journeys/components/VehicleJourney.js +++ b/app/javascript/vehicle_journeys/components/VehicleJourney.js @@ -153,6 +153,9 @@ export default class VehicleJourney extends Component { />
      + {vj.errors &&
      + {vj.errors} +
      }
      )} diff --git a/app/javascript/vehicle_journeys/components/VehicleJourneys.js b/app/javascript/vehicle_journeys/components/VehicleJourneys.js index b188962c2..256ca81f9 100644 --- a/app/javascript/vehicle_journeys/components/VehicleJourneys.js +++ b/app/javascript/vehicle_journeys/components/VehicleJourneys.js @@ -89,7 +89,7 @@ export default class VehicleJourneys extends Component {
      )} - { _.some(this.props.vehicleJourneys, 'errors') && ( + { this.props.vehicleJourneys.errors && this.props.vehicleJourneys.errors.length && _.some(this.props.vehicleJourneys, 'errors') && (
      Erreur : {this.props.vehicleJourneys.map((vj, index) => diff --git a/app/javascript/vehicle_journeys/containers/SaveVehicleJourneys.js b/app/javascript/vehicle_journeys/containers/SaveVehicleJourneys.js index f5f879ed8..3daf831f8 100644 --- a/app/javascript/vehicle_journeys/containers/SaveVehicleJourneys.js +++ b/app/javascript/vehicle_journeys/containers/SaveVehicleJourneys.js @@ -23,6 +23,9 @@ const mapDispatchToProps = (dispatch) => { }, onSubmitVehicleJourneys: (next, state) => { actions.submitVehicleJourneys(dispatch, state, next) + }, + validate: (state) =>{ + actions.validate(dispatch, state) } } } diff --git a/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js b/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js index ae45993a8..1a15ec46d 100644 --- a/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js +++ b/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js @@ -273,6 +273,8 @@ export default function vehicleJourneys(state = [], action) { return vj } }) + case 'DID_VALIDATE_VEHICLE_JOURNEYS': + return [...action.vehicleJourneys] default: return state } -- cgit v1.2.3 From bb62bc2028f142e953035680b2483ee6029711ae Mon Sep 17 00:00:00 2001 From: Zog Date: Wed, 31 Jan 2018 11:14:23 +0100 Subject: Disable immature feature --- app/javascript/packs/referential_lines/show.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/javascript') diff --git a/app/javascript/packs/referential_lines/show.js b/app/javascript/packs/referential_lines/show.js index 99c5072ef..542188018 100644 --- a/app/javascript/packs/referential_lines/show.js +++ b/app/javascript/packs/referential_lines/show.js @@ -6,5 +6,5 @@ routes = JSON.parse(decodeURIComponent(routes)) var map = new RoutesMap('routes_map') map.addRoutes(routes) -map.addRoutesLabels() +// map.addRoutesLabels() map.fitZoom() -- cgit v1.2.3 From c463c3a950246c4c2660ce7df1c1ea8f2acbe578 Mon Sep 17 00:00:00 2001 From: Zog Date: Wed, 31 Jan 2018 11:17:02 +0100 Subject: Refs #5750; Remove useless validation --- app/javascript/vehicle_journeys/actions/index.js | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/vehicle_journeys/actions/index.js b/app/javascript/vehicle_journeys/actions/index.js index b01158212..4a4ec371d 100644 --- a/app/javascript/vehicle_journeys/actions/index.js +++ b/app/javascript/vehicle_journeys/actions/index.js @@ -382,23 +382,8 @@ const actions = { }, validate : (dispatch, vehicleJourneys, next) => { - let valid = true - let vj, vjas - for (vj of vehicleJourneys){ - vj.errors = false - for(vjas of vj.vehicle_journey_at_stops){ - vjas.errors = null - if (vjas.area_kind == "non_commercial" && parseInt(vjas.departure_time.hour) == 0 && parseInt(vjas.departure_time.minute) == 0){ - vjas.errors = "Champ requis" - vj.errors = true - valid = false - } - } - } dispatch(actions.didValidateVehicleJourneys(vehicleJourneys)) - if(valid){ - actions.submitVehicleJourneys(dispatch, vehicleJourneys, next) - } + actions.submitVehicleJourneys(dispatch, vehicleJourneys, next) }, didValidateVehicleJourneys : (vehicleJourneys) => ({ -- cgit v1.2.3 From 9c322a5ea47f0badb0ba7e91de6df42d25e591c5 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Wed, 31 Jan 2018 13:23:24 +0100 Subject: VehicleJourneys#index: Allow company deletion in 'add' modal While the 'x' button in the Select2 was available in the 'edit' modal for a vehicle journey, it was not in the 'add' modal. Thus, once you added an associated company, you couldn't remove it in the modal. You'd either have to cancel and create your vehicle journey again, or create it an delete the company in the 'edit' modal later. This enables the 'x' button in the 'add' modal (it previously was only enabled when `editMode` was active) and sets the proper action/reducer to remove the company. The `allowClear` attribute was changed to only work in the 'edit' modal in 0079238842263768b88b0fa0fd977824b49eabd5. That commit appears to be changing things so that certain functions work when not in 'edit' mode. The case we're concerned about is that the 'edit' modal can be opened when in 'view' mode (not 'edit' mode) in order to get more detailed information about a vehicle journey. This means the company Select2 is available in 'view' mode, and the 'x' button should not be visible in that case. But, when I tested this, even with `allowClear: true`, the 'x' button wasn't visible. This, I can only assume, is because the Select2 is in a 'disabled' state, so it's smart enough to know not to show the 'x' button. Which works great for us, because this allows us to not show the 'x' button here and still show it in the 'add' and 'edit' modals. Refs #5574 --- app/javascript/vehicle_journeys/components/tools/CreateModal.js | 1 + .../vehicle_journeys/components/tools/select2s/CompanySelect2.js | 2 +- app/javascript/vehicle_journeys/containers/tools/AddVehicleJourney.js | 3 +++ 3 files changed, 5 insertions(+), 1 deletion(-) (limited to 'app/javascript') diff --git a/app/javascript/vehicle_journeys/components/tools/CreateModal.js b/app/javascript/vehicle_journeys/components/tools/CreateModal.js index 90328458b..8536f66e6 100644 --- a/app/javascript/vehicle_journeys/components/tools/CreateModal.js +++ b/app/javascript/vehicle_journeys/components/tools/CreateModal.js @@ -66,6 +66,7 @@ export default class CreateModal extends Component { this.props.onSelect2Company(e)} + onUnselect2Company = {() => this.props.onUnselect2Company()} />
      diff --git a/app/javascript/vehicle_journeys/components/tools/select2s/CompanySelect2.js b/app/javascript/vehicle_journeys/components/tools/select2s/CompanySelect2.js index 28a092945..5c7f75d99 100644 --- a/app/javascript/vehicle_journeys/components/tools/select2s/CompanySelect2.js +++ b/app/javascript/vehicle_journeys/components/tools/select2s/CompanySelect2.js @@ -26,7 +26,7 @@ export default class BSelect4 extends Component { multiple={false} ref='company_id' options={{ - allowClear: this.props.editMode, + allowClear: true, theme: 'bootstrap', width: '100%', placeholder: 'Filtrer par transporteur...', diff --git a/app/javascript/vehicle_journeys/containers/tools/AddVehicleJourney.js b/app/javascript/vehicle_journeys/containers/tools/AddVehicleJourney.js index 0db7628be..d982f5a5f 100644 --- a/app/javascript/vehicle_journeys/containers/tools/AddVehicleJourney.js +++ b/app/javascript/vehicle_journeys/containers/tools/AddVehicleJourney.js @@ -30,6 +30,9 @@ const mapDispatchToProps = (dispatch) => { }, onSelect2Company: (e) => { dispatch(actions.select2Company(e.params.data)) + }, + onUnselect2Company: () => { + dispatch(actions.unselect2Company()) } } } -- cgit v1.2.3 From 90f54f0acfe65ff276a229239809ce0e9fddf0b0 Mon Sep 17 00:00:00 2001 From: Zog Date: Wed, 31 Jan 2018 15:10:40 +0100 Subject: Fix specs --- app/javascript/vehicle_journeys/actions/index.js | 1 + 1 file changed, 1 insertion(+) (limited to 'app/javascript') diff --git a/app/javascript/vehicle_journeys/actions/index.js b/app/javascript/vehicle_journeys/actions/index.js index 4a4ec371d..8970c6025 100644 --- a/app/javascript/vehicle_journeys/actions/index.js +++ b/app/javascript/vehicle_journeys/actions/index.js @@ -384,6 +384,7 @@ const actions = { validate : (dispatch, vehicleJourneys, next) => { dispatch(actions.didValidateVehicleJourneys(vehicleJourneys)) actions.submitVehicleJourneys(dispatch, vehicleJourneys, next) + return true }, didValidateVehicleJourneys : (vehicleJourneys) => ({ -- cgit v1.2.3 From 663effc415399c61d22dadbc235bb7488022d191 Mon Sep 17 00:00:00 2001 From: Zog Date: Wed, 24 Jan 2018 16:56:16 +0100 Subject: Refs #5682 @3h; Use same UI as for timetables --- app/javascript/packs/calendars/edit.js | 74 ++++++++++++++++++++++++++ app/javascript/time_tables/actions/index.js | 5 +- app/javascript/time_tables/components/Metas.js | 12 ++--- 3 files changed, 83 insertions(+), 8 deletions(-) create mode 100644 app/javascript/packs/calendars/edit.js (limited to 'app/javascript') diff --git a/app/javascript/packs/calendars/edit.js b/app/javascript/packs/calendars/edit.js new file mode 100644 index 000000000..bd09657ec --- /dev/null +++ b/app/javascript/packs/calendars/edit.js @@ -0,0 +1,74 @@ +import React from 'react' +import { render } from 'react-dom' +import { Provider } from 'react-redux' +import { createStore } from 'redux' +import timeTablesApp from '../../time_tables/reducers' +import App from '../../time_tables/containers/App' +import clone from '../../helpers/clone' + +const actionType = clone(window, "actionType", true) + +// logger, DO NOT REMOVE +// var applyMiddleware = require('redux').applyMiddleware +// var createLogger = require('redux-logger') +// var thunkMiddleware = require('redux-thunk').default +// var promise = require('redux-promise') + +let initialState = { + status: { + actionType: actionType, + policy: window.perms, + fetchSuccess: true, + isFetching: false + }, + timetable: { + current_month: [], + current_periode_range: '', + periode_range: [], + time_table_periods: [], + time_table_dates: [] + }, + metas: { + comment: '', + day_types: [], + initial_tags: [] + }, + pagination: { + stateChanged: false, + currentPage: '', + periode_range: [] + }, + modal: { + type: '', + modalProps: { + active: false, + begin: { + day: '01', + month: '01', + year: String(new Date().getFullYear()) + }, + end: { + day: '01', + month: '01', + year: String(new Date().getFullYear()) + }, + index: false, + error: '' + }, + confirmModal: {} + } +} +// const loggerMiddleware = createLogger() + +let store = createStore( + timeTablesApp, + initialState, + // applyMiddleware(thunkMiddleware, promise, loggerMiddleware) +) + +render( + + + , + document.getElementById('periods') +) diff --git a/app/javascript/time_tables/actions/index.js b/app/javascript/time_tables/actions/index.js index 87c7a3e8d..70f548174 100644 --- a/app/javascript/time_tables/actions/index.js +++ b/app/javascript/time_tables/actions/index.js @@ -246,7 +246,8 @@ const actions = { return error }, fetchTimeTables: (dispatch, nextPage) => { - let urlJSON = window.location.pathname.split('/', 5).join('/') + let urlJSON = window.timetablesUrl || window.location.pathname.split('/', 5).join('/') + if(nextPage) { urlJSON += "/month.json?date=" + nextPage }else{ @@ -277,7 +278,7 @@ const actions = { let strDayTypes = actions.arrayToStrDayTypes(metas.day_types) metas.day_types = strDayTypes let sentState = assign({}, timetable, metas) - let urlJSON = window.location.pathname.split('/', 5).join('/') + let urlJSON = window.timetablesUrl || window.location.pathname.split('/', 5).join('/') let hasError = false fetch(urlJSON + '.json', { credentials: 'same-origin', diff --git a/app/javascript/time_tables/components/Metas.js b/app/javascript/time_tables/components/Metas.js index 4170ba493..3c6848d27 100644 --- a/app/javascript/time_tables/components/Metas.js +++ b/app/javascript/time_tables/components/Metas.js @@ -27,7 +27,7 @@ export default function Metas({metas, onUpdateDayTypes, onUpdateComment, onUpdat
      {/* color */} -
      + {metas.color !== undefined &&
      @@ -69,10 +69,10 @@ export default function Metas({metas, onUpdateDayTypes, onUpdateComment, onUpdat
      -
      +
      } {/* tags */} -
      + {metas.tags !== undefined &&
      onUnselect2Tags(e)} />
      -
      +
      } {/* calendar */} -
      + {metas.calendar !== null &&
      {metas.calendar ? metas.calendar.name : I18n.time_tables.edit.metas.no_calendar}
      -
      +
      } {/* day_types */}
      -- cgit v1.2.3 From ee7fe7a4760c3fdde987ef666db45c161e788ee9 Mon Sep 17 00:00:00 2001 From: Zog Date: Wed, 31 Jan 2018 15:47:06 +0100 Subject: Refs #5796: Add some legroom in the JourneyPatterns editor --- app/javascript/journey_patterns/components/JourneyPattern.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/javascript') diff --git a/app/javascript/journey_patterns/components/JourneyPattern.js b/app/javascript/journey_patterns/components/JourneyPattern.js index 01734f3a3..35765b99a 100644 --- a/app/javascript/journey_patterns/components/JourneyPattern.js +++ b/app/javascript/journey_patterns/components/JourneyPattern.js @@ -109,7 +109,7 @@ export default class JourneyPattern extends Component{ } else{ let hours = parseInt(time/60) - return hours + " h " + (time - 60*hours) + " min" + return hours + " h " + (time - 60*hours) } } -- cgit v1.2.3 From d114d549f7bc8a772803175dee9a665266d8ed04 Mon Sep 17 00:00:00 2001 From: Zog Date: Thu, 1 Feb 2018 10:34:40 +0100 Subject: Refs #5798 @3h; Show return journeys on the journeys' editor. --- app/javascript/helpers/stop_area_header_manager.js | 5 +++ app/javascript/packs/vehicle_journeys/index.js | 3 +- app/javascript/vehicle_journeys/actions/index.js | 17 ++++++--- app/javascript/vehicle_journeys/components/App.js | 1 + .../vehicle_journeys/components/VehicleJourney.js | 6 ++-- .../vehicle_journeys/components/VehicleJourneys.js | 41 +++++++++++++++++----- .../components/tools/EditVehicleJourney.js | 8 +++-- .../containers/VehicleJourneysList.js | 8 +++-- .../containers/tools/EditVehicleJourney.js | 1 + app/javascript/vehicle_journeys/reducers/index.js | 3 ++ .../reducers/returnVehicleJourneys.js | 11 ++++++ 11 files changed, 82 insertions(+), 22 deletions(-) create mode 100644 app/javascript/vehicle_journeys/reducers/returnVehicleJourneys.js (limited to 'app/javascript') diff --git a/app/javascript/helpers/stop_area_header_manager.js b/app/javascript/helpers/stop_area_header_manager.js index 2c820caf9..5b18e2f63 100644 --- a/app/javascript/helpers/stop_area_header_manager.js +++ b/app/javascript/helpers/stop_area_header_manager.js @@ -42,6 +42,11 @@ export default class StopAreaHeaderManager { let index = this.ids_list.indexOf(object_id) let sp = this.stopPointsList[index] let previousBreakpoint = this.stopPointsList[index - 1] + if(sp == undefined){ + console.log("STOP_POINT NOT FOUND: " + object_id) + console.log("AVAILABLE IDS:" + this.ids_list) + return + } if(index == 0 || (sp[attribute_to_check] != previousBreakpoint[attribute_to_check])){ showHeadline = true headline = this.hasFeature('long_distance_routes') ? sp.country_name : sp.city_name diff --git a/app/javascript/packs/vehicle_journeys/index.js b/app/javascript/packs/vehicle_journeys/index.js index aa5738d59..e6867cb17 100644 --- a/app/javascript/packs/vehicle_journeys/index.js +++ b/app/javascript/packs/vehicle_journeys/index.js @@ -60,6 +60,7 @@ var initialState = { }, vehicleJourneys: [], stopPointsList: window.stopPoints, + returnStopPointsList: window.returnStopPoints, pagination: { page : 1, totalCount: 0, @@ -99,7 +100,7 @@ let store = createStore( render( - + , document.getElementById('vehicle_journeys_wip') ) diff --git a/app/javascript/vehicle_journeys/actions/index.js b/app/javascript/vehicle_journeys/actions/index.js index 8970c6025..74a333b53 100644 --- a/app/javascript/vehicle_journeys/actions/index.js +++ b/app/javascript/vehicle_journeys/actions/index.js @@ -13,8 +13,8 @@ const actions = { exitEditMode: () => ({ type: "EXIT_EDIT_MODE" }), - receiveVehicleJourneys : (json) => ({ - type: "RECEIVE_VEHICLE_JOURNEYS", + receiveVehicleJourneys : (json, returnJourneys) => ({ + type: (returnJourneys ? "RECEIVE_RETURN_VEHICLE_JOURNEYS" : "RECEIVE_VEHICLE_JOURNEYS"), json }), receiveErrors : (json) => ({ @@ -290,10 +290,17 @@ const actions = { type: 'RECEIVE_TOTAL_COUNT', total }), - fetchVehicleJourneys : (dispatch, currentPage, nextPage, queryString) => { + fetchVehicleJourneys : (dispatch, currentPage, nextPage, queryString, url) => { + let returnJourneys = false if(currentPage == undefined){ currentPage = 1 } + if(url == undefined){ + url = window.location.pathname + } + else{ + returnJourneys = true + } let vehicleJourneys = [] let page switch (nextPage) { @@ -315,7 +322,7 @@ const actions = { str = '.json?page=' + page.toString() sep = '&' } - let urlJSON = window.location.pathname + str + let urlJSON = url + str if (queryString){ urlJSON = urlJSON + sep + queryString } @@ -375,7 +382,7 @@ const actions = { ) } window.currentItemsLength = vehicleJourneys.length - dispatch(actions.receiveVehicleJourneys(vehicleJourneys)) + dispatch(actions.receiveVehicleJourneys(vehicleJourneys, returnJourneys)) dispatch(actions.receiveTotalCount(json.total)) } }) diff --git a/app/javascript/vehicle_journeys/components/App.js b/app/javascript/vehicle_journeys/components/App.js index 44559c7c6..5ac284438 100644 --- a/app/javascript/vehicle_journeys/components/App.js +++ b/app/javascript/vehicle_journeys/components/App.js @@ -22,6 +22,7 @@ export default function App() { + {window.returnRouteUrl && }
      diff --git a/app/javascript/vehicle_journeys/components/VehicleJourney.js b/app/javascript/vehicle_journeys/components/VehicleJourney.js index 2b5783dda..e7d4b5b30 100644 --- a/app/javascript/vehicle_journeys/components/VehicleJourney.js +++ b/app/javascript/vehicle_journeys/components/VehicleJourney.js @@ -1,6 +1,7 @@ import React, { Component } from 'react' import PropTypes from 'prop-types' import actions from '../actions' +import EditVehicleJourney from '../containers/tools/EditVehicleJourney' export default class VehicleJourney extends Component { constructor(props) { @@ -80,7 +81,7 @@ export default class VehicleJourney extends Component { {purchase_windows.length > 3 && + {purchase_windows.length - 3}}
      } -
      + {!this.props.disabled &&
      -
      +
      } + {this.props.disabled && }
      {this.props.value.vehicle_journey_at_stops.map((vj, i) =>
      diff --git a/app/javascript/vehicle_journeys/components/VehicleJourneys.js b/app/javascript/vehicle_journeys/components/VehicleJourneys.js index 256ca81f9..ae852b35a 100644 --- a/app/javascript/vehicle_journeys/components/VehicleJourneys.js +++ b/app/javascript/vehicle_journeys/components/VehicleJourneys.js @@ -8,14 +8,36 @@ export default class VehicleJourneys extends Component { constructor(props){ super(props) this.headerManager = new StopAreaHeaderManager( - _.map(this.props.stopPointsList, (sp)=>{return sp.object_id}), - this.props.stopPointsList, + _.map(this.stopPoints(), (sp)=>{return sp.object_id}), + this.stopPoints(), this.props.filters.features ) } + isReturn() { + return this.props.routeUrl != undefined + } + + vehicleJourneysList() { + if(this.isReturn()){ + return this.props.returnVehicleJourneys + } + else{ + return this.props.vehicleJourneys + } + } + + stopPoints() { + if(this.isReturn()){ + return this.props.returnStopPointsList + } + else{ + return this.props.stopPointsList + } + } + componentDidMount() { - this.props.onLoadFirstPage(this.props.filters) + this.props.onLoadFirstPage(this.props.filters, this.props.routeUrl) } hasFeature(key) { @@ -89,10 +111,10 @@ export default class VehicleJourneys extends Component {
      )} - { this.props.vehicleJourneys.errors && this.props.vehicleJourneys.errors.length && _.some(this.props.vehicleJourneys, 'errors') && ( + { this.vehicleJourneysList().errors && this.vehicleJourneysList().errors.length && _.some(this.vehicleJourneysList(), 'errors') && (
      Erreur : - {this.props.vehicleJourneys.map((vj, index) => + {this.vehicleJourneysList().map((vj, index) => vj.errors && vj.errors.map((err, i) => { return (
        @@ -104,7 +126,7 @@ export default class VehicleJourneys extends Component {
      )} -
      0) ? '' : ' no_result')}> +
      0) ? '' : ' no_result')}>
      ID course
      @@ -114,7 +136,7 @@ export default class VehicleJourneys extends Component {
      Calendriers
      { this.hasFeature('purchase_windows') &&
      Calendriers Commerciaux
      }
      - {this.props.stopPointsList.map((sp, i) =>{ + {this.stopPoints().map((sp, i) =>{ return (
      {this.headerManager.stopPointHeader(sp.object_id)} @@ -125,17 +147,18 @@ export default class VehicleJourneys extends Component {
      - {this.props.vehicleJourneys.map((vj, index) => + {this.vehicleJourneysList().map((vj, index) => )}
      diff --git a/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js b/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js index 2893422f8..f814c0459 100644 --- a/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js +++ b/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js @@ -23,6 +23,10 @@ export default class EditVehicleJourney extends Component { } } + getSelected() { + return this.props.vehicleJourney ? [this.props.vehicleJourney] : actions.getSelected(this.props.vehicleJourneys) + } + render() { if(this.props.status.isFetching == true) { return false @@ -35,10 +39,10 @@ export default class EditVehicleJourney extends Component {
    • diff --git a/app/javascript/vehicle_journeys/containers/VehicleJourneysList.js b/app/javascript/vehicle_journeys/containers/VehicleJourneysList.js index 38ab9f6d3..76d1c3a78 100644 --- a/app/javascript/vehicle_journeys/containers/VehicleJourneysList.js +++ b/app/javascript/vehicle_journeys/containers/VehicleJourneysList.js @@ -6,17 +6,19 @@ const mapStateToProps = (state) => { return { editMode: state.editMode, vehicleJourneys: state.vehicleJourneys, + returnVehicleJourneys: state.returnVehicleJourneys, status: state.status, filters: state.filters, - stopPointsList: state.stopPointsList + stopPointsList: state.stopPointsList, + returnStopPointsList: state.returnStopPointsList } } const mapDispatchToProps = (dispatch) => { return { - onLoadFirstPage: (filters) =>{ + onLoadFirstPage: (filters, routeUrl) =>{ dispatch(actions.fetchingApi()) - actions.fetchVehicleJourneys(dispatch, undefined, undefined, filters.queryString) + actions.fetchVehicleJourneys(dispatch, undefined, undefined, filters.queryString, routeUrl) }, onUpdateTime: (e, subIndex, index, timeUnit, isDeparture, isArrivalsToggled) => { dispatch(actions.updateTime(e.target.value, subIndex, index, timeUnit, isDeparture, isArrivalsToggled)) diff --git a/app/javascript/vehicle_journeys/containers/tools/EditVehicleJourney.js b/app/javascript/vehicle_journeys/containers/tools/EditVehicleJourney.js index c2eabcc10..a851b6e7d 100644 --- a/app/javascript/vehicle_journeys/containers/tools/EditVehicleJourney.js +++ b/app/javascript/vehicle_journeys/containers/tools/EditVehicleJourney.js @@ -18,6 +18,7 @@ const mapDispatchToProps = (dispatch) => { dispatch(actions.closeModal()) }, onOpenEditModal: (vj) =>{ + console.log({vj}) dispatch(actions.openEditModal(vj)) }, onEditVehicleJourney: (data, selectedCompany) =>{ diff --git a/app/javascript/vehicle_journeys/reducers/index.js b/app/javascript/vehicle_journeys/reducers/index.js index 1963f7c6d..95ac9c7e1 100644 --- a/app/javascript/vehicle_journeys/reducers/index.js +++ b/app/javascript/vehicle_journeys/reducers/index.js @@ -1,5 +1,6 @@ import { combineReducers } from 'redux' import vehicleJourneys from './vehicleJourneys' +import returnVehicleJourneys from './returnVehicleJourneys' import pagination from './pagination' import modal from './modal' import status from './status' @@ -11,12 +12,14 @@ import custom_fields from './custom_fields' const vehicleJourneysApp = combineReducers({ vehicleJourneys, + returnVehicleJourneys, pagination, modal, status, filters, editMode, stopPointsList, + returnStopPointsList: stopPointsList, missions, custom_fields }) diff --git a/app/javascript/vehicle_journeys/reducers/returnVehicleJourneys.js b/app/javascript/vehicle_journeys/reducers/returnVehicleJourneys.js new file mode 100644 index 000000000..db3c71d17 --- /dev/null +++ b/app/javascript/vehicle_journeys/reducers/returnVehicleJourneys.js @@ -0,0 +1,11 @@ +import _ from 'lodash' +import actions from '../actions' + +export default function returnVehicleJourneys(state = [], action) { + switch (action.type) { + case 'RECEIVE_RETURN_VEHICLE_JOURNEYS': + return [...action.json] + default: + return state + } +} -- cgit v1.2.3 From b91895f897f6a9b401844e373d020c3f458fc130 Mon Sep 17 00:00:00 2001 From: Zog Date: Thu, 1 Feb 2018 10:37:44 +0100 Subject: :fire: log --- app/javascript/vehicle_journeys/containers/tools/EditVehicleJourney.js | 1 - 1 file changed, 1 deletion(-) (limited to 'app/javascript') diff --git a/app/javascript/vehicle_journeys/containers/tools/EditVehicleJourney.js b/app/javascript/vehicle_journeys/containers/tools/EditVehicleJourney.js index a851b6e7d..c2eabcc10 100644 --- a/app/javascript/vehicle_journeys/containers/tools/EditVehicleJourney.js +++ b/app/javascript/vehicle_journeys/containers/tools/EditVehicleJourney.js @@ -18,7 +18,6 @@ const mapDispatchToProps = (dispatch) => { dispatch(actions.closeModal()) }, onOpenEditModal: (vj) =>{ - console.log({vj}) dispatch(actions.openEditModal(vj)) }, onEditVehicleJourney: (data, selectedCompany) =>{ -- cgit v1.2.3 From ae336476f64254727caf2e447f444fd17f0513f1 Mon Sep 17 00:00:00 2001 From: Zog Date: Mon, 29 Jan 2018 16:56:06 +0100 Subject: Refs #5762; Update JS to accomodate stops without location --- app/javascript/helpers/routes_map.coffee | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/helpers/routes_map.coffee b/app/javascript/helpers/routes_map.coffee index 85def1390..6834406fc 100644 --- a/app/javascript/helpers/routes_map.coffee +++ b/app/javascript/helpers/routes_map.coffee @@ -30,20 +30,24 @@ class RoutesMap geometry: new ol.geom.Point(ol.proj.fromLonLat([parseFloat(stops[stops.length - 1].longitude), parseFloat(stops[stops.length - 1].latitude)])) }) ] + + prevStop = null stops.forEach (stop, i) => - if i < stops.length - 1 - geoColLns.push new ol.Feature - geometry: new ol.geom.LineString([ - ol.proj.fromLonLat([parseFloat(stops[i].longitude), parseFloat(stops[i].latitude)]), - ol.proj.fromLonLat([parseFloat(stops[i + 1].longitude), parseFloat(stops[i + 1].latitude)]) - ]) + if stop.longitude && stop.latitude + if prevStop + geoColLns.push new ol.Feature + geometry: new ol.geom.LineString([ + ol.proj.fromLonLat([parseFloat(prevStop.longitude), parseFloat(prevStop.latitude)]), + ol.proj.fromLonLat([parseFloat(stop.longitude), parseFloat(stop.latitude)]) + ]) + prevStop = stop - geoColPts.push(new ol.Feature({ - geometry: new ol.geom.Point(ol.proj.fromLonLat([parseFloat(stop.longitude), parseFloat(stop.latitude)])) - })) - unless @seenStopIds.indexOf(stop.stoparea_id) > 0 - @area.push [parseFloat(stop.longitude), parseFloat(stop.latitude)] - @seenStopIds.push stop.stoparea_id + geoColPts.push(new ol.Feature({ + geometry: new ol.geom.Point(ol.proj.fromLonLat([parseFloat(stop.longitude), parseFloat(stop.latitude)])) + })) + unless @seenStopIds.indexOf(stop.stoparea_id) > 0 + @area.push [parseFloat(stop.longitude), parseFloat(stop.latitude)] + @seenStopIds.push stop.stoparea_id vectorPtsLayer = new ol.layer.Vector({ source: new ol.source.Vector({ -- cgit v1.2.3 From 51633814820e624e7d77e6cb53da8f0eb3243ff2 Mon Sep 17 00:00:00 2001 From: Zog Date: Thu, 1 Feb 2018 15:55:00 +0100 Subject: :fire: log --- app/javascript/helpers/master_slave.coffee | 2 -- 1 file changed, 2 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/helpers/master_slave.coffee b/app/javascript/helpers/master_slave.coffee index 4866a55e3..81bebe36a 100644 --- a/app/javascript/helpers/master_slave.coffee +++ b/app/javascript/helpers/master_slave.coffee @@ -3,8 +3,6 @@ class MasterSlave $(selector).find('[data-master]').each (i, slave)-> $slave = $(slave) master = $($slave.data().master) - console.log $slave - console.log $slave.find("input:disabled, select:disabled") $slave.find("input:disabled, select:disabled").attr "data-slave-force-disabled", "true" toggle = -> val = master.filter(":checked").val() if master.filter("[type=radio]").length > 0 -- cgit v1.2.3 From 16a774d2f7cf499c564358e633fb23120e86fddc Mon Sep 17 00:00:00 2001 From: Zog Date: Fri, 2 Feb 2018 09:39:08 +0100 Subject: Refs #5825 @1h; Fix info window behaviour on VJs editor --- app/javascript/vehicle_journeys/actions/index.js | 4 +++ .../vehicle_journeys/components/VehicleJourney.js | 5 ++-- .../components/tools/EditVehicleJourney.js | 33 +++++++++++++--------- .../components/tools/VehicleJourneyInfoButton.js | 30 ++++++++++++++++++++ .../containers/tools/VehicleJourneyInfoButton.js | 20 +++++++++++++ app/javascript/vehicle_journeys/reducers/modal.js | 9 ++++++ 6 files changed, 86 insertions(+), 15 deletions(-) create mode 100644 app/javascript/vehicle_journeys/components/tools/VehicleJourneyInfoButton.js create mode 100644 app/javascript/vehicle_journeys/containers/tools/VehicleJourneyInfoButton.js (limited to 'app/javascript') diff --git a/app/javascript/vehicle_journeys/actions/index.js b/app/javascript/vehicle_journeys/actions/index.js index 74a333b53..bb4ccf417 100644 --- a/app/javascript/vehicle_journeys/actions/index.js +++ b/app/javascript/vehicle_journeys/actions/index.js @@ -69,6 +69,10 @@ const actions = { type : 'EDIT_VEHICLEJOURNEY_MODAL', vehicleJourney }), + openInfoModal : (vehicleJourney) => ({ + type : 'INFO_VEHICLEJOURNEY_MODAL', + vehicleJourney + }), openNotesEditModal : (vehicleJourney) => ({ type : 'EDIT_NOTES_VEHICLEJOURNEY_MODAL', vehicleJourney diff --git a/app/javascript/vehicle_journeys/components/VehicleJourney.js b/app/javascript/vehicle_journeys/components/VehicleJourney.js index e7d4b5b30..99a458f50 100644 --- a/app/javascript/vehicle_journeys/components/VehicleJourney.js +++ b/app/javascript/vehicle_journeys/components/VehicleJourney.js @@ -2,6 +2,7 @@ import React, { Component } from 'react' import PropTypes from 'prop-types' import actions from '../actions' import EditVehicleJourney from '../containers/tools/EditVehicleJourney' +import VehicleJourneyInfoButton from '../containers/tools/VehicleJourneyInfoButton' export default class VehicleJourney extends Component { constructor(props) { @@ -60,7 +61,7 @@ export default class VehicleJourney extends Component {
      - ($(e.target).parents("a").length == 0) && this.props.onSelectVehicleJourney(this.props.index) + !this.props.disabled && ($(e.target).parents("a").length == 0) && this.props.onSelectVehicleJourney(this.props.index) } >
      {this.props.value.short_id || '-'}
      @@ -93,7 +94,7 @@ export default class VehicleJourney extends Component { >
      } - {this.props.disabled && } + {this.props.disabled && }
    • {this.props.value.vehicle_journey_at_stops.map((vj, i) =>
      diff --git a/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js b/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js index f814c0459..f6a0e3c61 100644 --- a/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js +++ b/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js @@ -7,6 +7,7 @@ import CustomFieldsInputs from './CustomFieldsInputs' export default class EditVehicleJourney extends Component { constructor(props) { super(props) + this.updateValue = this.updateValue.bind(this) } handleSubmit() { @@ -23,8 +24,14 @@ export default class EditVehicleJourney extends Component { } } - getSelected() { - return this.props.vehicleJourney ? [this.props.vehicleJourney] : actions.getSelected(this.props.vehicleJourneys) + updateValue(attribute, e) { + this.props.modal.modalProps.vehicleJourney[attribute] = e.target.value + actions.resetValidation(e.currentTarget) + this.forceUpdate() + } + + editMode() { + return !this.props.modal.modalProps.info && this.props.editMode } render() { @@ -39,10 +46,10 @@ export default class EditVehicleJourney extends Component {
    • @@ -67,9 +74,9 @@ export default class EditVehicleJourney extends Component { type='text' ref='published_journey_name' className='form-control' - disabled={!this.props.editMode} - defaultValue={this.props.modal.modalProps.vehicleJourney.published_journey_name} - onKeyDown={(e) => actions.resetValidation(e.currentTarget)} + disabled={!this.editMode()} + value={this.props.modal.modalProps.vehicleJourney.published_journey_name} + onChange={(e) => this.updateValue('published_journey_name', e)} />
    • @@ -94,9 +101,9 @@ export default class EditVehicleJourney extends Component { type='text' ref='published_journey_identifier' className='form-control' - disabled={!this.props.editMode} - defaultValue={this.props.modal.modalProps.vehicleJourney.published_journey_identifier} - onKeyDown={(e) => actions.resetValidation(e.currentTarget)} + disabled={!this.editMode()} + value={this.props.modal.modalProps.vehicleJourney.published_journey_identifier} + onChange={(e) => this.updateValue('published_journey_identifier', e)} />
      @@ -105,7 +112,7 @@ export default class EditVehicleJourney extends Component { this.props.onSelect2Company(e)} onUnselect2Company = {() => this.props.onUnselect2Company()} @@ -152,13 +159,13 @@ export default class EditVehicleJourney extends Component { this.custom_fields[code]["value"] = value} - disabled={!this.props.editMode} + disabled={!this.editMode()} />
      { - this.props.editMode && + this.editMode() &&
      + + ) + } +} + +VehicleJourneyInfoButton.propTypes = { + onOpenEditModal: PropTypes.func.isRequired, + vehicleJourney: PropTypes.object.isRequired, +} diff --git a/app/javascript/vehicle_journeys/containers/tools/VehicleJourneyInfoButton.js b/app/javascript/vehicle_journeys/containers/tools/VehicleJourneyInfoButton.js new file mode 100644 index 000000000..19010c312 --- /dev/null +++ b/app/javascript/vehicle_journeys/containers/tools/VehicleJourneyInfoButton.js @@ -0,0 +1,20 @@ +import actions from '../../actions' +import { connect } from 'react-redux' +import VehicleJourneyInfoButtonComponent from '../../components/tools/VehicleJourneyInfoButton' + +const mapStateToProps = (state, ownProps) => { + return { + } +} + +const mapDispatchToProps = (dispatch) => { + return { + onOpenEditModal: (vj) =>{ + dispatch(actions.openInfoModal(vj)) + }, + } +} + +const VehicleJourneyInfoButton = connect(mapStateToProps, mapDispatchToProps)(VehicleJourneyInfoButtonComponent) + +export default VehicleJourneyInfoButton diff --git a/app/javascript/vehicle_journeys/reducers/modal.js b/app/javascript/vehicle_journeys/reducers/modal.js index fb7e16547..bcfc6ea0b 100644 --- a/app/javascript/vehicle_journeys/reducers/modal.js +++ b/app/javascript/vehicle_journeys/reducers/modal.js @@ -37,6 +37,15 @@ export default function modal(state = {}, action) { }, confirmModal: {} } + case 'INFO_VEHICLEJOURNEY_MODAL': + return { + type: 'edit', + modalProps: { + vehicleJourney: action.vehicleJourney, + info: true + }, + confirmModal: {} + } case 'EDIT_CALENDARS_VEHICLEJOURNEY_MODAL': vehicleJourneysModal = JSON.parse(JSON.stringify(action.vehicleJourneys)) let uniqTimetables = [] -- cgit v1.2.3 From e3342d251aa71702944b510ce59123295b53f9b0 Mon Sep 17 00:00:00 2001 From: Zog Date: Fri, 2 Feb 2018 10:03:28 +0100 Subject: Refs #5825; Fix pagination --- app/javascript/vehicle_journeys/actions/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'app/javascript') diff --git a/app/javascript/vehicle_journeys/actions/index.js b/app/javascript/vehicle_journeys/actions/index.js index bb4ccf417..4ca8bd73b 100644 --- a/app/javascript/vehicle_journeys/actions/index.js +++ b/app/javascript/vehicle_journeys/actions/index.js @@ -387,7 +387,9 @@ const actions = { } window.currentItemsLength = vehicleJourneys.length dispatch(actions.receiveVehicleJourneys(vehicleJourneys, returnJourneys)) - dispatch(actions.receiveTotalCount(json.total)) + if(!returnJourneys){ + dispatch(actions.receiveTotalCount(json.total)) + } } }) }, -- cgit v1.2.3 From 9f30b2debe7ece403d9e588df9763c119436d967 Mon Sep 17 00:00:00 2001 From: Zog Date: Fri, 2 Feb 2018 10:55:05 +0100 Subject: Fix jest specs --- app/javascript/time_tables/actions/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/javascript') diff --git a/app/javascript/time_tables/actions/index.js b/app/javascript/time_tables/actions/index.js index 70f548174..4a36ec4e1 100644 --- a/app/javascript/time_tables/actions/index.js +++ b/app/javascript/time_tables/actions/index.js @@ -1,5 +1,5 @@ -import range from 'lodash/range' import assign from 'lodash/assign' +import range from 'lodash/range' import reject from 'lodash/reject' import some from 'lodash/some' import every from 'lodash/every' -- cgit v1.2.3 From a08751696de0ba7a78f475588ff03f14bd44a7c6 Mon Sep 17 00:00:00 2001 From: Zog Date: Fri, 19 Jan 2018 10:17:43 +0100 Subject: Refs #3542 @1h; Add Time navigation --- .../packs/referential_overview/overview.js | 1 + app/javascript/referential_overview/index.coffee | 69 ++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 app/javascript/packs/referential_overview/overview.js create mode 100644 app/javascript/referential_overview/index.coffee (limited to 'app/javascript') diff --git a/app/javascript/packs/referential_overview/overview.js b/app/javascript/packs/referential_overview/overview.js new file mode 100644 index 000000000..59c326e9a --- /dev/null +++ b/app/javascript/packs/referential_overview/overview.js @@ -0,0 +1 @@ +import ReferentialOverview from '../../referential_overview' diff --git a/app/javascript/referential_overview/index.coffee b/app/javascript/referential_overview/index.coffee new file mode 100644 index 000000000..8dd0e3561 --- /dev/null +++ b/app/javascript/referential_overview/index.coffee @@ -0,0 +1,69 @@ +class TimeTravel + constructor: (@overview)-> + @container = @overview.container.find('.time-travel') + @todayBt = @container.find(".today") + @prevBt = @container.find(".prev-page") + @nextBt = @container.find(".next-page") + @initButtons() + + initButtons: -> + @prevBt.click (e)=> + @overview.prevPage() + e.preventDefault() + false + + @nextBt.click (e)=> + @overview.nextPage() + e.preventDefault() + false + + @todayBt.click (e)=> + today = new Date() + month = today.getMonth() + 1 + month = "0#{month}" if month < 10 + day = today.getDate() + day = "0#{month}" if day < 10 + @overview.showDay "#{today.getFullYear()}-#{month}-#{day}" + e.preventDefault() + false + + scrolledTo: (progress)-> + console.log "scrolledTo: #{progress*100}%" + @prevBt.removeClass 'disabled' + @nextBt.removeClass 'disabled' + @prevBt.addClass 'disabled' if progress == 0 + @nextBt.addClass 'disabled' if progress == 1 + +class window.ReferentialOverview + constructor: (selector)-> + @container = $(selector) + @timeTravel = new TimeTravel(this) + @currentOffset = 0 + + showDay: (date)-> + day = @container.find(".day.#{date}") + offset = day.offset().left + parentOffset = @container.find(".right .inner").offset().left + @scrollTo parentOffset - offset + + currentOffset: -> + @container.find(".right .inner").offset().left + + prevPage: -> + @scrollTo @currentOffset + @container.find(".right").width() + + nextPage: -> + @scrollTo @currentOffset - @container.find(".right").width() + + minOffset: -> + @_minOffset ||= @container.find(".right").width() - @container.find(".right .line").width() + @_minOffset + + scrollTo: (offset)-> + @currentOffset = offset + @currentOffset = Math.max(@currentOffset, @minOffset()) + @currentOffset = Math.min(@currentOffset, 0) + @container.find(".right .inner").css "margin-left": "#{@currentOffset}px" + @timeTravel.scrolledTo 1 - (@minOffset() - @currentOffset) / @minOffset() + +export default ReferentialOverview -- cgit v1.2.3 From b85f33cbf055633fab4d320f1a926e319626a9f5 Mon Sep 17 00:00:00 2001 From: Zog Date: Fri, 19 Jan 2018 11:16:44 +0100 Subject: Refs #3542 @1h; Adds filters --- app/javascript/referential_overview/index.coffee | 1 - 1 file changed, 1 deletion(-) (limited to 'app/javascript') diff --git a/app/javascript/referential_overview/index.coffee b/app/javascript/referential_overview/index.coffee index 8dd0e3561..6128d7c98 100644 --- a/app/javascript/referential_overview/index.coffee +++ b/app/javascript/referential_overview/index.coffee @@ -28,7 +28,6 @@ class TimeTravel false scrolledTo: (progress)-> - console.log "scrolledTo: #{progress*100}%" @prevBt.removeClass 'disabled' @nextBt.removeClass 'disabled' @prevBt.addClass 'disabled' if progress == 0 -- cgit v1.2.3 From efda80f4bb90cc5bc8d090c260ba2ac54869e121 Mon Sep 17 00:00:00 2001 From: Zog Date: Fri, 19 Jan 2018 12:18:12 +0100 Subject: Refs #3542 @1h; Add sticky header --- app/javascript/referential_overview/index.coffee | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'app/javascript') diff --git a/app/javascript/referential_overview/index.coffee b/app/javascript/referential_overview/index.coffee index 6128d7c98..c9a266dea 100644 --- a/app/javascript/referential_overview/index.coffee +++ b/app/javascript/referential_overview/index.coffee @@ -38,6 +38,8 @@ class window.ReferentialOverview @container = $(selector) @timeTravel = new TimeTravel(this) @currentOffset = 0 + $(document).scroll (e)=> + @documentScroll(e) showDay: (date)-> day = @container.find(".day.#{date}") @@ -48,6 +50,11 @@ class window.ReferentialOverview currentOffset: -> @container.find(".right .inner").offset().left + top: -> + @_top ||= @container.find('.days').offset().top - 80 + bottom: -> + @_bottom ||= @top() + @container.height() - 50 + prevPage: -> @scrollTo @currentOffset + @container.find(".right").width() @@ -62,7 +69,21 @@ class window.ReferentialOverview @currentOffset = offset @currentOffset = Math.max(@currentOffset, @minOffset()) @currentOffset = Math.min(@currentOffset, 0) - @container.find(".right .inner").css "margin-left": "#{@currentOffset}px" + @container.find(".right .inner .lines").css "margin-left": "#{@currentOffset}px" + @container.find(".head .week:first-child").css "margin-left", "#{@currentOffset}px" @timeTravel.scrolledTo 1 - (@minOffset() - @currentOffset) / @minOffset() + + documentScroll: (e)-> + if @sticky + if e.pageY < @top() || e.pageY > @bottom() + @container.removeClass "sticky" + @sticky = false + else + if e.pageY > @top() && e.pageY < @bottom() + @sticky = true + @container.addClass "sticky" + + + export default ReferentialOverview -- cgit v1.2.3 From bb238237ee32f7bb96fd3add772d778a7e8c8503 Mon Sep 17 00:00:00 2001 From: Zog Date: Fri, 19 Jan 2018 16:42:19 +0100 Subject: Refs #3542 @2h; Various UI improvements (hopefully) --- app/javascript/referential_overview/index.coffee | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/referential_overview/index.coffee b/app/javascript/referential_overview/index.coffee index c9a266dea..31a689273 100644 --- a/app/javascript/referential_overview/index.coffee +++ b/app/javascript/referential_overview/index.coffee @@ -40,11 +40,12 @@ class window.ReferentialOverview @currentOffset = 0 $(document).scroll (e)=> @documentScroll(e) + @documentScroll pageY: $(document).scrollTop() showDay: (date)-> day = @container.find(".day.#{date}") offset = day.offset().left - parentOffset = @container.find(".right .inner").offset().left + parentOffset = @currentOffset @scrollTo parentOffset - offset currentOffset: -> @@ -72,7 +73,21 @@ class window.ReferentialOverview @container.find(".right .inner .lines").css "margin-left": "#{@currentOffset}px" @container.find(".head .week:first-child").css "margin-left", "#{@currentOffset}px" @timeTravel.scrolledTo 1 - (@minOffset() - @currentOffset) / @minOffset() - + setTimeout => + @movePeriodTitles() + , 600 + + movePeriodTitles: -> + @_right_offset ||= @container.find('.right').offset().left + @container.find(".shifted").removeClass("shifted").css "margin-left", 0 + @container.find(".right .line").each (i, l) => + $(l).find(".period").each (i, _p) => + p = $(_p) + offset = parseInt(p.css("left")) + @currentOffset + if offset < 0 && - offset < p.width() + offset = Math.min(-offset, p.width() - 100) + p.find(".title").addClass("shifted").css "margin-left", offset + "px" + return documentScroll: (e)-> if @sticky -- cgit v1.2.3 From f937bda75ef024a281cff199a65d5ba4f811c13f Mon Sep 17 00:00:00 2001 From: Zog Date: Fri, 19 Jan 2018 17:29:50 +0100 Subject: Refs #3542; Add a date lookup --- app/javascript/referential_overview/index.coffee | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'app/javascript') diff --git a/app/javascript/referential_overview/index.coffee b/app/javascript/referential_overview/index.coffee index 31a689273..0e6541421 100644 --- a/app/javascript/referential_overview/index.coffee +++ b/app/javascript/referential_overview/index.coffee @@ -4,6 +4,8 @@ class TimeTravel @todayBt = @container.find(".today") @prevBt = @container.find(".prev-page") @nextBt = @container.find(".next-page") + @searchDateBt = @container.find("a.search-date") + @searchDateInput = @container.find("input.date-search") @initButtons() initButtons: -> @@ -27,6 +29,11 @@ class TimeTravel e.preventDefault() false + @searchDateBt.click (e)=> + @overview.showDay @searchDateInput.val() if @searchDateInput.val().length > 0 + e.preventDefault() + false + scrolledTo: (progress)-> @prevBt.removeClass 'disabled' @nextBt.removeClass 'disabled' @@ -44,8 +51,10 @@ class window.ReferentialOverview showDay: (date)-> day = @container.find(".day.#{date}") + @container.find(".day.selected").removeClass('selected') + day.addClass "selected" offset = day.offset().left - parentOffset = @currentOffset + parentOffset = @currentOffset + @container.find(".right").offset().left @scrollTo parentOffset - offset currentOffset: -> -- cgit v1.2.3 From ae36ee8a9270540cea2b0bea70b0f7c46a1818ef Mon Sep 17 00:00:00 2001 From: Zog Date: Wed, 7 Feb 2018 09:23:20 +0100 Subject: Refs #4126 @6h; Add i18n to JS --- .../vehicle_journeys/components/ConfirmModal.js | 6 +++--- app/javascript/vehicle_journeys/components/Filters.js | 18 +++++++++--------- .../vehicle_journeys/components/VehicleJourney.js | 10 +++++----- .../vehicle_journeys/components/VehicleJourneys.js | 18 +++++++++--------- .../components/tools/EditVehicleJourney.js | 2 +- 5 files changed, 27 insertions(+), 27 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/vehicle_journeys/components/ConfirmModal.js b/app/javascript/vehicle_journeys/components/ConfirmModal.js index 3bfc852fb..75e8a3932 100644 --- a/app/javascript/vehicle_journeys/components/ConfirmModal.js +++ b/app/javascript/vehicle_journeys/components/ConfirmModal.js @@ -7,7 +7,7 @@ export default function ConfirmModal({dispatch, modal, onModalAccept, onModalCan
      -

      Voulez-vous valider vos modifications avant de changer de page?

      +

      {I18n.t('vehicle_journeys.vehicle_journeys_matrix.modal_confirm')}

      ) -} +} ConfirmModal.propTypes = { vehicleJourneys: PropTypes.array.isRequired, modal: PropTypes.object.isRequired, onModalAccept: PropTypes.func.isRequired, onModalCancel: PropTypes.func.isRequired -} \ No newline at end of file +} diff --git a/app/javascript/vehicle_journeys/components/Filters.js b/app/javascript/vehicle_journeys/components/Filters.js index 2bd912e3e..f8697c930 100644 --- a/app/javascript/vehicle_journeys/components/Filters.js +++ b/app/javascript/vehicle_journeys/components/Filters.js @@ -46,10 +46,10 @@ export default function Filters({filters, pagination, missions, onFilter, onRese
      {/* Plage horaire */}
      - +
      - +
      - +
      - +
      @@ -122,7 +122,7 @@ export default function Filters({filters, pagination, missions, onFilter, onRese
      {/* Switch avec/sans calendrier */}
      - +
      diff --git a/app/javascript/vehicle_journeys/components/VehicleJourney.js b/app/javascript/vehicle_journeys/components/VehicleJourney.js index 99a458f50..4a9432231 100644 --- a/app/javascript/vehicle_journeys/components/VehicleJourney.js +++ b/app/javascript/vehicle_journeys/components/VehicleJourney.js @@ -23,7 +23,7 @@ export default class VehicleJourney extends Component { let ttURL = refURL + '/time_tables/' + tt.id return ( - +
      ) } @@ -32,7 +32,7 @@ export default class VehicleJourney extends Component { let ttURL = refURL + '/purchase_windows/' + tt.id return ( - + ) } @@ -65,7 +65,7 @@ export default class VehicleJourney extends Component { } >
      {this.props.value.short_id || '-'}
      -
      {this.props.value.published_journey_name && this.props.value.published_journey_name != "non renseigné" ? this.props.value.published_journey_name : '-'}
      +
      {this.props.value.published_journey_name && this.props.value.published_journey_name != I18n.t('undefined') ? this.props.value.published_journey_name : '-'}
      {this.props.value.journey_pattern.short_id || '-'}
      {this.props.value.company ? this.props.value.company.name : '-'}
      @@ -100,7 +100,7 @@ export default class VehicleJourney extends Component {
      {this.props.filters.toggleArrivals && -
      +
      }
      -
      +
      {(this.props.status.fetchSuccess == false) && (
      - Erreur : - la récupération des missions a rencontré un problème. Rechargez la page pour tenter de corriger le problème. + {I18n.tc("error")} + {I18n.t("vehicle_journeys.vehicle_journeys_matrix.fetching_error")}
      )} { this.vehicleJourneysList().errors && this.vehicleJourneysList().errors.length && _.some(this.vehicleJourneysList(), 'errors') && (
      - Erreur : + {I18n.tc("error")} {this.vehicleJourneysList().map((vj, index) => vj.errors && vj.errors.map((err, i) => { return ( @@ -129,12 +129,12 @@ export default class VehicleJourneys extends Component {
      0) ? '' : ' no_result')}>
      -
      ID course
      -
      Nom course
      -
      ID mission
      -
      Transporteur
      -
      Calendriers
      - { this.hasFeature('purchase_windows') &&
      Calendriers Commerciaux
      } +
      {I18n.attribute_name("vehicle_journey", "id")}
      +
      {I18n.attribute_name("vehicle_journey", "name")}
      +
      {I18n.attribute_name("vehicle_journey", "journey_pattern_id")}
      +
      {I18n.model_name("company")}
      +
      {I18n.model_name("time_table", "plural": true)}
      + { this.hasFeature('purchase_windows') &&
      {I18n.model_name("purchase_window", "plural": true)}
      }
      {this.stopPoints().map((sp, i) =>{ return ( diff --git a/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js b/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js index f6a0e3c61..bcfd4eb41 100644 --- a/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js +++ b/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js @@ -128,7 +128,7 @@ export default class EditVehicleJourney extends Component {
      -- cgit v1.2.3 From c20f034b60d39a4bcb56cd61f3fa314c64a8736c Mon Sep 17 00:00:00 2001 From: Zog Date: Wed, 7 Feb 2018 11:12:04 +0100 Subject: Refs #4126 @2h; Add more translations --- app/javascript/vehicle_journeys/components/Navigate.js | 5 ++--- .../vehicle_journeys/components/ToggleArrivals.js | 2 +- app/javascript/vehicle_journeys/components/Tools.js | 4 ++-- .../components/tools/EditVehicleJourney.js | 18 +++++++++--------- .../components/tools/VehicleJourneyInfoButton.js | 4 ++-- 5 files changed, 16 insertions(+), 17 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/vehicle_journeys/components/Navigate.js b/app/javascript/vehicle_journeys/components/Navigate.js index 0158b8392..24843babc 100644 --- a/app/javascript/vehicle_journeys/components/Navigate.js +++ b/app/javascript/vehicle_journeys/components/Navigate.js @@ -17,8 +17,7 @@ export default function Navigate({ dispatch, vehicleJourneys, pagination, status if(status.fetchSuccess == true) { return (
      - Liste des horaires {minVJ} à {maxVJ} sur {pagination.totalCount} - + {I18n.t("vehicle_journeys.vehicle_journeys_matrix.pagination", {minVJ, maxVJ, total:pagination.totalCount})}
      {e.preventDefault()}}> + {I18n.t('vehicle_journeys.vehicle_journeys_matrix.selected_journeys', {count: actions.getSelected(vehicleJourneys).length})} +
      ) } diff --git a/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js b/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js index bcfd4eb41..d3c01f154 100644 --- a/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js +++ b/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js @@ -59,7 +59,7 @@ export default class EditVehicleJourney extends Component {
      -

      Informations

      +

      {I18n.t('vehicle_journeys.form.infos')}

      ×
      @@ -69,7 +69,7 @@ export default class EditVehicleJourney extends Component {
      - +
      - +
      - +
      - +
      - +
      - +
      - + +
      - +
      ) } } -- cgit v1.2.3 From 2f895a1ee52922565b7ca1a0c00defe68f40aebd Mon Sep 17 00:00:00 2001 From: Zog Date: Mon, 12 Feb 2018 09:33:53 +0100 Subject: Refs #5888; Fix I18n in JS --- app/javascript/routes/components/BSelect2.js | 2 +- app/javascript/routes/components/OlMap.js | 24 +++++++++++----------- app/javascript/routes/components/StopPoint.js | 12 +++++------ app/javascript/routes/components/StopPointList.js | 8 ++++---- app/javascript/time_tables/actions/index.js | 12 +++++------ .../time_tables/components/ConfirmModal.js | 10 ++++----- .../time_tables/components/ErrorModal.js | 6 +++--- app/javascript/time_tables/components/Metas.js | 12 +++++------ .../time_tables/components/PeriodForm.js | 14 ++++++------- .../time_tables/components/TagsSelect2.js | 2 +- app/javascript/time_tables/components/Timetable.js | 8 ++++---- 11 files changed, 55 insertions(+), 55 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/routes/components/BSelect2.js b/app/javascript/routes/components/BSelect2.js index 158deaa17..035bce155 100644 --- a/app/javascript/routes/components/BSelect2.js +++ b/app/javascript/routes/components/BSelect2.js @@ -85,7 +85,7 @@ class BSelect2 extends Component{ onSelect={ this.props.onSelect } ref='newSelect' options={{ - placeholder: this.context.I18n.routes.edit.select2.placeholder, + placeholder: this.context.I18n.t("routes.edit.select2.placeholder"), allowClear: true, language: 'fr', /* Doesn't seem to work... :( */ theme: 'bootstrap', diff --git a/app/javascript/routes/components/OlMap.js b/app/javascript/routes/components/OlMap.js index 056bddbcb..4beb02872 100644 --- a/app/javascript/routes/components/OlMap.js +++ b/app/javascript/routes/components/OlMap.js @@ -115,40 +115,40 @@ export default class OlMap extends Component{ {this.props.value.olMap.json.name}

      - {this.context.I18n.routes.edit.stop_point_type} : + {this.context.I18n.t('routes.edit.map.stop_point_type')} : {this.props.value.olMap.json.area_type}

      - {this.context.I18n.routes.edit.short_name} : + {this.context.I18n.t('routes.edit.map.short_name')} : {this.props.value.olMap.json.short_name}

      - {this.context.I18n.id_reflex} : + {this.context.I18n.t('id_reflex')} : {this.props.value.olMap.json.user_objectid}

      -

      {this.context.I18n.routes.edit.map.coordinates} :

      +

      {this.context.I18n.t('routes.edit.map.coordinates')} :

      - {this.context.I18n.routes.edit.map.proj}.: WSG84
      - {this.context.I18n.routes.edit.map.lat}.: {this.props.value.olMap.json.latitude}
      - {this.context.I18n.routes.edit.map.lon}.: {this.props.value.olMap.json.longitude} + {this.context.I18n.t('routes.edit.map.proj')}.: WSG84
      + {this.context.I18n.t('routes.edit.map.lat')}.: {this.props.value.olMap.json.latitude}
      + {this.context.I18n.t('routes.edit.map.lon')}.: {this.props.value.olMap.json.longitude}

      - {this.context.I18n.routes.edit.map.postal_code} : + {this.context.I18n.t('routes.edit.map.postal_code')} : {this.props.value.olMap.json.zip_code}

      - {this.context.I18n.routes.edit.map.city} : + {this.context.I18n.t('routes.edit.map.city')} : {this.props.value.olMap.json.city_name}

      - {this.context.I18n.routes.edit.map.comment} : + {this.context.I18n.t('routes.edit.map.comment')} : {this.props.value.olMap.json.comment}

      {(this.props.value.stoparea_id != this.props.value.olMap.json.stoparea_id) &&(
      {this.props.onUpdateViaOlMap(this.props.index, this.props.value.olMap.json)}} - >{this.context.I18n.actions.select}
      + >{this.context.I18n.t('actions.select')}
      )}
      @@ -162,7 +162,7 @@ export default class OlMap extends Component{ } } -OlMap.PropTypes = { +OlMap.propTypes = { } OlMap.contextTypes = { diff --git a/app/javascript/routes/components/StopPoint.js b/app/javascript/routes/components/StopPoint.js index 2d47e802b..af51a6bb4 100644 --- a/app/javascript/routes/components/StopPoint.js +++ b/app/javascript/routes/components/StopPoint.js @@ -18,15 +18,15 @@ export default function StopPoint(props, {I18n}) {
      @@ -77,7 +77,7 @@ export default function StopPoint(props, {I18n}) { ) } -StopPoint.PropTypes = { +StopPoint.propTypes = { onToggleMap: PropTypes.func.isRequired, onToggleEdit: PropTypes.func.isRequired, onDeleteClick: PropTypes.func.isRequired, @@ -93,4 +93,4 @@ StopPoint.PropTypes = { StopPoint.contextTypes = { I18n: PropTypes.object -} \ No newline at end of file +} diff --git a/app/javascript/routes/components/StopPointList.js b/app/javascript/routes/components/StopPointList.js index b39fa0c9c..b227abdea 100644 --- a/app/javascript/routes/components/StopPointList.js +++ b/app/javascript/routes/components/StopPointList.js @@ -10,22 +10,22 @@ export default function StopPointList({ stopPoints, onDeleteClick, onMoveUpClick
      - +
      - +
      - +
      - +
      diff --git a/app/javascript/time_tables/actions/index.js b/app/javascript/time_tables/actions/index.js index 4a36ec4e1..98b9eab4b 100644 --- a/app/javascript/time_tables/actions/index.js +++ b/app/javascript/time_tables/actions/index.js @@ -8,7 +8,7 @@ const I18n = clone(window, "I18n") const actions = { weekDays: (index) => { - return range(1, 8).map(n => I18n.time_tables.edit.metas.days[n]) + return range(1, 8).map(n => I18n.t('time_tables.edit.metas.days')[n]) }, strToArrayDayTypes: (str) =>{ return actions.weekDays().map(day => str.indexOf(day) !== -1) @@ -155,7 +155,7 @@ const actions = { type : 'CLOSE_MODAL' }), monthName(strDate) { - let monthList = range(1,13).map(n => I18n.calendars.months[n]) + let monthList = range(1,13).map(n => I18n.t('calendars.months.'+ n )) let date = new Date(strDate) return monthList[date.getUTCMonth()] }, @@ -225,7 +225,7 @@ const actions = { let period = periods[i] if (index !== i && !period.deleted) { if (new Date(period.period_start) <= end && new Date(period.period_end) >= start) { - error = I18n.time_tables.edit.error_submit.periods_overlaps + error = I18n.t('time_tables.edit.error_submit.periods_overlaps') break } } @@ -239,7 +239,7 @@ const actions = { for (let day of in_days) { if (start <= new Date(day.date) && end >= new Date(day.date)) { - error = I18n.time_tables.edit.error_submit.dates_overlaps + error = I18n.t('time_tables.edit.error_submit.dates_overlaps') break } } @@ -316,9 +316,9 @@ const actions = { errorModalMessage: (errorKey) => { switch (errorKey) { case "withoutPeriodsWithDaysTypes": - return I18n.time_tables.edit.error_modal.withoutPeriodsWithDaysTypes + return I18n.t('time_tables.edit.error_modal.withoutPeriodsWithDaysTypes') case "withPeriodsWithoutDayTypes": - return I18n.time_tables.edit.error_modal.withPeriodsWithoutDayTypes + return I18n.t('time_tables.edit.error_modal.withPeriodsWithoutDayTypes') default: return errorKey diff --git a/app/javascript/time_tables/components/ConfirmModal.js b/app/javascript/time_tables/components/ConfirmModal.js index 845e7ed1b..4e8583bc0 100644 --- a/app/javascript/time_tables/components/ConfirmModal.js +++ b/app/javascript/time_tables/components/ConfirmModal.js @@ -9,11 +9,11 @@ export default function ConfirmModal({dispatch, modal, onModalAccept, onModalCan
      -

      {I18n.time_tables.edit.confirm_modal.title}

      +

      {I18n.t('time_tables.edit.confirm_modal.title')}

      -

      {I18n.time_tables.edit.confirm_modal.message}

      +

      {I18n.t('time_tables.edit.confirm_modal.message')}

      @@ -23,7 +23,7 @@ export default function ConfirmModal({dispatch, modal, onModalAccept, onModalCan type='button' onClick={() => { onModalCancel(modal.confirmModal.callback) }} > - {I18n.cancel} + {I18n.t('cancel')}
      @@ -49,4 +49,4 @@ ConfirmModal.propTypes = { ConfirmModal.contextTypes = { I18n: PropTypes.object -} \ No newline at end of file +} diff --git a/app/javascript/time_tables/components/ErrorModal.js b/app/javascript/time_tables/components/ErrorModal.js index 543177e54..8af12f1d1 100644 --- a/app/javascript/time_tables/components/ErrorModal.js +++ b/app/javascript/time_tables/components/ErrorModal.js @@ -10,7 +10,7 @@ export default function ErrorModal({dispatch, modal, onModalClose}, {I18n}) {
      -

      {I18n.time_tables.edit.error_modal.title}

      +

      {I18n.t('time_tables.edit.error_modal.title')}

      @@ -24,7 +24,7 @@ export default function ErrorModal({dispatch, modal, onModalClose}, {I18n}) { type='button' onClick={() => { onModalClose() }} > - {I18n.back} + {I18n.t('back')}
      @@ -41,4 +41,4 @@ ErrorModal.propTypes = { ErrorModal.contextTypes = { I18n: PropTypes.object -} \ No newline at end of file +} diff --git a/app/javascript/time_tables/components/Metas.js b/app/javascript/time_tables/components/Metas.js index 3c6848d27..08a6e26fe 100644 --- a/app/javascript/time_tables/components/Metas.js +++ b/app/javascript/time_tables/components/Metas.js @@ -13,7 +13,7 @@ export default function Metas({metas, onUpdateDayTypes, onUpdateComment, onUpdat {/* comment (name) */}
      - +
      @@ -124,7 +124,7 @@ export default function PeriodForm({modal, timetable, metas, onOpenAddPeriodForm className='btn btn-outline-primary' onClick={onOpenAddPeriodForm} > - {I18n.time_tables.actions.add_period} + {I18n.t('time_tables.actions.add_period')}
      } @@ -132,7 +132,7 @@ export default function PeriodForm({modal, timetable, metas, onOpenAddPeriodForm
      - ) + ) } PeriodForm.propTypes = { @@ -147,4 +147,4 @@ PeriodForm.propTypes = { PeriodForm.contextTypes = { I18n: PropTypes.object -} \ No newline at end of file +} diff --git a/app/javascript/time_tables/components/TagsSelect2.js b/app/javascript/time_tables/components/TagsSelect2.js index dc3739d58..43cf59fdf 100644 --- a/app/javascript/time_tables/components/TagsSelect2.js +++ b/app/javascript/time_tables/components/TagsSelect2.js @@ -40,7 +40,7 @@ export default class TagsSelect2 extends Component { allowClear: true, theme: 'bootstrap', width: '100%', - placeholder: this.context.I18n.time_tables.edit.select2.tag.placeholder, + placeholder: this.context.I18n.t('time_tables.edit.select2.tag.placeholder'), ajax: { url: origin + path + '/tags.json', dataType: 'json', diff --git a/app/javascript/time_tables/components/Timetable.js b/app/javascript/time_tables/components/Timetable.js index c44f2a134..991f31435 100644 --- a/app/javascript/time_tables/components/Timetable.js +++ b/app/javascript/time_tables/components/Timetable.js @@ -31,11 +31,11 @@ export default class Timetable extends Component {
      -
      {this.context.I18n.time_tables.synthesis}
      +
      {this.context.I18n.t('time_tables.edit.synthesis')}
      -
      {this.context.I18n.time_tables.edit.day_types}
      -
      {this.context.I18n.time_tables.edit.periods}
      -
      {this.context.I18n.time_tables.edit.exceptions}
      +
      {this.context.I18n.t('time_tables.edit.day_types')}
      +
      {this.context.I18n.t('time_tables.edit.periods')}
      +
      {this.context.I18n.t('time_tables.edit.exceptions')}
      -- cgit v1.2.3