aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/api/v1/routes_controller.rb4
-rw-r--r--app/controllers/routes_controller.rb2
-rw-r--r--app/helpers/routes_helper.rb6
-rw-r--r--app/inputs/search_stop_area_input.rb18
-rw-r--r--app/models/chouette/for_alighting_enumerations.rb2
-rw-r--r--app/models/chouette/route.rb64
-rw-r--r--app/models/concerns/route_restrictions.rb2
-rw-r--r--app/models/line_referential.rb2
-rw-r--r--app/views/api/kml/routes/show.kml.slim4
-rw-r--r--app/views/footnotes/_footnote_fields.html.slim2
-rw-r--r--app/views/lines/_form.html.slim8
-rw-r--r--app/views/referentials/show.html.slim4
-rw-r--r--app/views/routes/_form.html.slim6
-rw-r--r--app/views/routes/_route.html.slim8
-rw-r--r--app/views/routes/show.html.slim18
15 files changed, 55 insertions, 95 deletions
diff --git a/app/controllers/api/v1/routes_controller.rb b/app/controllers/api/v1/routes_controller.rb
index e3694725f..fbc589355 100644
--- a/app/controllers/api/v1/routes_controller.rb
+++ b/app/controllers/api/v1/routes_controller.rb
@@ -3,11 +3,11 @@ class Api::V1::RoutesController < Api::V1::ChouetteController
defaults :resource_class => Chouette::Route, :finder => :find_by_objectid!
belongs_to :line, :parent_class => Chouette::Line, :optional => true, :finder => :find_by_objectid!, :param => :line_id
-
+
protected
def collection
@routes ||= parent.routes
- end
+ end
end
diff --git a/app/controllers/routes_controller.rb b/app/controllers/routes_controller.rb
index 59c129867..a7e8e32a6 100644
--- a/app/controllers/routes_controller.rb
+++ b/app/controllers/routes_controller.rb
@@ -77,7 +77,7 @@ class RoutesController < ChouetteController
private
def route_params
- params.require(:route).permit( :direction_code, :wayback_code, :line_id, :objectid, :object_version, :creation_time, :creator_id, :name, :comment, :opposite_route_id, :published_name, :number, :direction, :wayback, { stop_points_attributes: [ :id, :_destroy, :position, :stop_area_id, :for_boarding, :for_alighting ] } )
+ params.require(:route).permit( :line_id, :objectid, :object_version, :creation_time, :creator_id, :name, :comment, :opposite_route_id, :published_name, :number, :direction, :wayback, { stop_points_attributes: [ :id, :_destroy, :position, :stop_area_id, :for_boarding, :for_alighting ] } )
end
end
diff --git a/app/helpers/routes_helper.rb b/app/helpers/routes_helper.rb
index b3d79262e..159c93054 100644
--- a/app/helpers/routes_helper.rb
+++ b/app/helpers/routes_helper.rb
@@ -6,11 +6,11 @@ module RoutesHelper
end
def fonticon_wayback(wayback)
- if wayback == "A"
+ if wayback == 'straight_forward'
return '<i class="fa fa-arrow-right"></i>'.html_safe
else
- return '<i class="fa fa-arrow-left"></i>'.html_safe
+ return '<i class="fa fa-arrow-left"></i>'.html_safe
end
end
-
+
end
diff --git a/app/inputs/search_stop_area_input.rb b/app/inputs/search_stop_area_input.rb
index e5cfafc34..c7e21e921 100644
--- a/app/inputs/search_stop_area_input.rb
+++ b/app/inputs/search_stop_area_input.rb
@@ -1,5 +1,5 @@
class SearchStopAreaInput < Formtastic::Inputs::SearchInput
-
+
def search
if options[:json]
tokenLimit = options[:tokenLimit].present? ? options[:tokenLimit] : "null"
@@ -16,19 +16,19 @@ class SearchStopAreaInput < Formtastic::Inputs::SearchInput
var item_localization = function( item){
var localization = item.zip_code + ' ' + item.short_city_name;
- return localization;
+ return localization;
};
- var item_format = function( item ){
- var name = item_name( item );
+ var item_format = function( item ){
+ var name = item_name( item );
var localization = item_localization( item );
-
+
html_result = '<li>';
html_result += '<span><image src=\"' + item.stop_area_path + '\" height=\"25px\" width=\"25px\"></span>'
if(name != '')
{
- html_result += '<span style=\"height:25px; line-height:25px; margin-left: 5px; \">' + name + '</span>' ;
- }
+ html_result += '<span style=\"height:25px; line-height:25px; margin-left: 5px; \">' + name + '</span>' ;
+ }
if(localization != '')
{
html_result += '<small style=\"height:25px; line-height:25px; margin-left: 10px; color: #555; \">' + localization + '</small>';
@@ -48,7 +48,7 @@ class SearchStopAreaInput < Formtastic::Inputs::SearchInput
noResultsText: '#{options[:no_result_text]}',
searchingText: '#{options[:searching_text]}',
resultsFormatter: item_format,
- tokenFormatter: item_format,
+ tokenFormatter: item_format,
});
});").html_safe)
end
@@ -62,7 +62,7 @@ class SearchStopAreaInput < Formtastic::Inputs::SearchInput
end
end
- def input_html_options
+ def input_html_options
css_class = super[:class]
super.merge({
:required => nil,
diff --git a/app/models/chouette/for_alighting_enumerations.rb b/app/models/chouette/for_alighting_enumerations.rb
index 4f34927d3..ab07a670d 100644
--- a/app/models/chouette/for_alighting_enumerations.rb
+++ b/app/models/chouette/for_alighting_enumerations.rb
@@ -2,7 +2,7 @@ module Chouette
module ForAlightingEnumerations
extend Enumerize
extend ActiveModel::Naming
-
+
enumerize :for_alighting, in: %w[normal forbidden request_stop is_flexible]
end
end
diff --git a/app/models/chouette/route.rb b/app/models/chouette/route.rb
index 8949a6bc2..446eb5f70 100644
--- a/app/models/chouette/route.rb
+++ b/app/models/chouette/route.rb
@@ -1,14 +1,17 @@
class Chouette::Route < Chouette::TridentActiveRecord
include RouteRestrictions
+ extend Enumerize
+ extend ActiveModel::Naming
+
+ enumerize :direction, in: %i(straight_forward backward clockwise counter_clockwise north north_west west south_west south south_east east north_east)
+ enumerize :wayback, in: %i(straight_forward backward)
+
# FIXME http://jira.codehaus.org/browse/JRUBY-6358
self.primary_key = "id"
- attr_accessor :wayback_code
- attr_accessor :direction_code
-
def self.nullable_attributes
- [:published_name, :comment, :number, :name]
+ [:published_name, :comment, :number, :name, :direction, :wayback]
end
belongs_to :line
@@ -61,8 +64,11 @@ class Chouette::Route < Chouette::TridentActiveRecord
# validates_presence_of :name
validates_presence_of :line
- # validates_presence_of :direction_code
- # validates_presence_of :wayback_code
+ # validates_presence_of :direction
+ # validates_presence_of :wayback
+
+ validates :direction, inclusion: { in: self.direction.values }
+ validates :wayback, inclusion: { in: self.wayback.values }
before_destroy :dereference_opposite_route
@@ -96,52 +102,6 @@ class Chouette::Route < Chouette::TridentActiveRecord
.order( "vehicle_journey_at_stops.departure_time")
end
- def self.direction_binding
- { "A" => "straight_forward",
- "R" => "backward",
- "ClockWise" => "clock_wise",
- "CounterClockWise" => "counter_clock_wise",
- "North" => "north",
- "NorthWest" => "north_west",
- "West" => "west",
- "SouthWest" => "south_west",
- "South" => "south",
- "SouthEast" => "south_east",
- "East" => "east",
- "NorthEast" => "north_east"}
- end
- def direction_code
- return nil if self.class.direction_binding[direction].nil?
- Chouette::Direction.new( self.class.direction_binding[direction])
- end
- def direction_code=(direction_code)
- self.direction = nil
- self.class.direction_binding.each do |k,v|
- self.direction = k if v==direction_code
- end
- end
- @@directions = nil
- def self.directions
- @@directions ||= Chouette::Direction.all
- end
- def self.wayback_binding
- { "A" => "straight_forward", "R" => "backward"}
- end
- def wayback_code
- return nil if self.class.wayback_binding[wayback].nil?
- Chouette::Wayback.new( self.class.wayback_binding[wayback])
- end
- def wayback_code=(wayback_code)
- self.wayback = nil
- self.class.wayback_binding.each do |k,v|
- self.wayback = k if v==wayback_code
- end
- end
- @@waybacks = nil
- def self.waybacks
- @@waybacks ||= Chouette::Wayback.all
- end
-
def stop_point_permutation?( stop_point_ids)
stop_points.map(&:id).map(&:to_s).sort == stop_point_ids.map(&:to_s).sort
end
diff --git a/app/models/concerns/route_restrictions.rb b/app/models/concerns/route_restrictions.rb
index 5a098d86f..4a21cbccf 100644
--- a/app/models/concerns/route_restrictions.rb
+++ b/app/models/concerns/route_restrictions.rb
@@ -8,7 +8,7 @@ module RouteRestrictions
# HUB-37
def wayback_code_limitation
return unless hub_restricted?
- errors.add( :wayback_code, I18n.t('hub.routes.wayback_code_exclusive')) if line.routes.reject {|r| r.id==id}.map(&:wayback_code).include?( wayback_code)
+ errors.add( :wayback, I18n.t('hub.routes.wayback_code_exclusive')) if line.routes.reject {|r| r.id==id}.map(&:wayback).include?( wayback)
end
# HUB-37
diff --git a/app/models/line_referential.rb b/app/models/line_referential.rb
index 7d3b638cb..e1f048fd8 100644
--- a/app/models/line_referential.rb
+++ b/app/models/line_referential.rb
@@ -6,7 +6,7 @@ class LineReferential < ActiveRecord::Base
has_many :group_of_lines, class_name: 'Chouette::GroupOfLine'
has_many :companies, class_name: 'Chouette::Company'
has_many :networks, class_name: 'Chouette::Network'
- has_many :line_referential_syncs, -> { order created_at: :desc}
+ has_many :line_referential_syncs, -> { order created_at: :desc }
has_many :workbenches
def add_member(organisation, options = {})
diff --git a/app/views/api/kml/routes/show.kml.slim b/app/views/api/kml/routes/show.kml.slim
index 3b08d81ce..51d2817c8 100644
--- a/app/views/api/kml/routes/show.kml.slim
+++ b/app/views/api/kml/routes/show.kml.slim
@@ -6,11 +6,11 @@ kml xmlns="http://www.opengis.net/kml/2.2"
placemark id="#{@route.objectid}"
name = h(@route.name)
extendeddata
- - [:direction_code, :wayback_code, :objectid, :object_version, :creation_time, :creator_id, :name, :comment, :published_name, :number, :direction, :wayback].each do |prop|
+ - [:direction, :wayback, :objectid, :object_version, :creation_time, :creator_id, :name, :comment, :published_name, :number, :direction_text, :wayback_text].each do |prop|
data name="#{prop.to_s}"
value = h(@route.send( prop))
data name="line_objectid"
value = h(@route.line.objectid)
- = @route.geometry_presenter.geometry.kml_representation.html_safe \ No newline at end of file
+ = @route.geometry_presenter.geometry.kml_representation.html_safe
diff --git a/app/views/footnotes/_footnote_fields.html.slim b/app/views/footnotes/_footnote_fields.html.slim
index ab006cfa9..c1944ed2d 100644
--- a/app/views/footnotes/_footnote_fields.html.slim
+++ b/app/views/footnotes/_footnote_fields.html.slim
@@ -1,4 +1,4 @@
= f.inputs :class => 'nested-fields footnote' do
= f.input :code, :wrapper_html => { class: 'col-md-3' }
= f.input :label, :wrapper_html => { class: 'col-md-7' }
- = link_to_remove_association t('actions.destroy'), f, class: 'col-md-2 remove' \ No newline at end of file
+ = link_to_remove_association t('actions.destroy'), f, class: 'col-md-2 remove'
diff --git a/app/views/lines/_form.html.slim b/app/views/lines/_form.html.slim
index 113a5c46c..ace0c4548 100644
--- a/app/views/lines/_form.html.slim
+++ b/app/views/lines/_form.html.slim
@@ -19,11 +19,11 @@
.footnotes_block
h3 = t("footnotes.index.title")
-
+
#footnotes
= form.semantic_fields_for :footnotes do |f|
= render "footnotes/footnote_fields", :f => f
-
+
.add_footnote
= link_to_add_association t("footnotes.actions.add_footnote"), form, :footnotes , :partial => "footnotes/footnote_fields", :"data-association-insertion-method" => "append", :"data-association-insertion-node" => "div#footnotes", class: 'add'
@@ -32,7 +32,7 @@
= form.action :cancel, as: :link
javascript:
- $(function() {
+ $(function() {
$("#line_group_of_line_tokens").tokenInput("#{name_filter_referential_group_of_lines_path(@line_referential, format: :json)}", {
crossDomain: false,
prePopulate: $('#group_of_line_tokens').data('pre'),
@@ -42,4 +42,4 @@ javascript:
noResultsText: "#{I18n.t('no_result_text')}",
searchingText: "#{I18n.t('searching_term')}"
});
- }); \ No newline at end of file
+ });
diff --git a/app/views/referentials/show.html.slim b/app/views/referentials/show.html.slim
index d5fed0344..044a745ec 100644
--- a/app/views/referentials/show.html.slim
+++ b/app/views/referentials/show.html.slim
@@ -44,7 +44,7 @@ h2
- if @referential.api_keys.present?
h3.api_keys = t('.api_keys')
-
+
.api_keys.paginated_content
= paginated_content(@referential.api_keys, "api_keys/api_key")
@@ -70,4 +70,4 @@ h2
h4 = t('.clean_up')
- == render 'clean' \ No newline at end of file
+ == render 'clean'
diff --git a/app/views/routes/_form.html.slim b/app/views/routes/_form.html.slim
index 329862955..d23188fa1 100644
--- a/app/views/routes/_form.html.slim
+++ b/app/views/routes/_form.html.slim
@@ -5,8 +5,8 @@
= form.input :number
= form.input :comment
= form.input :opposite_route, as: :select, :collection => @line.routes.select { |r| r.id != @route.id }
- = form.input :direction_code, as: :select, :collection => Chouette::Route.directions, :include_blank => false, :member_label => Proc.new { |mode| t("directions.label.#{mode}") }
- = form.input :wayback_code, as: :select, :collection => Chouette::Route.waybacks, :include_blank => false, :member_label => Proc.new { |mode| t("waybacks.label.#{mode}") }
+ = form.input :direction, :include_blank => false
+ = form.input :wayback, :include_blank => false
= form.input :objectid, :required => !@route.new_record?, :input_html => { :title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.route.objectid")}
#stop_points
@@ -88,4 +88,4 @@ javascript:
write_stop_point_ids();
order_position();
});
- }); \ No newline at end of file
+ });
diff --git a/app/views/routes/_route.html.slim b/app/views/routes/_route.html.slim
index fd740fa9b..5a377761f 100644
--- a/app/views/routes/_route.html.slim
+++ b/app/views/routes/_route.html.slim
@@ -11,9 +11,9 @@
h5
= link_to [@referential, @line, route], class: 'preview', title: "#{Chouette::Route.model_name.human.capitalize} #{route.name}" do
span.name
- - if route.wayback_code
+ - if route.wayback
= fonticon_wayback(route.wayback)
-
+
= truncate(route.name, length: 20)
.panel-body
@@ -38,6 +38,6 @@
p
- if !route.direction.blank?
- = "#{route.human_attribute_name('direction_code')} : #{t('directions.label.'+route.direction_code)}"
+ => "#{route.human_attribute_name('direction')} : #{route.direction_text}"
- else
- br \ No newline at end of file
+ br
diff --git a/app/views/routes/show.html.slim b/app/views/routes/show.html.slim
index a4e1aa90f..f71a01cef 100644
--- a/app/views/routes/show.html.slim
+++ b/app/views/routes/show.html.slim
@@ -21,16 +21,16 @@
= @route.comment
p
- label = "#{@route.human_attribute_name(:direction_code)} : "
- - if @route.direction_code
- = t("directions.label.#{@route.direction_code}").capitalize
+ label = "#{@route.human_attribute_name(:direction)} : "
+ - if @route.direction
+ = @route.direction_text
- else
= t(".undefined")
p
- label = "#{@route.human_attribute_name(:wayback_code)} : "
- - if @route.wayback_code
- = t("waybacks.label.#{@route.wayback_code}").capitalize
+ label = "#{@route.human_attribute_name(:wayback)} : "
+ - if @route.wayback
+ = @route.wayback_text
- else
= t(".undefined")
@@ -76,10 +76,10 @@ p.after_map
ul.actions
- if @route.stop_points.size >= 2
li = link_to t('journey_patterns.actions.new'), new_referential_line_route_journey_pattern_path(@referential, @line, @route), class: 'add'
-
+
- if @route.stop_points.present?
li = link_to t('routes.actions.edit_boarding_alighting'), edit_boarding_alighting_referential_line_route_path(@referential, @line, @route), class: 'edit'
-
+
- if @route.journey_patterns.size > 0
li = link_to t('vehicle_journeys.actions.index'), [@referential, @line, @route, :vehicle_journeys], class: 'clock'
@@ -87,4 +87,4 @@ p.after_map
li = link_to t('vehicle_journey_imports.new.title'), new_referential_line_route_vehicle_journey_import_path( @referential, @line, @route ), class: 'import'
li = link_to t('vehicle_journey_exports.new.title'), referential_line_route_vehicle_journey_exports_path(@referential, @line, @route, format: :zip), class: 'export'
- = creation_tag(@route) \ No newline at end of file
+ = creation_tag(@route)