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 | |
| parent | ab69ebf74e1975e883e3d908f3c5621b045729c7 (diff) | |
| download | chouette-core-68f1062c152c72be7995585f640739ac6de103b1.tar.bz2 | |
Refs #2597: updating ref_lines#show with routes search form
Diffstat (limited to 'app')
| -rw-r--r-- | app/assets/stylesheets/components/_lists.sass | 2 | ||||
| -rw-r--r-- | app/controllers/referential_lines_controller.rb | 18 | ||||
| -rw-r--r-- | app/views/referential_lines/show.html.slim | 36 |
3 files changed, 44 insertions, 12 deletions
diff --git a/app/assets/stylesheets/components/_lists.sass b/app/assets/stylesheets/components/_lists.sass index 17822b12a..53c7df907 100644 --- a/app/assets/stylesheets/components/_lists.sass +++ b/app/assets/stylesheets/components/_lists.sass @@ -12,7 +12,7 @@ $dlWidth: 40% letter-spacing: -0.31em text-rendering: optimizespeed font-weight: 300 - margin-bottom: 20px + margin-bottom: 40px .dl-head display: block 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, diff --git a/app/views/referential_lines/show.html.slim b/app/views/referential_lines/show.html.slim index f81d7e0fc..94f30c059 100644 --- a/app/views/referential_lines/show.html.slim +++ b/app/views/referential_lines/show.html.slim @@ -44,16 +44,32 @@ .row .col-lg-12 - - if @routes.any? - = new_pagination @routes, 'pull-right' + - if params[:q].present? or @routes.any? + .row.mb-sm + .col-lg-5.col-md-6.col-sm-6.col-xs-8 + = search_form_for @q, url: referential_line_path(@referential, @line) do |f| + .input-group.search_bar + = f.search_field :name_cont, class: 'form-control', placeholder: "Indiquez un nom d'itinéraire..." + + span.input-group-btn + button.btn.btn-default type='submit' + span.fa.fa-search - = table_builder @routes, - { @routes.human_attribute_name(:name) => 'name', @routes.human_attribute_name(:published_name) => 'published_name', @routes.human_attribute_name(:wayback) => Proc.new{|r| r.try(:wayback_text)}, @routes.human_attribute_name(:opposite_route) => Proc.new{|r| r.try(:opposite_route).try(:name)} }, - [:show, :edit, :delete], - [], - 'table' + .col-lg-7.col-md-6.col-sm-6.col-xs-4.text-right + = new_pagination @routes + + - if @routes.any? + .row + .col-lg-12 + = table_builder @routes, + { @routes.human_attribute_name(:name) => 'name', @routes.human_attribute_name(:published_name) => 'published_name', @routes.human_attribute_name(:wayback) => Proc.new{|r| r.try(:wayback_text)}, @routes.human_attribute_name(:opposite_route) => Proc.new{|r| r.try(:opposite_route).try(:name)} }, + [:show, :edit, :delete], + [], + 'table' - = new_pagination @routes, 'pull-right' + = new_pagination @routes, 'pull-right' - - else - = replacement_msg t('routes.search_no_results') + - unless @routes.any? + .row.mt-xs + .col-lg-12 + = replacement_msg t('routes.search_no_results') |
