aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers
diff options
context:
space:
mode:
authorZakaria BOUZIANE2014-12-15 10:09:06 +0100
committerZakaria BOUZIANE2014-12-15 10:09:06 +0100
commitfbb5cb147d73e794e2a3abffe3cf0f0c21e5e6cd (patch)
treec06416988e4ddec2f183a5d487be88f1b85db4aa /app/controllers
parentd1661c9504876812d64ba3b8182612737f04900c (diff)
parenta0433013264531e825268d0ae1a0da873d368313 (diff)
downloadchouette-core-fbb5cb147d73e794e2a3abffe3cf0f0c21e5e6cd.tar.bz2
Merge branch 'V2_5' : HUB ITLs adding
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/autocomplete_stop_areas_controller.rb54
-rw-r--r--app/controllers/routes_controller.rb17
-rw-r--r--app/controllers/stop_area_children_controller.rb21
-rw-r--r--app/controllers/stop_area_parents_controller.rb19
-rw-r--r--app/controllers/stop_area_routing_stops_controller.rb21
-rw-r--r--app/controllers/stop_areas_controller.rb3
-rw-r--r--app/controllers/stop_point_areas_controller.rb20
7 files changed, 71 insertions, 84 deletions
diff --git a/app/controllers/autocomplete_stop_areas_controller.rb b/app/controllers/autocomplete_stop_areas_controller.rb
new file mode 100644
index 000000000..64a62efe5
--- /dev/null
+++ b/app/controllers/autocomplete_stop_areas_controller.rb
@@ -0,0 +1,54 @@
+class AutocompleteStopAreasController < InheritedResources::Base
+ respond_to :json, :only => [:index, :children, :parent, :physicals]
+
+ before_filter :switch_referential
+
+ def switch_referential
+ Apartment::Database.switch(referential.slug)
+ end
+
+ def referential
+ @referential ||= current_organisation.referentials.find params[:referential_id]
+ end
+
+ protected
+
+ def collection
+ result = []
+ if physical_filter?
+ result = referential.stop_areas.physical
+ elsif itl_exclude_filter?
+ result = Chouette::StopArea.where("area_type != 'ITL'")
+ elsif target_type? && relation_parent?
+ result = Chouette::StopArea.new( :area_type => params[ :target_type ] ).possible_parents
+ elsif target_type? && relation_children?
+ result = Chouette::StopArea.new( :area_type => params[ :target_type ] ).possible_children
+ else
+ result = referential.stop_areas
+ end
+ @stop_areas = result.select{ |p| p.name =~ /#{params[:q]}/i }
+ @stop_areas
+ end
+
+ def target_type?
+ params.has_key?( :target_type) && params.has_key?( :relation )
+ end
+
+ def relation_parent?
+ params[ :relation ] == "parent"
+ end
+
+ def relation_children?
+ params[ :relation ] == "children"
+ end
+
+ def itl_exclude_filter?
+ params[:filter] == "itl_excluded"
+ end
+
+ def physical_filter?
+ params[:filter] == "physical"
+ end
+
+end
+
diff --git a/app/controllers/routes_controller.rb b/app/controllers/routes_controller.rb
index 391a14d88..6454ce068 100644
--- a/app/controllers/routes_controller.rb
+++ b/app/controllers/routes_controller.rb
@@ -15,6 +15,21 @@ class RoutesController < ChouetteController
end
end
+ def edit_boarding_alighting
+ @route = route
+ build_breadcrumb :edit
+ end
+
+ def save_boarding_alighting
+ @route = route
+
+ if @route.update_attributes(params[:route])
+ redirect_to referential_line_route_path(@referential, @line, @route)
+ else
+ render "edit_boarding_alighting"
+ end
+ end
+
def show
@map = RouteMap.new(route).with_helpers(self)
@stop_points = route.stop_points.paginate(:page => params[:page])
@@ -26,7 +41,7 @@ class RoutesController < ChouetteController
# overwrite inherited resources to use delete instead of destroy
# foreign keys will propagate deletion)
def destroy_resource(object)
- object.delete
+ object.delete
end
def destroy
diff --git a/app/controllers/stop_area_children_controller.rb b/app/controllers/stop_area_children_controller.rb
deleted file mode 100644
index d60fcb1a6..000000000
--- a/app/controllers/stop_area_children_controller.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-class StopAreaChildrenController < ChouetteController
-
- respond_to :json, :only => :index
-
- def index
- respond_to do |format|
- format.json { render :json => children_maps }
- end
- end
-
- protected
-
- def children_maps
- children.map {|area| area.attributes.merge( :area_type => t("area_types.label.#{area.area_type.underscore}"))}
- end
-
- def children
- referential.stop_areas.find(params[:stop_area_id]).possible_children.select{ |p| p.name =~ /#{params[:q]}/i }
- end
-
-end
diff --git a/app/controllers/stop_area_parents_controller.rb b/app/controllers/stop_area_parents_controller.rb
deleted file mode 100644
index c32e5df17..000000000
--- a/app/controllers/stop_area_parents_controller.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-class StopAreaParentsController < ChouetteController
-
- respond_to :json, :only => :index
-
- def index
- respond_to do |format|
- format.json { render :json => parents_maps }
- end
- end
-
- def parents_maps
- parents.map {|area| area.attributes.merge( :area_type => t("area_types.label.#{area.area_type.underscore}"))}
- end
-
- def parents
- referential.stop_areas.find(params[:stop_area_id]).possible_parents.select{ |p| p.name =~ /#{params[:q]}/i }
- end
-
-end
diff --git a/app/controllers/stop_area_routing_stops_controller.rb b/app/controllers/stop_area_routing_stops_controller.rb
deleted file mode 100644
index c5e7980f9..000000000
--- a/app/controllers/stop_area_routing_stops_controller.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-class StopAreaRoutingStopsController < ChouetteController
-
- respond_to :json, :only => :index
-
- def index
- respond_to do |format|
- format.json { render :json => routing_stops_maps }
- end
- end
-
- def routing_stops_maps
- routing_stops.collect do |stop|
- { :id => stop.id.to_s, :name => "#{stop.name} #{stop.country_code}" }
- end
- end
-
- def routing_stops
- referential.stop_areas.find(params[:stop_area_id]).possible_children.select{ |p| p.name =~ /#{params[:q]}/i }
- end
-
-end
diff --git a/app/controllers/stop_areas_controller.rb b/app/controllers/stop_areas_controller.rb
index 53a7575b9..6277b5814 100644
--- a/app/controllers/stop_areas_controller.rb
+++ b/app/controllers/stop_areas_controller.rb
@@ -36,7 +36,6 @@ class StopAreasController < ChouetteController
def add_routing_stops
@stop_area = stop_area
- @stops = stop_area.routing_stops
build_breadcrumb :edit
end
@@ -100,7 +99,7 @@ class StopAreasController < ChouetteController
def update
stop_area.position ||= stop_area.default_position
map.editable = true
-
+
update!
end
diff --git a/app/controllers/stop_point_areas_controller.rb b/app/controllers/stop_point_areas_controller.rb
deleted file mode 100644
index 1ece8641e..000000000
--- a/app/controllers/stop_point_areas_controller.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-class StopPointAreasController < ChouetteController
-
- respond_to :json, :only => :index
-
- def index
- respond_to do |format|
- format.json { render :json => areas_maps }
- end
- end
-
- def areas_maps
- areas.map {|area| area.attributes.merge( :area_type => t("area_types.label.#{area.area_type.underscore}"))}
- end
-
- def areas
- Chouette::StopPoint.area_candidates.select{ |p| p.name =~ /#{params[:q]}/i }
- end
-
-end
-