diff options
| author | jpl | 2017-02-20 14:46:15 +0100 | 
|---|---|---|
| committer | jpl | 2017-02-20 14:46:15 +0100 | 
| commit | 68f1062c152c72be7995585f640739ac6de103b1 (patch) | |
| tree | d6f7c826ce7896fd71acac298a94ebac587be5c7 /app/controllers/referential_lines_controller.rb | |
| parent | ab69ebf74e1975e883e3d908f3c5621b045729c7 (diff) | |
| download | chouette-core-68f1062c152c72be7995585f640739ac6de103b1.tar.bz2 | |
Refs #2597: updating ref_lines#show with routes search form
Diffstat (limited to 'app/controllers/referential_lines_controller.rb')
| -rw-r--r-- | app/controllers/referential_lines_controller.rb | 18 | 
1 files changed, 17 insertions, 1 deletions
| diff --git a/app/controllers/referential_lines_controller.rb b/app/controllers/referential_lines_controller.rb index bd244d13b..4842cebc1 100644 --- a/app/controllers/referential_lines_controller.rb +++ b/app/controllers/referential_lines_controller.rb @@ -24,7 +24,16 @@ class ReferentialLinesController < ChouetteController    def show      @map = LineMap.new(resource).with_helpers(self) -    @routes = @line.routes.order(:name).paginate(page: params[:page], per_page: 10) + +    @q = @line.routes.ransack(params[:q]) + +    if sort_route_column && sort_route_direction +      @routes ||= @q.result(distinct: true).order(sort_route_column + ' ' + sort_route_direction) +    else +      @routes ||= @q.result(distinct: true).order(:name) +    end +    @routes = @routes.paginate(page: params[:page], per_page: 10) +      @group_of_lines = @line.group_of_lines      show! do        build_breadcrumb :show @@ -96,6 +105,13 @@ class ReferentialLinesController < ChouetteController      %w[asc desc].include?(params[:direction]) ?  params[:direction] : 'asc'    end +  def sort_route_column +    @line.routes.column_names.include?(params[:sort]) ? params[:sort] : 'name' +  end +  def sort_route_direction +    %w[asc desc].include?(params[:direction]) ?  params[:direction] : 'asc' +  end +    def line_params      params.require(:line).permit(        :transport_mode, | 
