aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/assets/stylesheets/components/_compliance_control_blocks.sass3
-rw-r--r--app/controllers/compliance_control_blocks_controller.rb8
-rw-r--r--app/controllers/lines_controller.rb4
-rw-r--r--app/javascript/helpers/polyfills.js4
-rw-r--r--app/javascript/journey_patterns/actions/index.js18
-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/actions/index.js7
-rw-r--r--app/javascript/routes/components/StopPoint.js4
-rw-r--r--app/javascript/routes/index.js5
-rw-r--r--app/javascript/routes/reducers/stopPoints.js9
-rw-r--r--app/javascript/time_tables/actions/index.js11
-rw-r--r--app/javascript/vehicle_journeys/actions/index.js23
-rw-r--r--app/views/compliance_control_blocks/_form.html.slim6
-rw-r--r--app/views/referential_companies/edit.html.slim5
-rw-r--r--config/webpacker.yml2
-rw-r--r--db/migrate/20180413082929_clean_lines_secondary_companies.rb5
-rw-r--r--package.json4
-rw-r--r--spec/controllers/lines_controller_spec.rb29
-rw-r--r--yarn.lock10
28 files changed, 145 insertions, 57 deletions
diff --git a/app/assets/stylesheets/components/_compliance_control_blocks.sass b/app/assets/stylesheets/components/_compliance_control_blocks.sass
new file mode 100644
index 000000000..46880075c
--- /dev/null
+++ b/app/assets/stylesheets/components/_compliance_control_blocks.sass
@@ -0,0 +1,3 @@
+#compliance_control_block_form
+ .condition-attributes-errors
+ margin-bottom: 20px
diff --git a/app/controllers/compliance_control_blocks_controller.rb b/app/controllers/compliance_control_blocks_controller.rb
index 1173a548a..0851e2800 100644
--- a/app/controllers/compliance_control_blocks_controller.rb
+++ b/app/controllers/compliance_control_blocks_controller.rb
@@ -4,14 +4,6 @@ class ComplianceControlBlocksController < ChouetteController
belongs_to :compliance_control_set
actions :all, :except => [:show, :index]
- after_action :display_errors, only: [:create, :update]
-
- def display_errors
- unless @compliance_control_block.errors[:condition_attributes].empty?
- flash[:error] = @compliance_control_block.errors[:condition_attributes].join(', ')
- end
- end
-
private
def compliance_control_block_params
diff --git a/app/controllers/lines_controller.rb b/app/controllers/lines_controller.rb
index ae8c9ed0c..cd8091252 100644
--- a/app/controllers/lines_controller.rb
+++ b/app/controllers/lines_controller.rb
@@ -122,7 +122,7 @@ class LinesController < ChouetteController
end
def line_params
- params.require(:line).permit(
+ out = params.require(:line).permit(
:transport_mode,
:network_id,
:company_id,
@@ -148,6 +148,8 @@ class LinesController < ChouetteController
:secondary_company_ids => [],
footnotes_attributes: [:code, :label, :_destroy, :id]
)
+ out[:secondary_company_ids] = (out[:secondary_company_ids] || []).select(&:present?)
+ out
end
# Fake ransack filter
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 ea54f4e05..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"
@@ -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/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/actions/index.js b/app/javascript/routes/actions/index.js
index 5fbf5bce9..13b2d60b2 100644
--- a/app/javascript/routes/actions/index.js
+++ b/app/javascript/routes/actions/index.js
@@ -56,12 +56,7 @@ const actions = {
unselectMarker: (index) => ({
type: 'UNSELECT_MARKER',
index
- }),
- defaultAttribute: (attribute, stopAreaKind) => {
- if (attribute !== '') return attribute
- if (stopAreaKind === undefined) return ''
- return stopAreaKind === "commercial" ? "normal" : "forbidden"
- }
+ })
}
module.exports = actions
diff --git a/app/javascript/routes/components/StopPoint.js b/app/javascript/routes/components/StopPoint.js
index 768d069c0..908e97263 100644
--- a/app/javascript/routes/components/StopPoint.js
+++ b/app/javascript/routes/components/StopPoint.js
@@ -19,14 +19,14 @@ export default function StopPoint(props, {I18n}) {
</div>
<div>
- <select className='form-control' value={defaultAttribute(props.value.for_boarding, props.value.stoparea_kind)} id="for_boarding" onChange={props.onSelectChange}>
+ <select className='form-control' value={props.value.for_boarding} id="for_boarding" onChange={props.onSelectChange}>
<option value="normal">{I18n.t('routes.edit.stop_point.boarding.normal')}</option>
<option value="forbidden">{I18n.t('routes.edit.stop_point.boarding.forbidden')}</option>
</select>
</div>
<div>
- <select className='form-control' value={defaultAttribute(props.value.for_alighting, props.value.stoparea_kind)} id="for_alighting" onChange={props.onSelectChange}>
+ <select className='form-control' value={props.value.for_alighting} id="for_alighting" onChange={props.onSelectChange}>
<option value="normal">{I18n.t('routes.edit.stop_point.alighting.normal')}</option>
<option value="forbidden">{I18n.t('routes.edit.stop_point.alighting.forbidden')}</option>
</select>
diff --git a/app/javascript/routes/index.js b/app/javascript/routes/index.js
index 3c7322953..fc99a3086 100644
--- a/app/javascript/routes/index.js
+++ b/app/javascript/routes/index.js
@@ -22,6 +22,7 @@ const getInitialState = () => {
let fancyText = v.name.replace("&#39;", "\'")
if(v.zip_code && v.city_name)
fancyText += ", " + v.zip_code + " " + v.city_name.replace("&#39;", "\'")
+ forAlightingAndBoarding = v.stoparea_kind === 'commercial' ? 'normal' : 'forbidden'
state.push({
stoppoint_id: v.stoppoint_id,
@@ -37,8 +38,8 @@ const getInitialState = () => {
name: v.name ? v.name.replace("&#39;", "\'") : '',
registration_number: v.registration_number,
text: fancyText,
- for_boarding: v.for_boarding || '',
- for_alighting: v.for_alighting || '',
+ for_boarding: v.for_boarding || forAlightingAndBoarding,
+ for_alighting: v.for_alighting || forAlightingAndBoarding,
longitude: v.longitude || 0,
latitude: v.latitude || 0,
comment: v.comment ? v.comment.replace("&#39;", "\'") : '',
diff --git a/app/javascript/routes/reducers/stopPoints.js b/app/javascript/routes/reducers/stopPoints.js
index ba183d002..54142338d 100644
--- a/app/javascript/routes/reducers/stopPoints.js
+++ b/app/javascript/routes/reducers/stopPoints.js
@@ -8,8 +8,8 @@ const stopPoint = (state = {}, action, length) => {
text: '',
index: length,
edit: true,
- for_boarding: '',
- for_alighting: '',
+ for_boarding: 'normal',
+ for_alighting: 'normal',
olMap: {
isOpened: false,
json: {}
@@ -61,6 +61,7 @@ const stopPoints = (state = [], action) => {
case 'UPDATE_INPUT_VALUE':
return state.map( (t, i) => {
if (i === action.index) {
+ let forAlightingAndBoarding = action.text.stoparea_kind === 'commercial' ? 'normal' : 'forbidden'
return _.assign(
{},
t,
@@ -77,7 +78,9 @@ const stopPoints = (state = [], action) => {
area_type: action.text.area_type,
city_name: action.text.city_name,
comment: action.text.comment,
- registration_number: action.text.registration_number
+ registration_number: action.text.registration_number,
+ for_alighting: forAlightingAndBoarding,
+ for_boarding: forAlightingAndBoarding
}
)
} else {
diff --git a/app/javascript/time_tables/actions/index.js b/app/javascript/time_tables/actions/index.js
index 7c79dfe52..a5c454a18 100644
--- a/app/javascript/time_tables/actions/index.js
+++ b/app/javascript/time_tables/actions/index.js
@@ -191,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
@@ -235,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
},
diff --git a/app/javascript/vehicle_journeys/actions/index.js b/app/javascript/vehicle_journeys/actions/index.js
index 537dcfc06..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 = {
@@ -339,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/views/compliance_control_blocks/_form.html.slim b/app/views/compliance_control_blocks/_form.html.slim
index 2e87a877e..e8ae63384 100644
--- a/app/views/compliance_control_blocks/_form.html.slim
+++ b/app/views/compliance_control_blocks/_form.html.slim
@@ -1,6 +1,12 @@
= simple_form_for [@compliance_control_set, @compliance_control_block], html: { class: 'form-horizontal', id: 'compliance_control_block_form' }, wrapper: :horizontal_form do |f|
.row
.col-lg-12
+ - if @compliance_control_block.errors.has_key? :condition_attributes
+ .row.condition-attributes-errors
+ .col-lg-12
+ .alert.alert-danger
+ - @compliance_control_block.errors[:condition_attributes].each do |msg|
+ p.small = "- #{msg}"
.form-group
= f.input :transport_mode, as: :select, collection: ComplianceControlBlock.sorted_transport_modes, label: t('activerecord.attributes.compliance_control_blocks.transport_mode'), label_method: lambda {|t| ("<span>" + t("enumerize.transport_mode.#{t}") + "</span>").html_safe }
= f.input :transport_submode, as: :select, collection: ComplianceControlBlock.sorted_transport_submodes, label: t('activerecord.attributes.compliance_control_blocks.transport_submode'), label_method: lambda {|t| ("<span>" + t("enumerize.transport_submode.#{t}") + "</span>").html_safe }
diff --git a/app/views/referential_companies/edit.html.slim b/app/views/referential_companies/edit.html.slim
index 95be64aa1..0c9fb1f87 100644
--- a/app/views/referential_companies/edit.html.slim
+++ b/app/views/referential_companies/edit.html.slim
@@ -1,5 +1,8 @@
- breadcrumb :referential_company, @referential, @company
- page_header_content_for @company
+
.page_content
.container-fluid
- = render 'form'
+ .row
+ .col-lg-8.col-lg-offset-2.col-md-8.col-md-offset-2.col-sm-10.col-sm-offset-1
+ = render 'form'
diff --git a/config/webpacker.yml b/config/webpacker.yml
index be1105bad..24a7e32dc 100644
--- a/config/webpacker.yml
+++ b/config/webpacker.yml
@@ -41,7 +41,7 @@ development:
public: localhost:3035
hmr: false
# Inline should be set to true if using HMR
- inline: true
+ inline: false
overlay: true
disable_host_check: true
use_local_ip: false
diff --git a/db/migrate/20180413082929_clean_lines_secondary_companies.rb b/db/migrate/20180413082929_clean_lines_secondary_companies.rb
new file mode 100644
index 000000000..4c5659e8f
--- /dev/null
+++ b/db/migrate/20180413082929_clean_lines_secondary_companies.rb
@@ -0,0 +1,5 @@
+class CleanLinesSecondaryCompanies < ActiveRecord::Migration
+ def up
+ Chouette::Line.where("secondary_company_ids = '{NULL}'").update_all secondary_company_ids: nil
+ end
+end
diff --git a/package.json b/package.json
index 262d80b97..ef956105c 100644
--- a/package.json
+++ b/package.json
@@ -11,8 +11,10 @@
"clean-webpack-plugin": "^0.1.18",
"coffee-loader": "^0.9.0",
"coffeescript": "1.12.7",
+ "es6-symbol": "^3.1.1",
"jquery": "3.2.1",
"lodash": "4.17.4",
+ "polyfill-array-includes": "^1.0.0",
"promise-polyfill": "7.0.0",
"prop-types": "^15.6.0",
"react": "16.2.0",
@@ -24,7 +26,7 @@
"redux-promise": "0.5.3",
"redux-thunk": "2.2.0",
"uglify-js": "3.3.2",
- "whatwg-fetch": "2.0.3"
+ "whatwg-fetch": "^2.0.4"
},
"license": "MIT",
"engines": {
diff --git a/spec/controllers/lines_controller_spec.rb b/spec/controllers/lines_controller_spec.rb
index 96f49bb36..78020484b 100644
--- a/spec/controllers/lines_controller_spec.rb
+++ b/spec/controllers/lines_controller_spec.rb
@@ -1,9 +1,36 @@
RSpec.describe LinesController, :type => :controller do
login_user
- let(:line_referential) { create :line_referential, member: @user.organisation }
+ let(:line_referential) { create :line_referential, member: @user.organisation, objectid_format: :netex }
let(:line) { create :line, line_referential: line_referential }
+ describe 'POST create' do
+ let(:line_attrs){{
+ name: "test",
+ transport_mode: "bus"
+ }}
+ let(:request){ post :create, line_referential_id: line_referential.id, line: line_attrs }
+
+ with_permission "lines.create" do
+ it "should create a new line" do
+ expect{request}.to change{ line_referential.lines.count }.by 1
+ end
+
+ context "with an empty value in secondary_company_ids" do
+ let(:line_attrs){{
+ name: "test",
+ transport_mode: "bus",
+ secondary_company_ids: [""]
+ }}
+
+ it "should cleanup secondary_company_ids" do
+ expect{request}.to change{ line_referential.lines.count }.by 1
+ expect(line_referential.lines.last.secondary_company_ids).to eq []
+ end
+ end
+ end
+ end
+
describe 'PUT deactivate' do
let(:request){ put :deactivate, id: line.id, line_referential_id: line_referential.id }
diff --git a/yarn.lock b/yarn.lock
index b32d906dd..d0e8ff6a4 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -4719,6 +4719,10 @@ pn@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/pn/-/pn-1.1.0.tgz#e2f4cef0e219f463c179ab37463e4e1ecdccbafb"
+polyfill-array-includes@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/polyfill-array-includes/-/polyfill-array-includes-1.0.0.tgz#3dda070475859e99d653acf06ec3622cc76f8430"
+
portfinder@^1.0.9:
version "1.0.13"
resolved "https://registry.yarnpkg.com/portfinder/-/portfinder-1.0.13.tgz#bb32ecd87c27104ae6ee44b5a3ccbf0ebb1aede9"
@@ -6777,10 +6781,14 @@ whatwg-encoding@^1.0.1:
dependencies:
iconv-lite "0.4.13"
-whatwg-fetch@2.0.3, whatwg-fetch@>=0.10.0:
+whatwg-fetch@>=0.10.0:
version "2.0.3"
resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-2.0.3.tgz#9c84ec2dcf68187ff00bc64e1274b442176e1c84"
+whatwg-fetch@^2.0.4:
+ version "2.0.4"
+ resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-2.0.4.tgz#dde6a5df315f9d39991aa17621853d720b85566f"
+
whatwg-url@^6.3.0:
version "6.4.0"
resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-6.4.0.tgz#08fdf2b9e872783a7a1f6216260a1d66cc722e08"