diff options
| author | Luc Donnet | 2017-09-14 09:55:48 +0200 | 
|---|---|---|
| committer | Luc Donnet | 2017-09-14 09:55:48 +0200 | 
| commit | 2fa3be1518da4f471d614832f80526e074983195 (patch) | |
| tree | acbf2b8d95c3c572142d9c2b13f3704ce9db4304 | |
| parent | e11810f865239f5565c1b97c7e8da5f2b3108d29 (diff) | |
| download | chouette-core-2fa3be1518da4f471d614832f80526e074983195.tar.bz2 | |
Change wayback values in route Refs #3395 @4
| -rw-r--r-- | app/assets/javascripts/routes.coffee | 2 | ||||
| -rw-r--r-- | app/controllers/routes_controller.rb | 4 | ||||
| -rw-r--r-- | app/helpers/routes_helper.rb | 2 | ||||
| -rw-r--r-- | app/models/chouette/route.rb | 4 | ||||
| -rw-r--r-- | app/models/chouette/wayback.rb | 50 | ||||
| -rw-r--r-- | app/views/routes/_form.html.slim | 6 | ||||
| -rw-r--r-- | config/locales/enumerize.en.yml | 4 | ||||
| -rw-r--r-- | config/locales/enumerize.fr.yml | 12 | ||||
| -rw-r--r-- | config/locales/routes.en.yml | 3 | ||||
| -rw-r--r-- | config/locales/waybacks.en.yml | 4 | ||||
| -rw-r--r-- | config/locales/waybacks.fr.yml | 4 | ||||
| -rw-r--r-- | db/migrate/20170913074922_change_wayback_route_values.rb | 12 | ||||
| -rw-r--r-- | db/schema.rb | 2 | ||||
| -rw-r--r-- | spec/models/chouette/route/route_base_spec.rb | 4 | 
14 files changed, 36 insertions, 77 deletions
| diff --git a/app/assets/javascripts/routes.coffee b/app/assets/javascripts/routes.coffee index 2e36061b8..4492b381d 100644 --- a/app/assets/javascripts/routes.coffee +++ b/app/assets/javascripts/routes.coffee @@ -1,5 +1,5 @@  $(document).on("change", '#route_wayback', (e) -> -  way = if $(this).is(':checked') then "backward" else "straight_forward" +  way = if $(this).is(':checked') then "inbound" else "outbound"    $('.opposite_route').hide().find('select').prop('disabled', true)    field = $(".opposite_route.#{way}") diff --git a/app/controllers/routes_controller.rb b/app/controllers/routes_controller.rb index 04f63c112..78daffb30 100644 --- a/app/controllers/routes_controller.rb +++ b/app/controllers/routes_controller.rb @@ -94,8 +94,8 @@ class RoutesController < ChouetteController      else        parent.routes.where(opposite_route: nil)      end -    @forward  = scope.where(wayback: :straight_forward) -    @backward = scope.where(wayback: :backward) +    @forward  = scope.where(wayback: :outbound) +    @backward = scope.where(wayback: :inbound)    end    private diff --git a/app/helpers/routes_helper.rb b/app/helpers/routes_helper.rb index a8c9a1f0c..4bffa99d4 100644 --- a/app/helpers/routes_helper.rb +++ b/app/helpers/routes_helper.rb @@ -6,7 +6,7 @@ module RoutesHelper    end    def fonticon_wayback(wayback) -    if wayback == 'straight_forward' +    if wayback == 'outbound'        return '<i class="fa fa-arrow-right"></i>'.html_safe      else        return '<i class="fa fa-arrow-left"></i>'.html_safe diff --git a/app/models/chouette/route.rb b/app/models/chouette/route.rb index 49493d5b5..0bdccb36a 100644 --- a/app/models/chouette/route.rb +++ b/app/models/chouette/route.rb @@ -6,7 +6,7 @@ class Chouette::Route < Chouette::TridentActiveRecord    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), default: :straight_forward +  enumerize :wayback, in: %i(outbound inbound), default: :outbound    # FIXME http://jira.codehaus.org/browse/JRUBY-6358    self.primary_key = "id" @@ -106,7 +106,7 @@ class Chouette::Route < Chouette::TridentActiveRecord      Chouette::Geometry::RoutePresenter.new self    end -  @@opposite_waybacks = { straight_forward: :backward, backward: :straight_forward} +  @@opposite_waybacks = { outbound: :inbound, inbound: :outbound}    def opposite_wayback      @@opposite_waybacks[wayback.to_sym]    end diff --git a/app/models/chouette/wayback.rb b/app/models/chouette/wayback.rb deleted file mode 100644 index b2950449d..000000000 --- a/app/models/chouette/wayback.rb +++ /dev/null @@ -1,50 +0,0 @@ -class Chouette::Wayback < ActiveSupport::StringInquirer - -  def initialize(text_code, numerical_code) -    super text_code.to_s -    @numerical_code = numerical_code -  end - -  def self.new(text_code, numerical_code = nil) -    if text_code and numerical_code -      super -    elsif self === text_code  -      text_code -    else -      if Fixnum === text_code -        text_code, numerical_code = definitions.rassoc(text_code) -      else -        text_code, numerical_code = definitions.assoc(text_code.to_s) -      end - -      super text_code, numerical_code -    end -  end - -  def to_i -    @numerical_code -  end - -  def inspect -    "#{to_s}/#{to_i}" -  end - -  def name -    to_s -  end - -  @@definitions = [ -    ["straight_forward", 0], -    ["backward", 1] -  ] -  cattr_reader :definitions - -  @@all = nil -  def self.all -    @@all ||= definitions.collect do |text_code, numerical_code| -      new(text_code, numerical_code) -    end -  end - -end - diff --git a/app/views/routes/_form.html.slim b/app/views/routes/_form.html.slim index bee86f91e..244b427dc 100644 --- a/app/views/routes/_form.html.slim +++ b/app/views/routes/_form.html.slim @@ -7,11 +7,11 @@        .form-group.has_switch          = f.label :wayback, class: 'col-sm-4 col-xs-5 control-label' -        = f.input :wayback, as: :boolean, checked_value: :straight_forward, unchecked_value: :backward, label: content_tag(:span, @route.wayback_text, class: 'switch-label', data: {checkedValue: t('enumerize.route.direction.straight_forward'), uncheckedValue: t('enumerize.route.direction.backward')}), wrapper_html: { class: 'col-sm-8 col-xs-7'} +        = f.input :wayback, as: :boolean, checked_value: :outbound, unchecked_value: :inbound, label: content_tag(:span, @route.wayback_text, class: 'switch-label', data: {checkedValue: t('enumerize.route.wayback.outbound'), uncheckedValue: t('enumerize.route.wayback.inbound')}), wrapper_html: { class: 'col-sm-8 col-xs-7'} -      = f.input :opposite_route_id, collection: @forward, disabled: @route.wayback.straight_forward?, wrapper_html: {class: input_opposite_route_id_css(@route, 'straight_forward')} +      = f.input :opposite_route_id, collection: @forward, disabled: @route.wayback.outbound?, wrapper_html: {class: input_opposite_route_id_css(@route, 'outbound')} -      = f.input :opposite_route_id, collection: @backward, disabled: @route.wayback.backward?, wrapper_html: {class: input_opposite_route_id_css(@route, 'backward')} +      = f.input :opposite_route_id, collection: @backward, disabled: @route.wayback.inbound?, wrapper_html: {class: input_opposite_route_id_css(@route, 'inbound')} diff --git a/config/locales/enumerize.en.yml b/config/locales/enumerize.en.yml index 0bc3e5edc..addf64dbd 100644 --- a/config/locales/enumerize.en.yml +++ b/config/locales/enumerize.en.yml @@ -61,8 +61,8 @@ en:          east: 'East'          north_east: 'North East'        wayback: -        straight_forward: 'Straight Forward' -        backward: 'Backward' +        outbound: 'Straight Forward' +        inbound: 'Backward'      vehicle_journey:        transport_mode:          interchange: Interchange diff --git a/config/locales/enumerize.fr.yml b/config/locales/enumerize.fr.yml index 14aedd155..b183d80e0 100644 --- a/config/locales/enumerize.fr.yml +++ b/config/locales/enumerize.fr.yml @@ -14,10 +14,10 @@ fr:          canceled: Annulé      import_resource:        status: -        new: Nouveau -        pending: En file d'attente -        successful: Réussi -        failed: Echoué +        OK: ok +        ERROR: error +        WARNING: warning +        IGNORED: "n/a"      for_boarding:        normal: "Montée autorisée"        forbidden: "Montée interdite" @@ -61,8 +61,8 @@ fr:          east: 'Est'          north_east: 'Nord Est'        wayback: -        straight_forward: 'Aller' -        backward: 'Retour' +        outbound: 'Aller' +        inbound: 'Retour'      vehicle_journey:        transport_mode:          interchange: Interconnection diff --git a/config/locales/routes.en.yml b/config/locales/routes.en.yml index e94adf490..63d7b198c 100644 --- a/config/locales/routes.en.yml +++ b/config/locales/routes.en.yml @@ -36,9 +36,6 @@ en:        title: "Duplicate route"      route:        no_journey_pattern: "No Journey pattern" -      wayback: -        positive: "forward" -        negative: "backward"        opposite: "Opposite route"        no_opposite: "No opposite route"    activerecord: diff --git a/config/locales/waybacks.en.yml b/config/locales/waybacks.en.yml index e6d3234e1..58bcf06ba 100644 --- a/config/locales/waybacks.en.yml +++ b/config/locales/waybacks.en.yml @@ -1,5 +1,5 @@  en:    waybacks:      label: -      straight_forward: "straight forward" -      backward: "backward" +      outbound: "straight forward" +      inbound: "backward" diff --git a/config/locales/waybacks.fr.yml b/config/locales/waybacks.fr.yml index 4c6ed0036..c16e42e20 100644 --- a/config/locales/waybacks.fr.yml +++ b/config/locales/waybacks.fr.yml @@ -1,5 +1,5 @@  fr:    waybacks:      label: -      straight_forward: "aller" -      backward: "retour" +      outbound: "aller" +      inbound: "retour" diff --git a/db/migrate/20170913074922_change_wayback_route_values.rb b/db/migrate/20170913074922_change_wayback_route_values.rb new file mode 100644 index 000000000..a547cbd55 --- /dev/null +++ b/db/migrate/20170913074922_change_wayback_route_values.rb @@ -0,0 +1,12 @@ +class ChangeWaybackRouteValues < ActiveRecord::Migration +  def up +    execute "UPDATE routes SET wayback = 'outbound' WHERE routes.wayback = 'straight_forward';" +    execute "UPDATE routes SET wayback = 'inbound' WHERE routes.wayback = 'backward';" +  end + +  def down +    execute "UPDATE routes SET wayback = 'straight_forward' WHERE routes.wayback = 'outbound';" +    execute "UPDATE routes SET wayback = 'backward' WHERE routes.wayback = 'inbound';" +  end + +end diff --git a/db/schema.rb b/db/schema.rb index 9207590b5..39162b447 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: 20170907082913) do +ActiveRecord::Schema.define(version: 20170913074922) do    # These are extensions that must be enabled in order to support this database    enable_extension "plpgsql" diff --git a/spec/models/chouette/route/route_base_spec.rb b/spec/models/chouette/route/route_base_spec.rb index 794da4f1b..cac2880e8 100644 --- a/spec/models/chouette/route/route_base_spec.rb +++ b/spec/models/chouette/route/route_base_spec.rb @@ -11,7 +11,7 @@ RSpec.describe Chouette::Route, :type => :model do    end    it { is_expected.to enumerize(:direction).in(:straight_forward, :backward, :clockwise, :counter_clockwise, :north, :north_west, :west, :south_west, :south, :south_east, :east, :north_east) } -  it { is_expected.to enumerize(:wayback).in(:straight_forward, :backward) } +  it { is_expected.to enumerize(:wayback).in(:outbound, :inbound) }    #it { is_expected.to validate_presence_of :name }    it { is_expected.to validate_presence_of :line } @@ -19,7 +19,7 @@ RSpec.describe Chouette::Route, :type => :model do    #it { is_expected.to validate_presence_of :wayback_code }    #it { is_expected.to validate_presence_of :direction_code }    it { is_expected.to validate_inclusion_of(:direction).in_array(%i(straight_forward backward clockwise counter_clockwise north north_west west south_west south south_east east north_east)) } -  it { is_expected.to validate_inclusion_of(:wayback).in_array(%i(straight_forward backward)) } +  it { is_expected.to validate_inclusion_of(:wayback).in_array(%i(outbound inbound)) }    context "reordering methods" do      let(:bad_stop_point_ids){subject.stop_points.map { |sp| sp.id + 1}} | 
