aboutsummaryrefslogtreecommitdiffstats
path: root/app/javascript
diff options
context:
space:
mode:
Diffstat (limited to 'app/javascript')
-rw-r--r--app/javascript/helpers/polyfills.js4
-rw-r--r--app/javascript/journey_patterns/actions/index.js20
-rw-r--r--app/javascript/journey_patterns/components/CreateModal.js4
-rw-r--r--app/javascript/journey_patterns/components/JourneyPattern.js2
-rw-r--r--app/javascript/journey_patterns/reducers/journeyPatterns.js2
-rw-r--r--app/javascript/packs/calendars/edit.js2
-rw-r--r--app/javascript/packs/exports/new.js2
-rw-r--r--app/javascript/packs/journey_patterns/index.js2
-rw-r--r--app/javascript/packs/referential_lines/show.js2
-rw-r--r--app/javascript/packs/referential_overview/overview.js2
-rw-r--r--app/javascript/packs/routes/edit.js27
-rw-r--r--app/javascript/packs/routes/show.js2
-rw-r--r--app/javascript/packs/stop_areas/new.js2
-rw-r--r--app/javascript/packs/time_tables/edit.js2
-rw-r--r--app/javascript/packs/vehicle_journeys/index.js2
-rw-r--r--app/javascript/routes/components/StopPoint.js6
-rw-r--r--app/javascript/time_tables/actions/index.js17
-rw-r--r--app/javascript/time_tables/components/ConfirmModal.js8
-rw-r--r--app/javascript/time_tables/components/ErrorModal.js8
-rw-r--r--app/javascript/time_tables/components/Metas.js8
-rw-r--r--app/javascript/time_tables/components/PeriodForm.js8
-rw-r--r--app/javascript/time_tables/components/PeriodManager.js8
-rw-r--r--app/javascript/time_tables/components/TagsSelect2.js6
-rw-r--r--app/javascript/time_tables/components/Timetable.js14
-rw-r--r--app/javascript/time_tables/containers/App.js1
-rw-r--r--app/javascript/vehicle_journeys/actions/index.js32
-rw-r--r--app/javascript/vehicle_journeys/components/Filters.js4
-rw-r--r--app/javascript/vehicle_journeys/components/tools/CustomFieldsInputs.js13
-rw-r--r--app/javascript/vehicle_journeys/components/tools/TimetablesEditVehicleJourney.js2
-rw-r--r--app/javascript/vehicle_journeys/components/tools/select2s/CompanySelect2.js2
-rw-r--r--app/javascript/vehicle_journeys/components/tools/select2s/MissionSelect2.js2
-rw-r--r--app/javascript/vehicle_journeys/components/tools/select2s/TimetableSelect2.js2
-rw-r--r--app/javascript/vehicle_journeys/components/tools/select2s/VJSelect2.js2
-rw-r--r--app/javascript/vehicle_journeys/components/tools/select2s/fr.js9
-rw-r--r--app/javascript/vehicle_journeys/components/tools/select2s/language.js9
-rw-r--r--app/javascript/vehicle_journeys/reducers/vehicleJourneys.js15
36 files changed, 138 insertions, 115 deletions
diff --git a/app/javascript/helpers/polyfills.js b/app/javascript/helpers/polyfills.js
new file mode 100644
index 000000000..93e3e9846
--- /dev/null
+++ b/app/javascript/helpers/polyfills.js
@@ -0,0 +1,4 @@
+import 'promise-polyfill/src/polyfill'
+import 'es6-symbol/implement'
+import 'polyfill-array-includes'
+import 'whatwg-fetch'
diff --git a/app/javascript/journey_patterns/actions/index.js b/app/javascript/journey_patterns/actions/index.js
index 666157ea4..a813f4b9e 100644
--- a/app/javascript/journey_patterns/actions/index.js
+++ b/app/javascript/journey_patterns/actions/index.js
@@ -1,10 +1,3 @@
-import Promise from 'promise-polyfill'
-
-// To add to window
-if (!window.Promise) {
- window.Promise = Promise;
-}
-
const actions = {
enterEditMode: () => ({
type: "ENTER_EDIT_MODE"
@@ -43,7 +36,7 @@ const actions = {
}),
updateCheckboxValue : (e, index) => ({
type : 'UPDATE_CHECKBOX_VALUE',
- id : e.currentTarget.id,
+ position : e.currentTarget.id,
index
}),
checkConfirmModal : (event, callback, stateChanged,dispatch) => {
@@ -195,15 +188,19 @@ const actions = {
dispatch(actions.unavailableServer())
} else {
if(json.length != 0){
- let val
- for (val of json){
- for (let stop_point of val.route_short_description.stop_points){
+ let j = 0
+ while(j < json.length){
+ let val = json[j]
+ let i = 0
+ while(i < val.route_short_description.stop_points.length){
+ let stop_point = val.route_short_description.stop_points[i]
stop_point.checked = false
val.stop_area_short_descriptions.map((element) => {
if(element.stop_area_short_description.id === stop_point.id){
stop_point.checked = true
}
})
+ i ++
}
journeyPatterns.push(
_.assign({}, val, {
@@ -212,6 +209,7 @@ const actions = {
deletable: false
})
)
+ j ++
}
}
window.currentItemsLength = journeyPatterns.length
diff --git a/app/javascript/journey_patterns/components/CreateModal.js b/app/javascript/journey_patterns/components/CreateModal.js
index 36b5740dc..946c13d9c 100644
--- a/app/javascript/journey_patterns/components/CreateModal.js
+++ b/app/javascript/journey_patterns/components/CreateModal.js
@@ -57,7 +57,7 @@ export default class CreateModal extends Component {
<div className='row'>
<div className='col-lg-6 col-md-6 col-sm-6 col-xs-6'>
<div className='form-group'>
- <label className='control-label is-required'>{I18n.attribute_name('journey_pattern', 'published_name')}c</label>
+ <label className='control-label is-required'>{I18n.attribute_name('journey_pattern', 'published_name')}</label>
<input
type='text'
ref='published_name'
@@ -120,4 +120,4 @@ CreateModal.propTypes = {
onOpenCreateModal: PropTypes.func.isRequired,
onModalClose: PropTypes.func.isRequired,
onAddJourneyPattern: PropTypes.func.isRequired
-} \ No newline at end of file
+}
diff --git a/app/javascript/journey_patterns/components/JourneyPattern.js b/app/javascript/journey_patterns/components/JourneyPattern.js
index d381b0d50..4eba80030 100644
--- a/app/javascript/journey_patterns/components/JourneyPattern.js
+++ b/app/javascript/journey_patterns/components/JourneyPattern.js
@@ -45,7 +45,7 @@ export default class JourneyPattern extends Component{
<input
onChange = {(e) => this.props.onCheckboxChange(e)}
type='checkbox'
- id={sp.id}
+ id={sp.position}
checked={sp.checked}
disabled={(this.props.value.deletable || this.props.status.policy['journey_patterns.update'] == false || this.props.editMode == false) ? 'disabled' : ''}
>
diff --git a/app/javascript/journey_patterns/reducers/journeyPatterns.js b/app/javascript/journey_patterns/reducers/journeyPatterns.js
index 6c38e9288..b046f2b38 100644
--- a/app/javascript/journey_patterns/reducers/journeyPatterns.js
+++ b/app/javascript/journey_patterns/reducers/journeyPatterns.js
@@ -22,7 +22,7 @@ const journeyPattern = (state = {}, action) =>{
}
case 'UPDATE_CHECKBOX_VALUE':
var updatedStopPoints = state.stop_points.map((s) => {
- if (String(s.id) == action.id) {
+ if (String(s.position) == action.position) {
return _.assign({}, s, {checked : !s.checked})
}else {
return s
diff --git a/app/javascript/packs/calendars/edit.js b/app/javascript/packs/calendars/edit.js
index bd09657ec..0c46313b9 100644
--- a/app/javascript/packs/calendars/edit.js
+++ b/app/javascript/packs/calendars/edit.js
@@ -1,3 +1,5 @@
+import '../../helpers/polyfills'
+
import React from 'react'
import { render } from 'react-dom'
import { Provider } from 'react-redux'
diff --git a/app/javascript/packs/exports/new.js b/app/javascript/packs/exports/new.js
index ffe702cdb..b113cc709 100644
--- a/app/javascript/packs/exports/new.js
+++ b/app/javascript/packs/exports/new.js
@@ -1,3 +1,5 @@
+import '../../helpers/polyfills'
+
import MasterSlave from "../../helpers/master_slave"
new MasterSlave("form")
diff --git a/app/javascript/packs/journey_patterns/index.js b/app/javascript/packs/journey_patterns/index.js
index 367a8830f..075eea13a 100644
--- a/app/javascript/packs/journey_patterns/index.js
+++ b/app/javascript/packs/journey_patterns/index.js
@@ -1,3 +1,5 @@
+import '../../helpers/polyfills'
+
import React from 'react'
import { render } from 'react-dom'
import { Provider } from 'react-redux'
diff --git a/app/javascript/packs/referential_lines/show.js b/app/javascript/packs/referential_lines/show.js
index 99c5072ef..523f2040f 100644
--- a/app/javascript/packs/referential_lines/show.js
+++ b/app/javascript/packs/referential_lines/show.js
@@ -1,3 +1,5 @@
+import '../../helpers/polyfills'
+
import clone from '../../helpers/clone'
import RoutesMap from '../../helpers/routes_map'
diff --git a/app/javascript/packs/referential_overview/overview.js b/app/javascript/packs/referential_overview/overview.js
index 59c326e9a..03da12ef3 100644
--- a/app/javascript/packs/referential_overview/overview.js
+++ b/app/javascript/packs/referential_overview/overview.js
@@ -1 +1,3 @@
+import '../../helpers/polyfills'
+
import ReferentialOverview from '../../referential_overview'
diff --git a/app/javascript/packs/routes/edit.js b/app/javascript/packs/routes/edit.js
index fc7aa203d..0512b7aff 100644
--- a/app/javascript/packs/routes/edit.js
+++ b/app/javascript/packs/routes/edit.js
@@ -1,3 +1,5 @@
+import '../../helpers/polyfills'
+
import React from 'react'
import PropTypes from 'prop-types'
@@ -56,12 +58,25 @@ const getInitialState = () => {
}
var initialState = { stopPoints: getInitialState() }
-const loggerMiddleware = createLogger()
-let store = createStore(
- reducers,
- initialState,
- applyMiddleware(thunkMiddleware, promise, loggerMiddleware)
-)
+let store = null
+
+if(Object.assign){
+ const loggerMiddleware = createLogger()
+ store = createStore(
+ reducers,
+ initialState,
+ applyMiddleware(thunkMiddleware, promise, loggerMiddleware)
+ )
+}
+else{
+ // IE
+ store = createStore(
+ reducers,
+ initialState,
+ applyMiddleware(thunkMiddleware, promise)
+ )
+}
+
render(
<Provider store={store}>
diff --git a/app/javascript/packs/routes/show.js b/app/javascript/packs/routes/show.js
index c20de0800..e8e068ddd 100644
--- a/app/javascript/packs/routes/show.js
+++ b/app/javascript/packs/routes/show.js
@@ -1,3 +1,5 @@
+import '../../helpers/polyfills'
+
import clone from '../../helpers/clone'
import RoutesMap from '../../helpers/routes_map'
diff --git a/app/javascript/packs/stop_areas/new.js b/app/javascript/packs/stop_areas/new.js
index ffe702cdb..b113cc709 100644
--- a/app/javascript/packs/stop_areas/new.js
+++ b/app/javascript/packs/stop_areas/new.js
@@ -1,3 +1,5 @@
+import '../../helpers/polyfills'
+
import MasterSlave from "../../helpers/master_slave"
new MasterSlave("form")
diff --git a/app/javascript/packs/time_tables/edit.js b/app/javascript/packs/time_tables/edit.js
index cf058d501..873bdea50 100644
--- a/app/javascript/packs/time_tables/edit.js
+++ b/app/javascript/packs/time_tables/edit.js
@@ -1,3 +1,5 @@
+import '../../helpers/polyfills'
+
import React from 'react'
import { render } from 'react-dom'
import { Provider } from 'react-redux'
diff --git a/app/javascript/packs/vehicle_journeys/index.js b/app/javascript/packs/vehicle_journeys/index.js
index 9cad3870e..0b4351d26 100644
--- a/app/javascript/packs/vehicle_journeys/index.js
+++ b/app/javascript/packs/vehicle_journeys/index.js
@@ -1,3 +1,5 @@
+import '../../helpers/polyfills'
+
import React from 'react'
import { render } from 'react-dom'
import { Provider } from 'react-redux'
diff --git a/app/javascript/routes/components/StopPoint.js b/app/javascript/routes/components/StopPoint.js
index 808e739a6..908e97263 100644
--- a/app/javascript/routes/components/StopPoint.js
+++ b/app/javascript/routes/components/StopPoint.js
@@ -4,7 +4,7 @@ import PropTypes from 'prop-types'
import BSelect2 from './BSelect2'
import OlMap from './OlMap'
-import { defaultAttribute } from '../actions'
+import { defaultAttribute } from '../actions'
export default function StopPoint(props, {I18n}) {
return (
@@ -42,13 +42,13 @@ export default function StopPoint(props, {I18n}) {
<div
className={'btn btn-link' + (props.first ? ' disabled' : '')}
- onClick={props.onMoveUpClick}
+ onClick={props.first ? null : props.onMoveUpClick}
>
<span className='fa fa-arrow-up'></span>
</div>
<div
className={'btn btn-link' + (props.last ? ' disabled' : '')}
- onClick={props.onMoveDownClick}
+ onClick={props.last ? null : props.onMoveDownClick}
>
<span className='fa fa-arrow-down'></span>
</div>
diff --git a/app/javascript/time_tables/actions/index.js b/app/javascript/time_tables/actions/index.js
index 98b9eab4b..a5c454a18 100644
--- a/app/javascript/time_tables/actions/index.js
+++ b/app/javascript/time_tables/actions/index.js
@@ -4,7 +4,6 @@ import reject from 'lodash/reject'
import some from 'lodash/some'
import every from 'lodash/every'
import clone from '../../helpers/clone'
-const I18n = clone(window, "I18n")
const actions = {
weekDays: (index) => {
@@ -192,10 +191,13 @@ const actions = {
isInPeriod: (periods, date) => {
date = new Date(date)
- for (let period of periods) {
+ let i = 0;
+ while(i < periods.length){
+ let period = periods[i]
let begin = new Date(period.period_start)
let end = new Date(period.period_end)
if (date >= begin && date <= end) return true
+ i++
}
return false
@@ -236,12 +238,14 @@ const actions = {
let error = ''
start = new Date(start)
end = new Date(end)
-
- for (let day of in_days) {
+ let i = 0;
+ while(i < in_days){
+ let day = in_days[i]
if (start <= new Date(day.date) && end >= new Date(day.date)) {
error = I18n.t('time_tables.edit.error_submit.dates_overlaps')
break
}
+ i ++
}
return error
},
@@ -307,10 +311,11 @@ const actions = {
})
},
errorModalKey: (periods, dayTypes) => {
- const withoutPeriodsWithDaysTypes = reject(periods, 'deleted').length == 0 && some(dayTypes) && "withoutPeriodsWithDaysTypes"
+ // const withoutPeriodsWithDaysTypes = reject(periods, 'deleted').length == 0 && some(dayTypes) && "withoutPeriodsWithDaysTypes"
const withPeriodsWithoutDayTypes = reject(periods, 'deleted').length > 0 && every(dayTypes, dt => dt == false) && "withPeriodsWithoutDayTypes"
- return (withoutPeriodsWithDaysTypes || withPeriodsWithoutDayTypes) && (withoutPeriodsWithDaysTypes ? "withoutPeriodsWithDaysTypes" : "withPeriodsWithoutDayTypes")
+ // return (withoutPeriodsWithDaysTypes || withPeriodsWithoutDayTypes) && (withoutPeriodsWithDaysTypes ? "withoutPeriodsWithDaysTypes" : "withPeriodsWithoutDayTypes")
+ return withPeriodsWithoutDayTypes
},
errorModalMessage: (errorKey) => {
diff --git a/app/javascript/time_tables/components/ConfirmModal.js b/app/javascript/time_tables/components/ConfirmModal.js
index 4e8583bc0..e4219348d 100644
--- a/app/javascript/time_tables/components/ConfirmModal.js
+++ b/app/javascript/time_tables/components/ConfirmModal.js
@@ -2,7 +2,7 @@ import React from 'react'
import PropTypes from 'prop-types'
-export default function ConfirmModal({dispatch, modal, onModalAccept, onModalCancel, timetable, metas}, {I18n}) {
+export default function ConfirmModal({dispatch, modal, onModalAccept, onModalCancel, timetable, metas}) {
return (
<div className={'modal fade ' + ((modal.type == 'confirm') ? 'in' : '')} id='ConfirmModal'>
<div className='modal-container'>
@@ -45,8 +45,4 @@ ConfirmModal.propTypes = {
modal: PropTypes.object.isRequired,
onModalAccept: PropTypes.func.isRequired,
onModalCancel: PropTypes.func.isRequired
-}
-
-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 8af12f1d1..a512d28fd 100644
--- a/app/javascript/time_tables/components/ErrorModal.js
+++ b/app/javascript/time_tables/components/ErrorModal.js
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types'
import actions from '../actions'
-export default function ErrorModal({dispatch, modal, onModalClose}, {I18n}) {
+export default function ErrorModal({dispatch, modal, onModalClose}) {
return (
<div className={'modal fade ' + ((modal.type == 'error') ? 'in' : '')} id='ErrorModal'>
<div className='modal-container'>
@@ -37,8 +37,4 @@ export default function ErrorModal({dispatch, modal, onModalClose}, {I18n}) {
ErrorModal.propTypes = {
modal: PropTypes.object.isRequired,
onModalClose: PropTypes.func.isRequired
-}
-
-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 08a6e26fe..d9746a379 100644
--- a/app/javascript/time_tables/components/Metas.js
+++ b/app/javascript/time_tables/components/Metas.js
@@ -4,7 +4,7 @@ import PropTypes from 'prop-types'
import actions from '../actions'
import TagsSelect2 from './TagsSelect2'
-export default function Metas({metas, onUpdateDayTypes, onUpdateComment, onUpdateColor, onSelect2Tags, onUnselect2Tags}, {I18n}) {
+export default function Metas({metas, onUpdateDayTypes, onUpdateComment, onUpdateColor, onSelect2Tags, onUnselect2Tags}) {
let colorList = ["", "#9B9B9B", "#FFA070", "#C67300", "#7F551B", "#41CCE3", "#09B09C", "#3655D7", "#6321A0", "#E796C6", "#DD2DAA"]
return (
<div className='form-horizontal'>
@@ -134,8 +134,4 @@ Metas.propTypes = {
onUpdateColor: PropTypes.func.isRequired,
onSelect2Tags: PropTypes.func.isRequired,
onUnselect2Tags: PropTypes.func.isRequired
-}
-
-Metas.contextTypes = {
- I18n: PropTypes.object
-}
+} \ No newline at end of file
diff --git a/app/javascript/time_tables/components/PeriodForm.js b/app/javascript/time_tables/components/PeriodForm.js
index d17a246f7..36ed6cfdf 100644
--- a/app/javascript/time_tables/components/PeriodForm.js
+++ b/app/javascript/time_tables/components/PeriodForm.js
@@ -33,7 +33,7 @@ const makeYearsOptions = (yearSelected) => {
return arr
}
-export default function PeriodForm({modal, timetable, metas, onOpenAddPeriodForm, onClosePeriodForm, onUpdatePeriodForm, onValidatePeriodForm}, {I18n}) {
+export default function PeriodForm({modal, timetable, metas, onOpenAddPeriodForm, onClosePeriodForm, onUpdatePeriodForm, onValidatePeriodForm}) {
return (
<div className="container-fluid">
<div className="row">
@@ -143,8 +143,4 @@ PeriodForm.propTypes = {
onUpdatePeriodForm: PropTypes.func.isRequired,
onValidatePeriodForm: PropTypes.func.isRequired,
timetable: PropTypes.object.isRequired
-}
-
-PeriodForm.contextTypes = {
- I18n: PropTypes.object
-}
+} \ No newline at end of file
diff --git a/app/javascript/time_tables/components/PeriodManager.js b/app/javascript/time_tables/components/PeriodManager.js
index 6b817fe73..6871d0b9b 100644
--- a/app/javascript/time_tables/components/PeriodManager.js
+++ b/app/javascript/time_tables/components/PeriodManager.js
@@ -55,7 +55,7 @@ export default class PeriodManager extends Component {
type='button'
onClick={() => this.props.onOpenEditPeriodForm(this.props.value, this.props.index)}
>
- Modifier
+ {I18n.t('actions.edit')}
</button>
</li>
<li className='delete-action'>
@@ -64,7 +64,7 @@ export default class PeriodManager extends Component {
onClick={() => this.props.onDeletePeriod(this.props.index, this.props.metas.day_types)}
>
<span className='fa fa-trash'></span>
- Supprimer
+ {I18n.t('actions.destroy')}
</button>
</li>
</ul>
@@ -79,8 +79,4 @@ PeriodManager.propTypes = {
currentDate: PropTypes.object.isRequired,
onDeletePeriod: PropTypes.func.isRequired,
onOpenEditPeriodForm: PropTypes.func.isRequired
-}
-
-PeriodManager.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 43cf59fdf..dd8d6e9c0 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.t('time_tables.edit.select2.tag.placeholder'),
+ placeholder: I18n.t('time_tables.edit.select2.tag.placeholder'),
ajax: {
url: origin + path + '/tags.json',
dataType: 'json',
@@ -74,8 +74,4 @@ export default class TagsSelect2 extends Component {
const formatRepo = (props) => {
if(props.name) return props.name
-}
-
-TagsSelect2.contextTypes = {
- I18n: PropTypes.object
} \ No newline at end of file
diff --git a/app/javascript/time_tables/components/Timetable.js b/app/javascript/time_tables/components/Timetable.js
index 991f31435..3779fa2d0 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 {
<div className="table table-2entries mb-sm">
<div className="t2e-head w20">
<div className="th">
- <div className="strong">{this.context.I18n.t('time_tables.edit.synthesis')}</div>
+ <div className="strong">{I18n.t('time_tables.edit.synthesis')}</div>
</div>
- <div className="td"><span>{this.context.I18n.t('time_tables.edit.day_types')}</span></div>
- <div className="td"><span>{this.context.I18n.t('time_tables.edit.periods')}</span></div>
- <div className="td"><span>{this.context.I18n.t('time_tables.edit.exceptions')}</span></div>
+ <div className="td"><span>{I18n.t('time_tables.edit.day_types')}</span></div>
+ <div className="td"><span>{I18n.t('time_tables.edit.periods')}</span></div>
+ <div className="td"><span>{I18n.t('time_tables.edit.exceptions')}</span></div>
</div>
<div className="t2e-item-list w80">
<div>
@@ -109,8 +109,4 @@ Timetable.propTypes = {
onDeletePeriod: PropTypes.func.isRequired,
onExcludeDateFromPeriod: PropTypes.func.isRequired,
onIncludeDateInPeriod: PropTypes.func.isRequired
-}
-
-Timetable.contextTypes = {
- I18n: PropTypes.object
-}
+} \ No newline at end of file
diff --git a/app/javascript/time_tables/containers/App.js b/app/javascript/time_tables/containers/App.js
index 5963f8f1d..c12e33ef5 100644
--- a/app/javascript/time_tables/containers/App.js
+++ b/app/javascript/time_tables/containers/App.js
@@ -10,7 +10,6 @@ import SaveTimetable from './SaveTimetable'
import ConfirmModal from './ConfirmModal'
import ErrorModal from './ErrorModal'
import clone from '../../helpers/clone'
-const I18n = clone(window, "I18n", true)
class App extends Component {
componentDidMount(){
diff --git a/app/javascript/vehicle_journeys/actions/index.js b/app/javascript/vehicle_journeys/actions/index.js
index e00e9b1b0..d51012cdb 100644
--- a/app/javascript/vehicle_journeys/actions/index.js
+++ b/app/javascript/vehicle_journeys/actions/index.js
@@ -1,9 +1,3 @@
-import Promise from 'promise-polyfill'
-
-// To add to window
-if (!window.Promise) {
- window.Promise = Promise;
-}
import { batchActions } from '../batch'
const actions = {
@@ -113,14 +107,9 @@ const actions = {
type : 'EDIT_PURCHASE_WINDOWS_VEHICLEJOURNEY_MODAL',
vehicleJourneys
}),
- selectPurchaseWindowsModal: (selectedWindow) =>({
+ selectPurchaseWindowsModal: (selectedItem) =>({
type: 'SELECT_PURCHASE_WINDOW_MODAL',
- selectedItem:{
- id: selectedWindow.id,
- name: selectedWindow.name,
- color: selectedWindow.color,
- objectid: selectedWindow.objectid
- }
+ selectedItem
}),
addSelectedPurchaseWindow: () => ({
type: 'ADD_SELECTED_PURCHASE_WINDOW'
@@ -344,16 +333,23 @@ const actions = {
if(hasError == true) {
dispatch(actions.unavailableServer())
} else {
- let val
- for (val of json.vehicle_journeys){
+ let i = 0
+ while(i < json.vehicle_journeys.length){
+ let val = json.vehicle_journeys[i]
+ i++
var timeTables = []
var purchaseWindows = []
- let tt
- for (tt of val.time_tables){
+ let k = 0
+ while(k < val.time_tables.length){
+ let tt = val.time_tables[k]
+ k++
timeTables.push(tt)
}
if(val.purchase_windows){
- for (tt of val.purchase_windows){
+ k = 0
+ while(k < val.purchase_windows.length){
+ let tt = val.purchase_windows[k]
+ k++
purchaseWindows.push(tt)
}
}
diff --git a/app/javascript/vehicle_journeys/components/Filters.js b/app/javascript/vehicle_journeys/components/Filters.js
index ae3ab3476..93fe015a8 100644
--- a/app/javascript/vehicle_journeys/components/Filters.js
+++ b/app/javascript/vehicle_journeys/components/Filters.js
@@ -145,12 +145,12 @@ export default function Filters({filters, pagination, missions, onFilter, onRese
<span
className='btn btn-link'
onClick={(e) => onResetFilters(e, pagination)}>
- Effacer
+ {I18n.t('actions.erase')}
</span>
<span
className='btn btn-default'
onClick={(e) => onFilter(e, pagination)}>
- Filtrer
+ {I18n.t('actions.filter')}
</span>
</div>
</div>
diff --git a/app/javascript/vehicle_journeys/components/tools/CustomFieldsInputs.js b/app/javascript/vehicle_journeys/components/tools/CustomFieldsInputs.js
index 90d72a801..827c36b76 100644
--- a/app/javascript/vehicle_journeys/components/tools/CustomFieldsInputs.js
+++ b/app/javascript/vehicle_journeys/components/tools/CustomFieldsInputs.js
@@ -27,6 +27,19 @@ export default class CustomFieldsInputs extends Component {
)
}
+ stringInput(cf){
+ return(
+ <input
+ type='text'
+ ref={'custom_fields.' + cf.code}
+ className='form-control'
+ disabled={this.props.disabled}
+ defaultValue={cf.value}
+ onChange={(e) => this.props.onUpdate(cf.code, e.target.value) }
+ />
+ )
+ }
+
render() {
return (
<div>
diff --git a/app/javascript/vehicle_journeys/components/tools/TimetablesEditVehicleJourney.js b/app/javascript/vehicle_journeys/components/tools/TimetablesEditVehicleJourney.js
index 7a2686c13..9ee2e1849 100644
--- a/app/javascript/vehicle_journeys/components/tools/TimetablesEditVehicleJourney.js
+++ b/app/javascript/vehicle_journeys/components/tools/TimetablesEditVehicleJourney.js
@@ -58,7 +58,7 @@ export default class TimetablesEditVehicleJourney extends Component {
<div className='wrapper'>
<div>
<div className='form-group'>
- <label className='control-label'>{this.props.modal.modalProps.timetables.length == 0 ? I18n.t('vehicle_journeys.vehicle_journeys_matrix.no_associated_timetables'): I18n.t('vehicle_journeys.form.timetables')}</label>
+ <label className='control-label'>{this.props.modal.modalProps.timetables.length == 0 ? I18n.t('vehicle_journeys.vehicle_journeys_matrix.no_associated_timetables'): I18n.t('vehicle_journeys.form.time_tables')}</label>
</div>
</div>
<div></div>
diff --git a/app/javascript/vehicle_journeys/components/tools/select2s/CompanySelect2.js b/app/javascript/vehicle_journeys/components/tools/select2s/CompanySelect2.js
index b7e9691c1..60ad439b8 100644
--- a/app/javascript/vehicle_journeys/components/tools/select2s/CompanySelect2.js
+++ b/app/javascript/vehicle_journeys/components/tools/select2s/CompanySelect2.js
@@ -31,7 +31,7 @@ export default class BSelect4 extends Component {
theme: 'bootstrap',
width: '100%',
placeholder: I18n.t('vehicle_journeys.vehicle_journeys_matrix.affect_company'),
- language: require('./fr'),
+ language: require('./language'),
ajax: {
url: origin + path + '/companies.json' + '?line_id=' + line,
dataType: 'json',
diff --git a/app/javascript/vehicle_journeys/components/tools/select2s/MissionSelect2.js b/app/javascript/vehicle_journeys/components/tools/select2s/MissionSelect2.js
index 96b34125d..cec39ab4e 100644
--- a/app/javascript/vehicle_journeys/components/tools/select2s/MissionSelect2.js
+++ b/app/javascript/vehicle_journeys/components/tools/select2s/MissionSelect2.js
@@ -75,7 +75,7 @@ export default class BSelect4 extends Component {
escapeMarkup: function (markup) { return markup; },
templateResult: formatRepo,
placeholder: I18n.t('vehicle_journeys.vehicle_journeys_matrix.filters.journey_pattern'),
- language: require('./fr'),
+ language: require('./language'),
allowClear: false,
escapeMarkup: function (markup) { return markup; },
}
diff --git a/app/javascript/vehicle_journeys/components/tools/select2s/TimetableSelect2.js b/app/javascript/vehicle_journeys/components/tools/select2s/TimetableSelect2.js
index 9a345b464..d5aad20d0 100644
--- a/app/javascript/vehicle_journeys/components/tools/select2s/TimetableSelect2.js
+++ b/app/javascript/vehicle_journeys/components/tools/select2s/TimetableSelect2.js
@@ -27,7 +27,7 @@ export default class BSelect4 extends Component {
theme: 'bootstrap',
width: '100%',
placeholder: I18n.t('vehicle_journeys.vehicle_journeys_matrix.filters.timetable'),
- language: require('./fr'),
+ language: require('./language'),
ajax: {
url: origin + path + this.props.chunkURL,
dataType: 'json',
diff --git a/app/javascript/vehicle_journeys/components/tools/select2s/VJSelect2.js b/app/javascript/vehicle_journeys/components/tools/select2s/VJSelect2.js
index f5881cef7..50a941b6d 100644
--- a/app/javascript/vehicle_journeys/components/tools/select2s/VJSelect2.js
+++ b/app/javascript/vehicle_journeys/components/tools/select2s/VJSelect2.js
@@ -27,7 +27,7 @@ export default class BSelect4b extends Component {
theme: 'bootstrap',
placeholder: I18n.t('vehicle_journeys.vehicle_journeys_matrix.filters.id'),
width: '100%',
- language: require('./fr'),
+ language: require('./language'),
ajax: {
url: origin + path + '/vehicle_journeys.json',
dataType: 'json',
diff --git a/app/javascript/vehicle_journeys/components/tools/select2s/fr.js b/app/javascript/vehicle_journeys/components/tools/select2s/fr.js
deleted file mode 100644
index 20154d412..000000000
--- a/app/javascript/vehicle_journeys/components/tools/select2s/fr.js
+++ /dev/null
@@ -1,9 +0,0 @@
-module.exports = {
- errorLoading:function(){return"Les résultats ne peuvent pas être chargés."},
- inputTooLong:function(e){var t=e.input.length-e.maximum,n="Supprimez "+t+" caractère";return t!==1&&(n+="s"),n},
- inputTooShort:function(e){var t=e.minimum-e.input.length,n="Saisissez "+t+" caractère";return t!==1&&(n+="s"),n},
- loadingMore:function(){return"Chargement de résultats supplémentaires…"},
- maximumSelected:function(e){var t="Vous pouvez seulement sélectionner "+e.maximum+" élément";return e.maximum!==1&&(t+="s"),t},
- noResults:function(){return"Aucun résultat trouvé"},
- searching:function(){return"Recherche en cours…"}
-}
diff --git a/app/javascript/vehicle_journeys/components/tools/select2s/language.js b/app/javascript/vehicle_journeys/components/tools/select2s/language.js
new file mode 100644
index 000000000..9d587f96e
--- /dev/null
+++ b/app/javascript/vehicle_journeys/components/tools/select2s/language.js
@@ -0,0 +1,9 @@
+module.exports = {
+ errorLoading: () => I18n.t('select2.error_loading'),
+ inputTooLong: (e) => I18n.t('select2.input_too_short', { count: e.input.length - e.maximum}),
+ inputTooShort: (e) => I18n.t('select2.input_too_long', { count: e.minimum - e.input.length }),
+ loadingMore: () => I18n.t('select2.loading_more'),
+ maximumSelected: (e) => I18n.t('select2.maximum_selected', {count: e.maximum}),
+ noResults: () => I18n.t('select2.no_results'),
+ searching: () => I18n.t('select2.searching')
+}
diff --git a/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js b/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js
index 6524f8d6f..b02c19a69 100644
--- a/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js
+++ b/app/javascript/vehicle_journeys/reducers/vehicleJourneys.js
@@ -9,32 +9,35 @@ const vehicleJourney= (state = {}, action, keep) => {
return _.assign({}, state, {selected: false})
case 'ADD_VEHICLEJOURNEY':
let pristineVjasList = []
- let prevSp = action.stopPointsList[0]
+ let prevSp
let current_time = {
hour: 0,
minute: 0
}
let computeSchedule = false
- let userTZOffet = 0
+ let initTZOffet = 0
if(action.data["start_time.hour"] && action.data["start_time.hour"].value && action.data["start_time.hour"].value.length > 0 && action.data["start_time.minute"] && action.selectedJourneyPattern.full_schedule && action.selectedJourneyPattern.costs){
computeSchedule = true
- userTZOffet = action.data["tz_offset"] && parseInt(action.data["tz_offset"].value) || 0
- current_time.hour = parseInt(action.data["start_time.hour"].value) + parseInt(userTZOffet / 60)
+ initTZOffet = - action.stopPointsList[0].time_zone_offset / 60 || 0
+ current_time.hour = parseInt(action.data["start_time.hour"].value) + parseInt(initTZOffet / 60)
current_time.minute = 0
if(action.data["start_time.minute"].value){
- current_time.minute = parseInt(action.data["start_time.minute"].value) + (userTZOffet - 60 * parseInt(userTZOffet / 60))
+ current_time.minute = parseInt(action.data["start_time.minute"].value) + (initTZOffet - 60 * parseInt(initTZOffet / 60))
}
}
_.each(action.stopPointsList, (sp) =>{
let inJourney = false
let newVjas
if(computeSchedule){
- if(action.selectedJourneyPattern.costs[prevSp.stop_area_id + "-" + sp.stop_area_id]){
+ if(prevSp && 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)
current_time = actions.addMinutesToTime(current_time, delta)
prevSp = sp
inJourney = true
}
+ if(!prevSp){
+ prevSp = sp
+ }
let offsetHours = sp.time_zone_offset / 3600
let offsetminutes = sp.time_zone_offset/60 - 60*offsetHours
newVjas = {