diff options
| -rw-r--r-- | app/controllers/routes_controller.rb | 12 | ||||
| -rw-r--r-- | app/views/routes/_form.html.slim | 2 | 
2 files changed, 12 insertions, 2 deletions
| diff --git a/app/controllers/routes_controller.rb b/app/controllers/routes_controller.rb index a7e8e32a6..aecdb480d 100644 --- a/app/controllers/routes_controller.rb +++ b/app/controllers/routes_controller.rb @@ -9,6 +9,8 @@ class RoutesController < ChouetteController      belongs_to :line, :parent_class => Chouette::Line, :optional => true, :polymorphic => true    end +  before_action :define_candidate_opposite_routes, only: [:new, :edit, :create, :update] +    def index      index! do |format|        format.html { redirect_to referential_line_path(@referential,@line) } @@ -74,6 +76,15 @@ class RoutesController < ChouetteController        end    end +  def define_candidate_opposite_routes +    @candidate_opposite_routes = +      if params[:id] +        resource.line.routes.where("id <> ?", resource) +      else +        parent.routes +      end +  end +    private    def route_params @@ -81,4 +92,3 @@ class RoutesController < ChouetteController    end  end - diff --git a/app/views/routes/_form.html.slim b/app/views/routes/_form.html.slim index 4b0cbd015..9893e4ed7 100644 --- a/app/views/routes/_form.html.slim +++ b/app/views/routes/_form.html.slim @@ -7,7 +7,7 @@    .row      .col-lg-4.col-md-6.col-sm-8.col-xs-8 -      = f.input :opposite_route_id, collection: @line.routes.where("id <> ?", @route) +      = f.input :opposite_route_id, collection: @candidate_opposite_routes      / .col-lg-4.col-md-4.col-sm-4.col-xs-4      /   = f.input :direction, include_blank: false | 
