aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/routing_constraint_zones_controller.rb10
1 files changed, 8 insertions, 2 deletions
diff --git a/app/controllers/routing_constraint_zones_controller.rb b/app/controllers/routing_constraint_zones_controller.rb
index 1eb2ddf28..c526e6348 100644
--- a/app/controllers/routing_constraint_zones_controller.rb
+++ b/app/controllers/routing_constraint_zones_controller.rb
@@ -22,14 +22,20 @@ class RoutingConstraintZonesController < ChouetteController
def new
new! do |format|
format.html
- @route = @line.routes.find params[:route_id] if params[:route_id]
- format.js
+ format.js {
+ # Get selected route in the form view
+ @route = @line.routes.find params[:route_id] if params[:route_id]
+ # Get the routing_constraint_zone, the main use is when validation failed
+ routing_constraint_zone = @line.routing_constraint_zones.new(JSON(params[:routing_constraint_zone_json])) if params[:routing_constraint_zone_json]
+ @routing_constraint_zone = routing_constraint_zone || build_resource
+ }
end
end
protected
alias_method :routing_constraint_zone, :resource
+ alias_method :line, :parent
def collection
@q = current_referential.routing_constraint_zones.search(params[:q])