diff options
| author | Luc Donnet | 2012-10-11 09:39:25 +0200 |
|---|---|---|
| committer | Luc Donnet | 2012-10-11 09:39:25 +0200 |
| commit | 0f61b9f0de549290b9ebf4f5cc2d00b63c2fd02e (patch) | |
| tree | f2955e539117ecaa10331994fd42f0345e17fbf7 /app/controllers | |
| parent | 09419f7fbe6be35abba2b638431e41480e8cf764 (diff) | |
| parent | 8b8c8f3ec124e6327e535c13a4045c1d62859d52 (diff) | |
| download | chouette-core-0f61b9f0de549290b9ebf4f5cc2d00b63c2fd02e.tar.bz2 | |
Merge branch 'master' of chouette.dryade.priv:/srv/git/chouette2
Diffstat (limited to 'app/controllers')
| -rw-r--r-- | app/controllers/group_of_lines_controller.rb | 47 | ||||
| -rw-r--r-- | app/controllers/lines_controller.rb | 18 | ||||
| -rw-r--r-- | app/controllers/time_table_dates_controller.rb | 27 | ||||
| -rw-r--r-- | app/controllers/time_table_periods_controller.rb | 27 |
4 files changed, 65 insertions, 54 deletions
diff --git a/app/controllers/group_of_lines_controller.rb b/app/controllers/group_of_lines_controller.rb new file mode 100644 index 000000000..c758ad16d --- /dev/null +++ b/app/controllers/group_of_lines_controller.rb @@ -0,0 +1,47 @@ +class GroupOfLinesController < ChouetteController + defaults :resource_class => Chouette::GroupOfLine + respond_to :html + respond_to :xml + respond_to :json + respond_to :kml, :only => :show + + belongs_to :referential + + def show + @map = GroupOfLineMap.new(resource).with_helpers(self) + @lines = resource.lines.order(:name).paginate(:page => params[:page]) + show! + end + + def name_filter + respond_to do |format| + format.json { render :json => filtered_group_of_lines_maps} + end + + end + + protected + + def filtered_group_of_lines_maps + filtered_group_of_lines.collect do |group_of_line| + { :id => group_of_line.id, :name => group_of_line.name } + end + end + + def filtered_group_of_lines + referential.group_of_lines.select{ |t| t.name =~ /#{params[:q]}/i } + end + + def collection + @q = referential.group_of_lines.search(params[:q]) + @group_of_lines ||= @q.result(:distinct => true).order(:name).paginate(:page => params[:page]) + end + + def resource_url(group_of_line = nil) + referential_group_of_line_path(referential, group_of_line || resource) + end + + def collection_url + referential_group_of_lines_path(referential) + end +end diff --git a/app/controllers/lines_controller.rb b/app/controllers/lines_controller.rb index e85c29fc9..c8655908d 100644 --- a/app/controllers/lines_controller.rb +++ b/app/controllers/lines_controller.rb @@ -10,6 +10,7 @@ class LinesController < ChouetteController def show @map = LineMap.new(resource).with_helpers(self) @routes = @line.routes + @group_of_lines = @line.group_of_lines show! end @@ -20,8 +21,25 @@ class LinesController < ChouetteController respond_with(objects, :location => smart_collection_url) end + def name_filter + respond_to do |format| + format.json { render :json => filtered_lines_maps} + end + + end + protected + def filtered_lines_maps + filtered_lines.collect do |line| + { :id => line.id, :name => line.published_name } + end + end + + def filtered_lines + referential.lines.select{ |t| t.published_name =~ /#{params[:q]}/i } + end + def collection @q = referential.lines.search(params[:q]) @lines ||= @q.result(:distinct => true).order(:number).paginate(:page => params[:page]).includes([:network, :company]) diff --git a/app/controllers/time_table_dates_controller.rb b/app/controllers/time_table_dates_controller.rb deleted file mode 100644 index 100034394..000000000 --- a/app/controllers/time_table_dates_controller.rb +++ /dev/null @@ -1,27 +0,0 @@ -class TimeTableDatesController < ChouetteController - defaults :resource_class => Chouette::TimeTableDate, :collection_name => 'dates' - - respond_to :html - - belongs_to :referential do - belongs_to :time_table, :parent_class => Chouette::TimeTable - end - - def update - update! do |success, failure| - success.html { redirect_to referential_time_table_path(@referential,@time_table) } - end - end - - def create - create! do |success, failure| - success.html { redirect_to referential_time_table_path(@referential,@time_table) } - end - end - - def destroy - destroy! do |success, failure| - success.html { redirect_to referential_time_table_path(@referential,@time_table) } - end - end -end diff --git a/app/controllers/time_table_periods_controller.rb b/app/controllers/time_table_periods_controller.rb deleted file mode 100644 index 0614de2d5..000000000 --- a/app/controllers/time_table_periods_controller.rb +++ /dev/null @@ -1,27 +0,0 @@ -class TimeTablePeriodsController < ChouetteController - defaults :resource_class => Chouette::TimeTablePeriod, :collection_name => 'periods' - - respond_to :html - - belongs_to :referential do - belongs_to :time_table, :parent_class => Chouette::TimeTable - end - - def update - update! do |success, failure| - success.html { redirect_to referential_time_table_path(@referential,@time_table) } - end - end - - def create - create! do |success, failure| - success.html { redirect_to referential_time_table_path(@referential,@time_table) } - end - end - - def destroy - destroy! do |success, failure| - success.html { redirect_to referential_time_table_path(@referential,@time_table) } - end - end -end |
