From 3d61c788b87c8a4017dc86c4f2bc211fc784af14 Mon Sep 17 00:00:00 2001 From: Marc Florisson Date: Fri, 21 Nov 2014 18:11:35 +0100 Subject: display more info on stop area auto complete. Mantis 30118 --- app/controllers/stop_area_children_controller.rb | 2 +- app/controllers/stop_area_parents_controller.rb | 2 +- app/controllers/stop_point_areas_controller.rb | 20 ++--- app/views/routes/_form.html.erb | 96 ++++++++++++++---------- 4 files changed, 65 insertions(+), 55 deletions(-) (limited to 'app') diff --git a/app/controllers/stop_area_children_controller.rb b/app/controllers/stop_area_children_controller.rb index 773f6e1b8..d60fcb1a6 100644 --- a/app/controllers/stop_area_children_controller.rb +++ b/app/controllers/stop_area_children_controller.rb @@ -11,7 +11,7 @@ class StopAreaChildrenController < ChouetteController protected def children_maps - children.map { |c| c.attributes} + children.map {|area| area.attributes.merge( :area_type => t("area_types.label.#{area.area_type.underscore}"))} end def children diff --git a/app/controllers/stop_area_parents_controller.rb b/app/controllers/stop_area_parents_controller.rb index 06b462075..c32e5df17 100644 --- a/app/controllers/stop_area_parents_controller.rb +++ b/app/controllers/stop_area_parents_controller.rb @@ -9,7 +9,7 @@ class StopAreaParentsController < ChouetteController end def parents_maps - parents.map { |p| p.attributes} + parents.map {|area| area.attributes.merge( :area_type => t("area_types.label.#{area.area_type.underscore}"))} end def parents diff --git a/app/controllers/stop_point_areas_controller.rb b/app/controllers/stop_point_areas_controller.rb index 9544d0fe6..1ece8641e 100644 --- a/app/controllers/stop_point_areas_controller.rb +++ b/app/controllers/stop_point_areas_controller.rb @@ -3,25 +3,17 @@ class StopPointAreasController < ChouetteController respond_to :json, :only => :index def index - respond_to do |format| - format.json { render :json => areas_maps } - end + respond_to do |format| + format.json { render :json => areas_maps } + end end def areas_maps - areas.collect do |area| - { :id => area.id.to_s, - :name => area.name, - :country_code => area.country_code, - :zip_code => area.zip_code || "", - :city_name => area.city_name || "", - :area_type => t("area_types.label.#{area.area_type.underscore}") - } - end + 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 } + def areas + Chouette::StopPoint.area_candidates.select{ |p| p.name =~ /#{params[:q]}/i } end end diff --git a/app/views/routes/_form.html.erb b/app/views/routes/_form.html.erb index 658fda0ae..270c49911 100644 --- a/app/views/routes/_form.html.erb +++ b/app/views/routes/_form.html.erb @@ -26,55 +26,73 @@ <% end %> <% end %>