aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers/time_tables_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/time_tables_controller.rb')
-rw-r--r--app/controllers/time_tables_controller.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/app/controllers/time_tables_controller.rb b/app/controllers/time_tables_controller.rb
index dbecde0eb..b860d2948 100644
--- a/app/controllers/time_tables_controller.rb
+++ b/app/controllers/time_tables_controller.rb
@@ -6,8 +6,24 @@ class TimeTablesController < ChouetteController
belongs_to :referential
+ def comment_filter
+ respond_to do |format|
+ format.json { render :json => filtered_time_tables_maps}
+ end
+
+ end
+
protected
+ def filtered_time_tables_maps
+ filtered_time_tables.collect do |time_table|
+ { :id => time_table.id.to_s, :name => time_table.comment }
+ end
+ end
+ def filtered_time_tables
+ referential.time_tables.select{ |t| t.comment =~ /#{params[:q]}/i }
+ end
+
def collection
@q = referential.time_tables.search(params[:q])
@time_tables ||= @q.result(:distinct => true).order(:comment).paginate(:page => params[:page], :per_page => 10)