aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuc Donnet2016-11-18 15:11:29 +0100
committerLuc Donnet2016-11-18 15:11:29 +0100
commit6827025a73a35788bbfb40d0ef20903cb62d27e3 (patch)
tree51d3aa6ce87496beb242377163aab6c41ca78bbe
parentd20a0e06b5df1645d311f8fbf7a7fb66cad3a869 (diff)
parent37e2519ca0e0131a5b7ea7c3c7bf16833b15703f (diff)
downloadchouette-core-6827025a73a35788bbfb40d0ef20903cb62d27e3.tar.bz2
Merge branch 'master' of github.com:AF83/stif-boiv
-rw-r--r--app/assets/javascripts/es6_browserified/components/App.js8
-rw-r--r--app/assets/javascripts/es6_browserified/components/BSelect2.js7
-rw-r--r--app/assets/javascripts/es6_browserified/components/Todo.js7
-rw-r--r--app/assets/javascripts/es6_browserified/components/TodoList.js7
-rw-r--r--app/assets/javascripts/es6_browserified/containers/AddTodo.js8
-rw-r--r--app/assets/javascripts/es6_browserified/containers/VisibleTodoList.js8
-rw-r--r--app/assets/javascripts/es6_browserified/form_helper.js2
-rw-r--r--app/assets/javascripts/es6_browserified/reducers/index.js6
-rw-r--r--app/assets/javascripts/es6_browserified/reducers/todos.js4
-rw-r--r--app/assets/javascripts/es6_browserified/stop_points.js14
-rw-r--r--app/assets/javascripts/select2.coffee2
-rw-r--r--app/assets/stylesheets/components/_select2.sass17
-rw-r--r--app/controllers/lines_controller.rb21
-rw-r--r--app/controllers/referential_lines_controller.rb21
-rw-r--r--app/models/chouette/line.rb9
-rw-r--r--app/models/line_referential.rb3
-rw-r--r--app/models/referential_metadata.rb4
-rw-r--r--app/models/workbench.rb2
-rw-r--r--app/views/referential_lines/show.html.slim25
-rw-r--r--app/views/referential_stop_areas/show.html.slim39
-rw-r--r--app/views/referentials/_form.html.slim17
-rw-r--r--app/views/referentials/show.html.slim19
-rw-r--r--app/views/shared/_lines_search_form.html.slim13
-rw-r--r--app/views/workbenches/_referential.html.slim8
-rw-r--r--app/views/workbenches/show.html.slim61
-rw-r--r--config/locales/enumerize.en.yml101
-rw-r--r--config/locales/enumerize.fr.yml101
-rw-r--r--config/locales/lines.en.yml2
-rw-r--r--config/locales/lines.fr.yml2
-rw-r--r--db/migrate/20161117104301_add_transport_submode_to_lines.rb5
-rw-r--r--db/schema.rb19
-rw-r--r--lib/stif/codif_line_synchronization.rb1
-rw-r--r--package.json22
-rw-r--r--spec/javascripts/reducers_spec.js178
-rw-r--r--spec/models/line_referential_spec.rb2
35 files changed, 618 insertions, 147 deletions
diff --git a/app/assets/javascripts/es6_browserified/components/App.js b/app/assets/javascripts/es6_browserified/components/App.js
index d41c97217..7488b0b39 100644
--- a/app/assets/javascripts/es6_browserified/components/App.js
+++ b/app/assets/javascripts/es6_browserified/components/App.js
@@ -1,6 +1,6 @@
-import React from 'react'
-import AddTodo from '../containers/AddTodo'
-import VisibleTodoList from '../containers/VisibleTodoList'
+var React = require('react')
+var AddTodo = require('../containers/AddTodo')
+var VisibleTodoList = require('../containers/VisibleTodoList')
const App = () => (
<div>
@@ -9,4 +9,4 @@ const App = () => (
</div>
)
-export default App
+module.exports = App
diff --git a/app/assets/javascripts/es6_browserified/components/BSelect2.js b/app/assets/javascripts/es6_browserified/components/BSelect2.js
index 6fe0f6307..a78dc625f 100644
--- a/app/assets/javascripts/es6_browserified/components/BSelect2.js
+++ b/app/assets/javascripts/es6_browserified/components/BSelect2.js
@@ -1,5 +1,6 @@
-import React, {PropTypes} from 'react'
-import Select2 from 'react-select2'
+var React = require('react')
+var PropTypes = require('react').PropTypes
+var Select2 = require('react-select2')
// get JSON full path
@@ -123,4 +124,4 @@ const formatRepo = (props) => {
// )
}
-export default BSelect3
+module.exports = BSelect3
diff --git a/app/assets/javascripts/es6_browserified/components/Todo.js b/app/assets/javascripts/es6_browserified/components/Todo.js
index b5313876e..bf60a405e 100644
--- a/app/assets/javascripts/es6_browserified/components/Todo.js
+++ b/app/assets/javascripts/es6_browserified/components/Todo.js
@@ -1,5 +1,6 @@
-import React, {PropTypes} from 'react'
-import BSelect2 from './BSelect2'
+var React = require('react')
+var PropTypes = require('react').PropTypes
+var BSelect2 = require('./BSelect2')
const Container = {display: 'table', tableLayout: 'fixed', width: '100%'}
const firstBlock = {display: 'table-cell', verticalAlign: 'middle', width: '55%'}
@@ -73,4 +74,4 @@ Todo.propTypes = {
value: PropTypes.object
}
-export default Todo
+module.exports = Todo
diff --git a/app/assets/javascripts/es6_browserified/components/TodoList.js b/app/assets/javascripts/es6_browserified/components/TodoList.js
index 03bd4dbf6..3ea2c90e1 100644
--- a/app/assets/javascripts/es6_browserified/components/TodoList.js
+++ b/app/assets/javascripts/es6_browserified/components/TodoList.js
@@ -1,5 +1,6 @@
-import React, {PropTypes} from 'react'
-import Todo from './Todo'
+var React = require('react')
+var PropTypes = require('react').PropTypes
+var Todo = require('./Todo')
const TodoList = ({ todos, onDeleteClick, onMoveUpClick, onMoveDownClick, onChange, onSelectChange }) => {
return (
@@ -32,4 +33,4 @@ TodoList.propTypes = {
onSelectChange: PropTypes.func.isRequired
}
-export default TodoList
+module.exports = TodoList
diff --git a/app/assets/javascripts/es6_browserified/containers/AddTodo.js b/app/assets/javascripts/es6_browserified/containers/AddTodo.js
index 857732333..98904ec21 100644
--- a/app/assets/javascripts/es6_browserified/containers/AddTodo.js
+++ b/app/assets/javascripts/es6_browserified/containers/AddTodo.js
@@ -1,6 +1,6 @@
-import React from 'react'
-import { connect } from 'react-redux'
-import actions from '../actions'
+var React = require('react')
+var connect = require('react-redux').connect
+var actions = require('../actions')
let AddTodo = ({ dispatch }) => {
return (
@@ -18,4 +18,4 @@ let AddTodo = ({ dispatch }) => {
}
AddTodo = connect()(AddTodo)
-export default AddTodo
+module.exports = AddTodo
diff --git a/app/assets/javascripts/es6_browserified/containers/VisibleTodoList.js b/app/assets/javascripts/es6_browserified/containers/VisibleTodoList.js
index a9b395279..464d6e482 100644
--- a/app/assets/javascripts/es6_browserified/containers/VisibleTodoList.js
+++ b/app/assets/javascripts/es6_browserified/containers/VisibleTodoList.js
@@ -1,6 +1,6 @@
-import actions from '../actions'
-import { connect } from 'react-redux'
-import TodoList from '../components/TodoList'
+var actions = require('../actions')
+var connect = require('react-redux').connect
+var TodoList = require('../components/TodoList')
const mapStateToProps = (state) => {
return {
@@ -33,4 +33,4 @@ const VisibleTodoList = connect(
mapDispatchToProps
)(TodoList)
-export default VisibleTodoList
+module.exports = VisibleTodoList
diff --git a/app/assets/javascripts/es6_browserified/form_helper.js b/app/assets/javascripts/es6_browserified/form_helper.js
index 140794886..d48718841 100644
--- a/app/assets/javascripts/es6_browserified/form_helper.js
+++ b/app/assets/javascripts/es6_browserified/form_helper.js
@@ -7,4 +7,4 @@ const addInput = (name, value, index) => {
form.appendChild(input)
}
-export default addInput
+module.exports = addInput
diff --git a/app/assets/javascripts/es6_browserified/reducers/index.js b/app/assets/javascripts/es6_browserified/reducers/index.js
index aee1799aa..381b32d8b 100644
--- a/app/assets/javascripts/es6_browserified/reducers/index.js
+++ b/app/assets/javascripts/es6_browserified/reducers/index.js
@@ -1,8 +1,8 @@
-import { combineReducers } from 'redux'
-import todos from './todos'
+var combineReducers = require('redux').combineReducers
+var todos = require('./todos')
const todoApp = combineReducers({
todos
})
-export default todoApp
+module.exports = todoApp
diff --git a/app/assets/javascripts/es6_browserified/reducers/todos.js b/app/assets/javascripts/es6_browserified/reducers/todos.js
index cbbb59c37..916cd4704 100644
--- a/app/assets/javascripts/es6_browserified/reducers/todos.js
+++ b/app/assets/javascripts/es6_browserified/reducers/todos.js
@@ -1,4 +1,4 @@
-import addInput from '../form_helper'
+var addInput = require('../form_helper')
const todo = (state = {}, action, length) => {
switch (action.type) {
@@ -82,4 +82,4 @@ const todos = (state = [], action) => {
}
}
-export default todos
+module.exports = todos
diff --git a/app/assets/javascripts/es6_browserified/stop_points.js b/app/assets/javascripts/es6_browserified/stop_points.js
index f3ac81906..f594c0da4 100644
--- a/app/assets/javascripts/es6_browserified/stop_points.js
+++ b/app/assets/javascripts/es6_browserified/stop_points.js
@@ -1,10 +1,10 @@
-import React from 'react'
-import { render } from 'react-dom'
-import { Provider } from 'react-redux'
-import { createStore } from 'redux'
-import todoApp from './reducers'
-import App from './components/App'
-import addInput from './form_helper'
+var React = require('react')
+var render = require('react-dom').render
+var Provider = require('react-redux').Provider
+var createStore = require('redux').createStore
+var todoApp = require('./reducers')
+var App = require('./components/App')
+var addInput = require('./form_helper')
// logger, DO NOT REMOVE
// var applyMiddleware = require('redux').applyMiddleware
diff --git a/app/assets/javascripts/select2.coffee b/app/assets/javascripts/select2.coffee
index 27528961a..edd4c476d 100644
--- a/app/assets/javascripts/select2.coffee
+++ b/app/assets/javascripts/select2.coffee
@@ -5,5 +5,7 @@
theme: 'bootstrap'
language: 'fr'
placeholder: target.data('select2ed-placeholder')
+ allowClear: true
+
$(document).on 'ready page:load', select_2
diff --git a/app/assets/stylesheets/components/_select2.sass b/app/assets/stylesheets/components/_select2.sass
new file mode 100644
index 000000000..b7fd2c6df
--- /dev/null
+++ b/app/assets/stylesheets/components/_select2.sass
@@ -0,0 +1,17 @@
+//-----------------------//
+// Select2 Customisation //
+//-----------------------//
+
+// With Font Awesome adjusts.
+
+.select2-selection__clear
+ font-size: 0
+ font-family: FontAwesome
+ text-rendering: auto
+ -webkit-font-smoothing: antialiased
+
+ &::before
+ content: '\f057'
+ display: inline
+ font-size: 14px
+ font-weight: normal
diff --git a/app/controllers/lines_controller.rb b/app/controllers/lines_controller.rb
index a93084012..1a5c30787 100644
--- a/app/controllers/lines_controller.rb
+++ b/app/controllers/lines_controller.rb
@@ -69,25 +69,16 @@ class LinesController < BreadcrumbController
end
def filtered_lines
- line_referential.lines.select{ |t| [t.name, t.published_name].find { |e| /#{params[:q]}/i =~ e } }
+ line_referential.lines.by_text(params[:q])
end
def collection
- if params[:q] && params[:q]["network_id_eq"] == "-1"
- params[:q]["network_id_eq"] = ""
- params[:q]["network_id_blank"] = "1"
+ %w(network_id company_id group_of_lines_id comment_id transport_mode_name).each do |filter|
+ if params[:q] && params[:q]["#{filter}_eq"] == '-1'
+ params[:q]["#{filter}_eq"] = ''
+ params[:q]["#{filter}_blank"] = '1'
+ end
end
-
- if params[:q] && params[:q]["company_id_eq"] == "-1"
- params[:q]["company_id_eq"] = ""
- params[:q]["company_id_blank"] = "1"
- end
-
- if params[:q] && params[:q]["group_of_lines_id_eq"] == "-1"
- params[:q]["group_of_lines_id_eq"] = ""
- params[:q]["group_of_lines_id_blank"] = "1"
- end
-
@q = line_referential.lines.search(params[:q])
@lines ||= @q.result(:distinct => true).order(:number).paginate(:page => params[:page]).includes([:network, :company])
end
diff --git a/app/controllers/referential_lines_controller.rb b/app/controllers/referential_lines_controller.rb
index 6a07e5093..c53819dd2 100644
--- a/app/controllers/referential_lines_controller.rb
+++ b/app/controllers/referential_lines_controller.rb
@@ -63,23 +63,15 @@ class ReferentialLinesController < ChouetteController
end
def filtered_lines
- referential.lines.select{ |t| [t.name, t.published_name].find { |e| /#{params[:q]}/i =~ e } }
+ referential.lines.by_text(params[:q])
end
def collection
- if params[:q] && params[:q]["network_id_eq"] == "-1"
- params[:q]["network_id_eq"] = ""
- params[:q]["network_id_blank"] = "1"
- end
-
- if params[:q] && params[:q]["company_id_eq"] == "-1"
- params[:q]["company_id_eq"] = ""
- params[:q]["company_id_blank"] = "1"
- end
-
- if params[:q] && params[:q]["group_of_lines_id_eq"] == "-1"
- params[:q]["group_of_lines_id_eq"] = ""
- params[:q]["group_of_lines_id_blank"] = "1"
+ %w(network_id company_id group_of_lines_id comment_id transport_mode_name).each do |filter|
+ if params[:q] && params[:q]["#{filter}_eq"] == '-1'
+ params[:q]["#{filter}_eq"] = ''
+ params[:q]["#{filter}_blank"] = '1'
+ end
end
@q = referential.lines.search(params[:q])
@@ -91,6 +83,7 @@ class ReferentialLinesController < ChouetteController
def line_params
params.require(:line).permit(
:transport_mode,
+ :transport_submode,
:network_id,
:company_id,
:objectid,
diff --git a/app/models/chouette/line.rb b/app/models/chouette/line.rb
index c3a867caa..b47f7d6f9 100644
--- a/app/models/chouette/line.rb
+++ b/app/models/chouette/line.rb
@@ -1,9 +1,13 @@
class Chouette::Line < Chouette::ActiveRecord
include DefaultNetexAttributesSupport
include LineRestrictions
-
include LineReferentialSupport
+ extend Enumerize
+ extend ActiveModel::Naming
+
+ enumerize :transport_submode, in: %i(unknown undefined internationalFlight domesticFlight intercontinentalFlight domesticScheduledFlight shuttleFlight intercontinentalCharterFlight internationalCharterFlight roundTripCharterFlight sightseeingFlight helicopterService domesticCharterFlight SchengenAreaFlight airshipService shortHaulInternationalFlight canalBarge localBus regionalBus expressBus nightBus postBus specialNeedsBus mobilityBus mobilityBusForRegisteredDisabled sightseeingBus shuttleBus highFrequencyBus dedicatedLaneBus schoolBus schoolAndPublicServiceBus railReplacementBus demandAndResponseBus airportLinkBus internationalCoach nationalCoach shuttleCoach regionalCoach specialCoach schoolCoach sightseeingCoach touristCoach commuterCoach metro tube urbanRailway local highSpeedRail suburbanRailway regionalRail interregionalRail longDistance intermational sleeperRailService nightRail carTransportRailService touristRailway railShuttle replacementRailService specialTrain crossCountryRail rackAndPinionRailway cityTram localTram regionalTram sightseeingTram shuttleTram trainTram internationalCarFerry nationalCarFerry regionalCarFerry localCarFerry internationalPassengerFerry nationalPassengerFerry regionalPassengerFerry localPassengerFerry postBoat trainFerry roadFerryLink airportBoatLink highSpeedVehicleService highSpeedPassengerService sightseeingService schoolBoat cableFerry riverBus scheduledFerry shuttleFerryService telecabin cableCar lift chairLift dragLift telecabinLink funicular streetCableCar allFunicularServices undefinedFunicular)
+
# FIXME http://jira.codehaus.org/browse/JRUBY-6358
self.primary_key = "id"
@@ -32,6 +36,9 @@ class Chouette::Line < Chouette::ActiveRecord
validates_presence_of :name
+ scope :by_text, ->(text) { where('lower(name) LIKE :t or lower(published_name) LIKE :t or lower(objectid) LIKE :t or lower(comment) LIKE :t or lower(number) LIKE :t',
+ t: "%#{text.downcase}%") }
+
def self.nullable_attributes
[:published_name, :number, :comment, :url, :color, :text_color, :stable_id]
end
diff --git a/app/models/line_referential.rb b/app/models/line_referential.rb
index 7096fd6ff..8bbc32993 100644
--- a/app/models/line_referential.rb
+++ b/app/models/line_referential.rb
@@ -1,7 +1,6 @@
class LineReferential < ActiveRecord::Base
has_many :line_referential_memberships
has_many :organisations, through: :line_referential_memberships
-
has_many :lines, class_name: 'Chouette::Line'
has_many :group_of_lines, class_name: 'Chouette::GroupOfLine'
has_many :companies, class_name: 'Chouette::Company'
@@ -28,6 +27,6 @@ class LineReferential < ActiveRecord::Base
end
def transport_modes
- Chouette::TransportMode.all.select { |tm| tm.positive? }
+ Chouette::TransportMode.all.select { |tm| tm.to_i > 0 }
end
end
diff --git a/app/models/referential_metadata.rb b/app/models/referential_metadata.rb
index 57ef9f7ca..5cd0ed22b 100644
--- a/app/models/referential_metadata.rb
+++ b/app/models/referential_metadata.rb
@@ -1,9 +1,11 @@
class ReferentialMetadata < ActiveRecord::Base
belongs_to :referential
belongs_to :referential_source, class_name: 'Referential'
-
has_array_of :lines, class_name: 'Chouette::Line'
+ scope :include_lines, -> (line_ids) { where('line_ids && ARRAY[?]', line_ids) }
+ scope :include_dateranges, -> (dateranges) { where('periodes && ARRAY[?]', dateranges) }
+
def self.new_from from
ReferentialMetadata.new({
referential_source: from.referential_source,
diff --git a/app/models/workbench.rb b/app/models/workbench.rb
index a83fea70d..b5ab37222 100644
--- a/app/models/workbench.rb
+++ b/app/models/workbench.rb
@@ -13,5 +13,5 @@ class Workbench < ActiveRecord::Base
validates :organisation, presence: true
has_many :referentials
-
+ has_many :referential_metadatas, through: :referentials
end
diff --git a/app/views/referential_lines/show.html.slim b/app/views/referential_lines/show.html.slim
index 4c439d08a..a479cd580 100644
--- a/app/views/referential_lines/show.html.slim
+++ b/app/views/referential_lines/show.html.slim
@@ -1,7 +1,10 @@
- text_color = @line.text_color.blank? ? "black" : "##{@line.text_color}"
- bg_color = @line.color.blank? ? "white" : "##{@line.color}"
-= title_tag t('lines.show.title', line: @line.name)
+h2
+ = t('lines.show.title', line: @line.name)
+ - if @line.deactivated?
+ small = " (désactivé)"
.line_show
= @map.to_html
@@ -45,6 +48,10 @@
p
label = "#{@line.human_attribute_name('transport_mode')} : "
= t("transport_modes.label.#{@line.transport_mode}")
+
+ p
+ label = "#{@line.human_attribute_name('transport_submode')} : "
+ = t("enumerize.linereferential.transport_submode.#{@line.transport_submode}")
p
label = "#{@line.human_attribute_name('stable_id')} : "
@@ -56,14 +63,14 @@
/ p
/ label = "#{@line.human_attribute_name('mobility_restricted_suitability')} : "
- /
+ /
/ - if @line.mobility_restricted_suitability.nil?
/ = @line.human_attribute_name("unspecified_mrs")
/ - elsif @line.mobility_restricted_suitability?
/ = @line.human_attribute_name("accessible")
/ - else
/ = @line.human_attribute_name("not_accessible")
- /
+ /
/ br
/ = "#{@line.human_attribute_name('number_of_mrs_vj')} : #{@line.vehicle_journeys.where('mobility_restricted_suitability = ?', true).count}"
/ br
@@ -71,29 +78,29 @@
/ br
/ = "#{@line.human_attribute_name('number_of_null_mrs_vj')} : "
/ = @line.vehicle_journeys.count - (@line.vehicle_journeys.where("mobility_restricted_suitability = ?", true).count + @line.vehicle_journeys.where("mobility_restricted_suitability = ?", false).count)
- /
+ /
/ p
/ label = "#{@line.human_attribute_name('flexible_service')} : "
- /
+ /
/ - if @line.flexible_service.nil?
/ = @line.human_attribute_name("unspecified_fs")
/ - elsif @line.flexible_service?
/ = @line.human_attribute_name("on_demaond_fs")
/ - else
/ = @line.human_attribute_name("regular_fs")
- /
+ /
/ br
/ = "#{@line.human_attribute_name('number_of_fs_vj')} : #{@line.vehicle_journeys.where('flexible_service = ?', true).count}"
/ br
/ = "#{@line.human_attribute_name('number_of_non_fs_vj')} : #{@line.vehicle_journeys.where('flexible_service = ?', false).count}"
/ br
/ = @line.human_attribute_name("number_of_null_fs_vj")
- /
+ /
/ - if @line.flexible_service.nil?
/ = "(#{@line.human_attribute_name('default_fs_msg')})"
- /
+ /
/ = ": #{@line.vehicle_journeys.count - (@line.vehicle_journeys.where('flexible_service = ?', true).count + @line.vehicle_journeys.where('flexible_service = ?', false).count)}"
- /
+ /
/ p
/ label = "#{@line.human_attribute_name('footnotes')} : "
/ ul
diff --git a/app/views/referential_stop_areas/show.html.slim b/app/views/referential_stop_areas/show.html.slim
index 2278c4812..c1475723d 100644
--- a/app/views/referential_stop_areas/show.html.slim
+++ b/app/views/referential_stop_areas/show.html.slim
@@ -6,47 +6,52 @@
.summary
p
label = "#{@stop_area.human_attribute_name('comment')} : "
- = @stop_area.comment
+ = " #{@stop_area.comment}"
p
label = "#{@stop_area.human_attribute_name('nearest_topic_name')} : "
- = @stop_area.nearest_topic_name
+ = " #{@stop_area.nearest_topic_name}"
p
label = "#{@stop_area.human_attribute_name('street_name')} : "
- = @stop_area.street_name
+ = " #{@stop_area.street_name}"
p
label = "#{@stop_area.human_attribute_name('country_code')} : "
- = @stop_area.country_code
+ = " #{@stop_area.country_code}"
p
label = "#{@stop_area.human_attribute_name('zip_code')} : "
- = @stop_area.zip_code
+ = " #{@stop_area.zip_code}"
p
label = "#{@stop_area.human_attribute_name('city_name')} : "
- = @stop_area.city_name
+ = " #{@stop_area.city_name}"
p
label = "#{@stop_area.human_attribute_name('fare_code')} : "
- = @stop_area.fare_code
+ = " #{@stop_area.fare_code}"
p
label = "#{@stop_area.human_attribute_name('time_zone')} : "
- = @stop_area.time_zone
+ = " #{@stop_area.time_zone}"
p
label = "#{@stop_area.human_attribute_name('url')} : "
- = @stop_area.url
+ = " #{@stop_area.url}"
p
label = "#{@stop_area.human_attribute_name('registration_number')} : "
- = @stop_area.registration_number
+ = " #{@stop_area.registration_number}"
+
+ - if @stop_area.deleted_at
+ p
+ label = "#{@stop_area.human_attribute_name('deleted_at')} : "
+ = " #{l @stop_area.deleted_at, format: :long}"
p
label = "#{@stop_area.human_attribute_name('stop_area_type')} : "
- = t("area_types.label.#{@stop_area.stop_area_type}")
+ = " " + t("area_types.label.#{@stop_area.stop_area_type}")
i.fa.fa-info-circle data-toggle="tooltip" data-placement="right" title="#{t('.not_editable')}"
@@ -55,24 +60,24 @@
label = "#{@stop_area.human_attribute_name('mobility_restricted_suitability')} : "
- if !@stop_area.mobility_restricted_suitability.nil?
- = t((@stop_area.mobility_restricted_suitability == true).to_s)
+ = " #{t((@stop_area.mobility_restricted_suitability == true).to_s)}"
- else
- = t('unknown')
+ = " #{t('unknown')}"
p
label = "#{@stop_area.human_attribute_name('stairs_availability')} : "
- if !@stop_area.stairs_availability.nil?
- = t((@stop_area.stairs_availability == true).to_s)
+ = " #{t((@stop_area.stairs_availability == true).to_s)}"
- else
- = t('unknown')
+ = " #{t('unknown')}"
p
label = "#{@stop_area.human_attribute_name('lift_availability')} : "
- if !@stop_area.lift_availability.nil?
- = t((@stop_area.lift_availability == true).to_s)
+ = " #{t((@stop_area.lift_availability == true).to_s)}"
- else
- = t('unknown')
+ = " #{t('unknown')}"
p
label = t('stop_areas.show.geographic_data')
diff --git a/app/views/referentials/_form.html.slim b/app/views/referentials/_form.html.slim
index ce53c2ede..1a0d5f105 100644
--- a/app/views/referentials/_form.html.slim
+++ b/app/views/referentials/_form.html.slim
@@ -1,13 +1,21 @@
= semantic_form_for @referential, class: 'form-horizontal' do |form|
= form.inputs do
= form.input :name
-
+
- if @referential.new_record?
+ - if @referential.created_from
+ = form.input :created_from
+
= form.input :slug, :input_html => { title: t("formtastic.titles.referential.slug") }
- else
li.input
label.label = @referential.human_attribute_name('slug')
= @referential.slug
+
+ - if @referential.created_from
+ li.input
+ label.label = @referential.human_attribute_name('created_from')
+ = @referential.created_from.name
= form.input :prefix, input_html: { title: t("formtastic.titles.referential.prefix") }
= form.input :projection_type, as: :select, :collection => Referential.available_srids
@@ -15,12 +23,7 @@
= form.input :upper_corner, input_html: { title: t("formtastic.titles.referential.upper_corner") }
= form.input :lower_corner, input_html: { title: t("formtastic.titles.referential.lower_corner") }
= form.input :data_format, label: true, include_blank: false
- - if @referential.created_from
- = form.input :created_from
-
- = form.inputs for: [:referential_metadatas, @referential.referential_metadatas] do |meta|
- = meta.inputs :referential_source
-
+
= form.actions do
= form.action :submit, as: :button
= form.action :cancel, as: :link
diff --git a/app/views/referentials/show.html.slim b/app/views/referentials/show.html.slim
index 1fc8f108f..56d7bd728 100644
--- a/app/views/referentials/show.html.slim
+++ b/app/views/referentials/show.html.slim
@@ -3,33 +3,38 @@ h2
em.small = " (archivé)" if @referential.archived?
.summary
+ - if @referential.created_from
+ p
+ label = "#{Referential.human_attribute_name('created_from')} : "
+ = " #{@referential.created_from.name}"
+
p
label = "#{Referential.human_attribute_name('slug')} : "
- = @referential.slug
+ = " #{@referential.slug}"
p
label = "#{Referential.human_attribute_name('prefix')} : "
- = @referential.prefix
+ = " #{@referential.prefix}"
p
label = "#{Referential.human_attribute_name('projection_type')} : "
- if !@referential.projection_type_label.empty?
- = "#{@referential.projection_type_label} (epsg:#{@referential.projection_type})"
+ = " #{@referential.projection_type_label} (epsg:#{@referential.projection_type})"
p
label = "#{Referential.human_attribute_name('time_zone').capitalize} : "
- = @referential.time_zone
+ = " #{@referential.time_zone}"
p
label = "#{Referential.human_attribute_name('data_format_restrictions')} : "
- = @referential.data_format
+ = " #{@referential.data_format}"
p
label = "#{Referential.human_attribute_name('validity_period')} : "
- if Chouette::TimeTable.start_validity_period.nil?
- = Referential.human_attribute_name("no_validity_period")
+ = " #{Referential.human_attribute_name('no_validity_period')}"
- else
- = Referential.human_attribute_name("start_validity_period")
+ = " #{Referential.human_attribute_name('start_validity_period')}"
= l Chouette::TimeTable.start_validity_period
= Referential.human_attribute_name("end_validity_period")
= l Chouette::TimeTable.end_validity_period
diff --git a/app/views/shared/_lines_search_form.html.slim b/app/views/shared/_lines_search_form.html.slim
index 685325bdc..30cdb1483 100644
--- a/app/views/shared/_lines_search_form.html.slim
+++ b/app/views/shared/_lines_search_form.html.slim
@@ -2,7 +2,7 @@
= search_form_for @q, url: eval("#{referential_type}_lines_path(referential)"), remote: true, html: { method: :get, class: 'form-inline', id: 'search', role: 'form' } do |f|
.panel.panel-default
.panel-heading
- .input-group.col-lg-9.col-md-9
+ .input-group.col-md-9
= f.search_field :name_or_number_or_objectid_or_comment_cont, placeholder: t('lines.index.name_or_number_or_objectid_or_comment'), class: 'form-control'
.input-group-btn
button.btn.btn-primary type='submit'
@@ -15,7 +15,10 @@
#advanced_search.panel-collapse.collapse
.panel-body
.row
- - %w(networks companies group_of_lines).each do |filter|
- - if referential&.send(filter).any?
- .col-lg-4.col-md-4.col-sm-4.col-xs-4
- = f.select(:"#{filter.singularize unless filter == 'group_of_lines'}_id_eq", referential.send(filter).collect { |f| [f.name, f.id] }.unshift([t("lines.index.no_#{filter}"), -1]), { include_blank: '' }, { class: 'form-control', style: 'width: 100%', 'data-select2ed': 'true', 'data-select2ed-placeholder': t("lines.index.all_#{filter}") })
+ - %w(networks companies group_of_lines transport_modes).each do |filter|
+ - options_container = (referential_type == 'referential' && filter == 'transport_modes') ? referential.line_referential : referential
+ - if options_container && options_container.send(filter).any?
+ - options = options_container.send(filter).collect { |f| [f.name, filter == 'transport_modes' ? f.name : f.id] }.unshift([t("lines.index.no_#{filter}"), -1])
+ - matcher = filter == 'transport_modes' ? :transport_mode_name_eq : :"#{filter == 'group_of_lines' ? filter : filter.singularize}_id_eq"
+ .col-xs-3
+ = f.select(matcher, options, { include_blank: '' }, { class: 'form-control', style: 'width: 100%', 'data-select2ed': 'true', 'data-select2ed-placeholder': t("lines.index.all_#{filter}") })
diff --git a/app/views/workbenches/_referential.html.slim b/app/views/workbenches/_referential.html.slim
index cc1964f30..7ea9c26f4 100644
--- a/app/views/workbenches/_referential.html.slim
+++ b/app/views/workbenches/_referential.html.slim
@@ -2,11 +2,11 @@
.panel-heading
.panel-title.clearfix
span.pull-right
- .btn-group
- = link_to edit_referential_path(referential), class: 'btn btn-default btn-sm' do
+ .btn-group.btn-group-sm
+ = link_to edit_referential_path(referential), class: 'btn btn-default' do
span.fa.fa-pencil
- = link_to referential_path(referential), method: :delete, :data => {:confirm => t('referentials.actions.destroy_confirm')}, class: 'btn btn-danger btn-sm' do
+ = link_to referential_path(referential), method: :delete, :data => {:confirm => t('referentials.actions.destroy_confirm')}, class: 'btn btn-danger' do
span.fa.fa-trash-o
h5
@@ -31,4 +31,4 @@
= "#{referential.human_attribute_name('time_tables')} : "
span.time_tables_count
-= javascript_include_tag referential_path(referential, format: :js) \ No newline at end of file
+= javascript_include_tag referential_path(referential, format: :js)
diff --git a/app/views/workbenches/show.html.slim b/app/views/workbenches/show.html.slim
index 49396a0e2..801714bc7 100644
--- a/app/views/workbenches/show.html.slim
+++ b/app/views/workbenches/show.html.slim
@@ -2,4 +2,63 @@
.referentials.paginated_content
h4 Liste des jeux de données
- = paginated_content @workbench.referentials
+
+ / = paginated_content @workbench.referentials
+
+ table.table.table-bordered.table-hover
+ thead
+ tr
+ th = Referential.human_attribute_name(:name)
+ th = Referential.human_attribute_name(:updated_at)
+ th = "Publié le"
+ th = Referential.human_attribute_name(:validity_period)
+ th = Referential.human_attribute_name(:lines)
+ th = Referential.human_attribute_name(:organisation)
+ th = "Etat"
+ th = "Actions"
+
+ tbody
+ - @workbench.referentials.each do |referential|
+ tr
+ td = referential.name
+ td = l referential.updated_at, format: :long
+ td
+ td
+ - if Chouette::TimeTable.start_validity_period.nil?
+ = "#{Referential.human_attribute_name('no_validity_period')}"
+ - else
+ = " #{Referential.human_attribute_name('start_validity_period')}"
+ = l Chouette::TimeTable.start_validity_period, format: :long
+ = Referential.human_attribute_name("end_validity_period")
+ = l Chouette::TimeTable.end_validity_period, format: :long
+
+ td = referential.lines.count
+ td = referential.organisation.name
+
+ / Status (archived?)
+ td.text-center
+ - if referential.archived?
+ span.fa.fa-archive title="Archivé"
+ - else
+ = "-"
+
+ / Actions
+ td.text-center
+ .btn-group.btn-group-xs
+ = link_to referential_path(referential), class: 'btn btn-default' do
+ span.fa.fa-eye
+
+ = link_to edit_referential_path(referential), class: 'btn btn-default' do
+ span.fa.fa-pencil
+
+ - if referential.archived?
+ = link_to unarchive_referential_path(referential), class: 'btn btn-default', method: :put do
+ span.fa-stack title="Désarchiver"
+ span.fa.fa-archive.fa-stack-1x
+ span.fa.fa-ban.fa-stack-2x
+ - else
+ = link_to archive_referential_path(referential), class: 'btn btn-default', method: :put do
+ span.fa.fa-archive title="Archiver"
+
+ = link_to referential_path(referential), method: :delete, :data => {:confirm => t('referentials.actions.destroy_confirm')}, class: 'btn btn-danger' do
+ span.fa.fa-trash-o
diff --git a/config/locales/enumerize.en.yml b/config/locales/enumerize.en.yml
index aab0bcf32..ed6c84efa 100644
--- a/config/locales/enumerize.en.yml
+++ b/config/locales/enumerize.en.yml
@@ -50,3 +50,104 @@ en:
wayback:
straight_forward: 'Straight Forward'
backward: 'Backward'
+
+ linereferential:
+ transport_submode:
+ unknown: 'Unknown'
+ undefined: 'Undefined'
+ internationalFlight: 'International flight'
+ domesticFlight: 'Domestic flight'
+ intercontinentalFlight: 'Intercontinental flight'
+ domesticScheduledFlight: 'Domestic scheduled flight'
+ shuttleFlight: 'Shuttle flight'
+ intercontinentalCharterFlight: "Intercontinental charter flight"
+ internationalCharterFlight: "International charter flight"
+ roundTripCharterFlight: "Roundtrip charter flight"
+ sightseeingFlight: 'Sightseeing flight'
+ helicopterService: "Helicopter service"
+ domesticCharterFlight: "Domestic charter flight"
+ SchengenAreaFlight: 'Schengen area flight'
+ airshipService: 'Airship service'
+ shortHaulInternationalFlight: 'Short haul international flight'
+ canalBarge: 'Canal barge'
+ localBus: 'Local bus'
+ regionalBus: 'Regional bus'
+ expressBus: 'Express bus'
+ nightBus: 'Night bus'
+ postBus: 'Post but'
+ specialNeedsBus: 'Special needs bus'
+ mobilityBus: 'Mobility bus'
+ mobilityBusForRegisteredDisabled: 'Mobility bus for registered disabled'
+ sightseeingBus: 'sightseeingBus'
+ shuttleBus: 'Shuttle bus'
+ highFrequencyBus: 'High frequency bus'
+ dedicatedLaneBus: 'Dedicated lane bus'
+ schoolBus: 'School bus'
+ schoolAndPublicServiceBus: 'School and public service bus'
+ railReplacementBus: 'Rail replacement bus'
+ demandAndResponseBus: 'Demand and response bus'
+ airportLinkBus: 'Airport link bus'
+ internationalCoach: 'International coach'
+ nationalCoach: 'National coach'
+ shuttleCoach: 'Shuttle coach'
+ regionalCoach: 'Regional coach'
+ specialCoach: 'Special coach'
+ schoolCoach: 'School coach'
+ sightseeingCoach: 'Sightseeing coach'
+ touristCoach: 'Tourist coach'
+ commuterCoach: 'Commuter coach'
+ metro: 'Metro'
+ tube: 'Tube'
+ urbanRailway: 'Urban railway'
+ local: 'Local'
+ highSpeedRail: 'High speed rail'
+ suburbanRailway: 'Suburban railway'
+ regionalRail: 'Regional rail'
+ interregionalRail: 'Interregional rail'
+ longDistance: 'Long distance'
+ international: 'International'
+ sleeperRailService: 'Sleeper rail service'
+ nightRail: 'Night rail'
+ carTransportRailService: 'Car transport rail service'
+ touristRailway: 'Tourist railway'
+ railShuttle: 'Rail shuttle'
+ replacementRailService: 'Replacement rail service'
+ specialTrain: 'Special train'
+ crossCountryRail: 'Cross country rail'
+ rackAndPinionRailway: 'Rack and pinion railway'
+ cityTram: 'City tram'
+ localTram: 'Local tram'
+ regionalTram: 'Regional tram'
+ sightseeingTram: 'Sightseeing tram'
+ shuttleTram: 'Shuttle tram'
+ trainTram: 'Train tram'
+ internationalCarFerry: 'International car ferry'
+ nationalCarFerry: 'National car ferry'
+ regionalCarFerry: 'Regional car ferry'
+ localCarFerry: 'Local car ferry'
+ internationalPassengerFerry: 'International passenger ferry'
+ nationalPassengerFerry: 'National passenger ferry'
+ regionalPassengerFerry: 'Regional passenger ferry'
+ localPassengerFerry: 'Local passenger ferry'
+ postBoat: 'Post boat'
+ trainFerry: 'Train ferry'
+ roadFerryLink: 'Road ferry link'
+ airportBoatLink: "Airport boat link"
+ highSpeedVehicleService: 'High speed vehicle service'
+ highSpeedPassengerService: 'High speed passenger service'
+ sightseeingService: 'Sightseeing service'
+ schoolBoat: 'School boat'
+ cableFerry: 'Cable ferry'
+ riverBus: 'River bus'
+ scheduledFerry: 'Scheduled ferry'
+ shuttleFerryService: 'Shuttle ferry service'
+ telecabin: 'Telecabin'
+ cableCar: 'Cable car'
+ lift: 'Lift'
+ chairLift: 'Chair lift'
+ dragLift: 'Drag lift'
+ telecabinLink: 'Telecabin link'
+ funicular: 'Funicular'
+ streetCableCar: 'Street cable car'
+ allFunicularServices: 'All funicular services'
+ undefinedFunicular: 'Undefined funicular'
diff --git a/config/locales/enumerize.fr.yml b/config/locales/enumerize.fr.yml
index b800521e3..e6eb1f13b 100644
--- a/config/locales/enumerize.fr.yml
+++ b/config/locales/enumerize.fr.yml
@@ -50,3 +50,104 @@ fr:
wayback:
straight_forward: 'Aller'
backward: 'Retour'
+
+ linereferential:
+ transport_submode:
+ unknown: 'Inconnu'
+ undefined: 'Non défini'
+ internationalFlight: 'Vol international'
+ domesticFlight: 'Vol intérieur'
+ intercontinentalFlight: 'Vol intercontinental'
+ domesticScheduledFlight: 'Vol intérieur régulier'
+ shuttleFlight: 'Vol de navette'
+ intercontinentalCharterFlight: "Vol 'charter' intercontinental"
+ internationalCharterFlight: "Vol 'charter' international"
+ roundTripCharterFlight: "Vol 'charter' aller/retour"
+ sightseeingFlight: 'Vol tourisme'
+ helicopterService: "Service d'hélicoptère"
+ domesticCharterFlight: "Vol 'charter' intérieur"
+ SchengenAreaFlight: 'Vol de zone Shengen'
+ airshipService: 'Service de dirigeable'
+ shortHaulInternationalFlight: 'Vol international à courte distance'
+ canalBarge: 'Péniche'
+ localBus: 'Bus local'
+ regionalBus: 'Bus régional'
+ expressBus: 'Bus express'
+ nightBus: 'Bus de nuit'
+ postBus: 'Bus postal'
+ specialNeedsBus: 'Bus de besoins spécial'
+ mobilityBus: 'Bus de mobilité'
+ mobilityBusForRegisteredDisabled: 'Bus de mobilité pour personnes handicapées'
+ sightseeingBus: 'Bus touristique'
+ shuttleBus: 'Bus navette'
+ highFrequencyBus: 'Bus à haute fréquence'
+ dedicatedLaneBus: 'Bus à voie réservée'
+ schoolBus: 'Bus scolaire'
+ schoolAndPublicServiceBus: 'Bus scolaire/service public'
+ railReplacementBus: 'Bus de remplacement de train'
+ demandAndResponseBus: 'Bus demande/réponse'
+ airportLinkBus: 'Bus de liaison aéroport'
+ internationalCoach: 'Autocar international'
+ nationalCoach: 'Autocar national'
+ shuttleCoach: 'Autocar navette'
+ regionalCoach: 'Autocar régional'
+ specialCoach: 'Autocar spécial'
+ schoolCoach: 'Autocar scolaire'
+ sightseeingCoach: 'Autocar touristique'
+ touristCoach: 'Autocar touristique (2)'
+ commuterCoach: 'Autocar de banlieue'
+ metro: 'Métro'
+ tube: 'Métro (2)'
+ urbanRailway: 'Train urbain'
+ local: 'Local'
+ highSpeedRail: 'Train à grande vitesse'
+ suburbanRailway: 'Train de banlieue'
+ regionalRail: 'Train régional'
+ interregionalRail: 'Train interrégional'
+ longDistance: 'Longue distance'
+ international: 'International'
+ sleeperRailService: 'Train à couchettes'
+ nightRail: 'Train de nuit'
+ carTransportRailService: 'Service ferroviaire de transport de voitures'
+ touristRailway: 'Train touristique'
+ railShuttle: 'Navette ferroviaire'
+ replacementRailService: 'Service de train de remplacement'
+ specialTrain: 'Train spécial'
+ crossCountryRail: 'Train de campagne'
+ rackAndPinionRailway: 'Train à crémaillère'
+ cityTram: 'Tramway de ville'
+ localTram: 'Tramway local'
+ regionalTram: 'Tramway régional'
+ sightseeingTram: 'Tramway touristique'
+ shuttleTram: 'Tramway navette'
+ trainTram: 'Train/tramway'
+ internationalCarFerry: 'Ferry international'
+ nationalCarFerry: 'Ferry national'
+ regionalCarFerry: 'Ferry régional'
+ localCarFerry: 'Ferry local'
+ internationalPassengerFerry: 'Traversier international à passagers'
+ nationalPassengerFerry: 'Traversier national à passagers'
+ regionalPassengerFerry: 'Traversier régional à passagers'
+ localPassengerFerry: 'Traversier local à passagers'
+ postBoat: 'Bateau de poste'
+ trainFerry: 'Navire transbordeur'
+ roadFerryLink: 'Liaison par navire transbordeur'
+ airportBoatLink: "Liaison maritime d'aéroport"
+ highSpeedVehicleService: 'Service de véhicule à grande vitesse'
+ highSpeedPassengerService: 'Service passager à grande vitesse'
+ sightseeingService: 'Service touristique'
+ schoolBoat: 'Bateau scolaire'
+ cableFerry: 'Traversier à câble'
+ riverBus: 'Bateau-bus'
+ scheduledFerry: 'Traversier régulier'
+ shuttleFerryService: 'Service de traversier-navette'
+ telecabin: 'Télécabine'
+ cableCar: 'Téléphérique'
+ lift: 'Ascenseur'
+ chairLift: 'Télésiège'
+ dragLift: 'Téléski'
+ telecabinLink: 'Liaison télécabine'
+ funicular: 'Funiculaire'
+ streetCableCar: 'Tramway (2)'
+ allFunicularServices: 'Tous services de funiculaire'
+ undefinedFunicular: 'Funiculaire non défini'
diff --git a/config/locales/lines.en.yml b/config/locales/lines.en.yml
index 84285bbcb..1ed57d79f 100644
--- a/config/locales/lines.en.yml
+++ b/config/locales/lines.en.yml
@@ -27,9 +27,11 @@ en:
no_networks: "No networks"
no_companies: "No companies"
no_group_of_lines: "No group of lines"
+ no_transport_mode: No transport mode
all_networks: "All networks"
all_companies: "All companies"
all_group_of_lines: "All group of lines"
+ all_transport_modes: All transport modes
multi_selection: "Multiple selection"
multi_selection_enable: "Enable multiple selection"
multi_selection_disable: "Disable multiple selection"
diff --git a/config/locales/lines.fr.yml b/config/locales/lines.fr.yml
index b5a13c34a..abd6696b4 100644
--- a/config/locales/lines.fr.yml
+++ b/config/locales/lines.fr.yml
@@ -27,9 +27,11 @@ fr:
no_networks: "Aucun réseaux"
no_companies: "Aucun transporteurs"
no_group_of_lines: "Aucun groupes de ligne"
+ no_transport_modes: Aucun mode de transport
all_networks: "Tous les réseaux"
all_companies: "Tous les transporteurs"
all_group_of_lines: "Tous les groupes de ligne"
+ all_transport_modes: Tous les modes de transport
multi_selection: "Sélection multiple"
multi_selection_enable: "Activer la sélection multiple"
multi_selection_disable: "Désactiver la sélection multiple"
diff --git a/db/migrate/20161117104301_add_transport_submode_to_lines.rb b/db/migrate/20161117104301_add_transport_submode_to_lines.rb
new file mode 100644
index 000000000..e652dc190
--- /dev/null
+++ b/db/migrate/20161117104301_add_transport_submode_to_lines.rb
@@ -0,0 +1,5 @@
+class AddTransportSubmodeToLines < ActiveRecord::Migration
+ def change
+ add_column :lines, :transport_submode, :string
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 035856060..12b08ac5e 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20161116130958) do
+ActiveRecord::Schema.define(version: 20161117104301) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -147,22 +147,6 @@ ActiveRecord::Schema.define(version: 20161116130958) do
add_index "connection_links", ["objectid"], :name => "connection_links_objectid_key", :unique => true
- create_table "delayed_jobs", force: true do |t|
- t.integer "priority", default: 0
- t.integer "attempts", default: 0
- t.text "handler"
- t.text "last_error"
- t.datetime "run_at"
- t.datetime "locked_at"
- t.datetime "failed_at"
- t.string "locked_by"
- t.string "queue"
- t.datetime "created_at"
- t.datetime "updated_at"
- end
-
- add_index "delayed_jobs", ["priority", "run_at"], :name => "delayed_jobs_priority"
-
create_table "exports", force: true do |t|
t.integer "referential_id", limit: 8
t.string "status"
@@ -348,6 +332,7 @@ ActiveRecord::Schema.define(version: 20161116130958) do
t.integer "line_referential_id"
t.boolean "deactivated", default: false
t.text "import_xml"
+ t.string "transport_submode"
end
add_index "lines", ["line_referential_id"], :name => "index_lines_on_line_referential_id"
diff --git a/lib/stif/codif_line_synchronization.rb b/lib/stif/codif_line_synchronization.rb
index d580ae3b8..deadad5ba 100644
--- a/lib/stif/codif_line_synchronization.rb
+++ b/lib/stif/codif_line_synchronization.rb
@@ -71,6 +71,7 @@ module Stif
import_xml: api_line.xml
}
+ params[:transport_submode] = api_line.transport_submode.to_s
unless api_line.operator_ref.nil?
params[:company] = Chouette::Company.find_by(objectid: api_line.operator_ref)
end
diff --git a/package.json b/package.json
index 99c7916c1..43f8c4c6a 100644
--- a/package.json
+++ b/package.json
@@ -1,17 +1,17 @@
{
"name": "something",
"dependencies": {
- "babel-polyfill": "^6.16.0",
- "babel-preset-es2015": "^6.18.0",
- "babel-preset-react": "^6.16.0",
- "babelify": "^7.3.0",
- "browserify": "^13.1.1",
- "browserify-incremental": "^3.1.1",
- "react": "^15.3.2",
- "react-dom": "^15.3.2",
- "react-redux": "^4.4.5",
- "react-select2": "^4.0.2",
- "redux": "^3.6.0"
+ "babel-polyfill": "6.16.0",
+ "babel-preset-es2015": "6.18.0",
+ "babel-preset-react": "6.16.0",
+ "babelify": "7.3.0",
+ "browserify": "13.1.1",
+ "browserify-incremental": "3.1.1",
+ "react": "15.3.2",
+ "react-dom": "15.3.2",
+ "react-redux": "4.4.5",
+ "react-select2": "4.0.2",
+ "redux": "3.6.0"
},
"license": "MIT",
"engines": {
diff --git a/spec/javascripts/reducers_spec.js b/spec/javascripts/reducers_spec.js
new file mode 100644
index 000000000..a4880e73e
--- /dev/null
+++ b/spec/javascripts/reducers_spec.js
@@ -0,0 +1,178 @@
+var reducer = require('es6_browserified/reducers/todos')
+let state = []
+describe('stops reducer', () => {
+ beforeEach(()=>{
+ state = [
+ {
+ text: 'first',
+ index: 0,
+ for_boarding: 'normal',
+ for_alighting: 'normal'
+ },
+ {
+ text: 'second',
+ index: 1,
+ for_boarding: 'normal',
+ for_alighting: 'normal'
+ }
+ ]
+ })
+
+ it('should return the initial state', () => {
+ expect(
+ reducer(undefined, {})
+ ).toEqual([])
+ })
+
+ it('should handle ADD_STOP', () => {
+ expect(
+ reducer(state, {
+ type: 'ADD_STOP'
+ })
+ ).toEqual(
+ [
+ {
+ text: 'first',
+ index: 0,
+ for_boarding: 'normal',
+ for_alighting: 'normal'
+ },
+ {
+ text: 'second',
+ index: 1,
+ for_boarding: 'normal',
+ for_alighting: 'normal'
+ },
+ {
+ text: '',
+ index: 2,
+ for_boarding: 'normal',
+ for_alighting: 'normal'
+ }
+ ]
+ )
+ })
+
+ it('should handle MOVE_UP_STOP', () => {
+ expect(
+ reducer(state, {
+ type: 'MOVE_STOP_UP',
+ index: 1
+ })
+ ).toEqual(
+ [
+ {
+ text: 'second',
+ index: 1,
+ for_boarding: 'normal',
+ for_alighting: 'normal'
+ },
+ {
+ text: 'first',
+ index: 0,
+ for_boarding: 'normal',
+ for_alighting: 'normal'
+ }
+ ]
+ )
+ })
+
+ it('should handle MOVE_DOWN_STOP', () => {
+ expect(
+ reducer(state, {
+ type: 'MOVE_STOP_DOWN',
+ index: 0
+ })
+ ).toEqual(
+ [
+ {
+ text: 'second',
+ index: 1,
+ for_boarding: 'normal',
+ for_alighting: 'normal'
+ },
+ {
+ text: 'first',
+ index: 0,
+ for_boarding: 'normal',
+ for_alighting: 'normal'
+ }
+ ]
+ )
+ })
+
+ it('should handle DELETE_STOP', () => {
+ expect(
+ reducer(state, {
+ type: 'DELETE_STOP',
+ index: 1
+ })
+ ).toEqual(
+ [
+ {
+ text: 'first',
+ index: 0,
+ for_boarding: 'normal',
+ for_alighting: 'normal'
+ }
+ ]
+ )
+ })
+
+ //TODO unskip when es6 is properly functionnal
+ xit('should handle UPDATE_INPUT_VALUE', () => {
+ expect(
+ reducer(state, {
+ type: 'UPDATE_INPUT_VALUE',
+ index: 0,
+ text: {
+ text: "new value",
+ stoparea_id: 1
+ }
+ })
+ ).toEqual(
+ [
+ {
+ text: 'new value',
+ index: 0,
+ stoparea_id: 1,
+ for_boarding: 'normal',
+ for_alighting: 'normal'
+ },
+ {
+ text: 'second',
+ index: 1,
+ for_boarding: 'normal',
+ for_alighting: 'normal'
+ }
+ ]
+ )
+ })
+
+ xit('should handle UPDATE_SELECT_VALUE', () => {
+ expect(
+ reducer(state, {
+ type :'UPDATE_SELECT_VALUE',
+ select_id: 'for_boarding',
+ select_value: 'prohibited',
+ index: 0
+ })
+ ).toEqual(
+ [
+ {
+ text: 'new value',
+ index: 0,
+ stoparea_id: 1,
+ for_boarding: 'prohibited',
+ for_alighting: 'normal'
+ },
+ {
+ text: 'second',
+ index: 1,
+ for_boarding: 'normal',
+ for_alighting: 'normal'
+ }
+ ]
+ )
+ })
+})
diff --git a/spec/models/line_referential_spec.rb b/spec/models/line_referential_spec.rb
index 942795076..8472faaa0 100644
--- a/spec/models/line_referential_spec.rb
+++ b/spec/models/line_referential_spec.rb
@@ -12,7 +12,7 @@ RSpec.describe LineReferential, :type => :model do
describe "#transport_modes" do
it 'returns a list of all transport modes' do
- expect(FactoryGirl.create(:line_referential).transport_modes).to eq( Chouette::TransportMode.all.select { |tm| tm.positive? } )
+ expect(FactoryGirl.create(:line_referential).transport_modes).to eq( Chouette::TransportMode.all.select { |tm| tm.to_i > 0 } )
end
end
end