diff options
| -rw-r--r-- | Gemfile | 4 | ||||
| -rw-r--r-- | Gemfile.lock | 6 | ||||
| -rw-r--r-- | app/controllers/referential_lines_controller.rb | 18 | ||||
| -rw-r--r-- | app/helpers/pagination_helper.rb | 4 | ||||
| -rw-r--r-- | app/views/referential_lines/show.html.slim | 9 | ||||
| -rw-r--r-- | db/schema.rb | 18 |
6 files changed, 40 insertions, 19 deletions
@@ -91,7 +91,7 @@ gem 'formtastic', '2.3.1' gem 'RedCloth', '~> 4.3.0' gem 'simple_form', '~> 3.1.0' gem 'font-awesome-sass', '~> 4.7' -gem 'will_paginate-bootstrap', '~> 1.0.1' +gem 'will_paginate-bootstrap' gem 'breadcrumbs_on_rails' # Format Output @@ -104,7 +104,7 @@ gem 'inherited_resources' gem 'google-analytics-rails' # Model -gem 'will_paginate', '~> 3.0.7' +gem 'will_paginate' gem 'ransack' gem 'squeel' gem 'active_attr' diff --git a/Gemfile.lock b/Gemfile.lock index e555b92ae..35dc39edd 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -558,7 +558,7 @@ GEM websocket-driver (0.5.3-java) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.2) - will_paginate (3.0.7) + will_paginate (3.1.5) will_paginate-bootstrap (1.0.1) will_paginate (>= 3.0.3) xml-simple (1.1.5) @@ -682,8 +682,8 @@ DEPENDENCIES uglifier (~> 2.7.2) webmock whenever! - will_paginate (~> 3.0.7) - will_paginate-bootstrap (~> 1.0.1) + will_paginate + will_paginate-bootstrap BUNDLED WITH 1.13.6 diff --git a/app/controllers/referential_lines_controller.rb b/app/controllers/referential_lines_controller.rb index 4842cebc1..5d36e7da7 100644 --- a/app/controllers/referential_lines_controller.rb +++ b/app/controllers/referential_lines_controller.rb @@ -23,18 +23,22 @@ class ReferentialLinesController < ChouetteController end def show - @map = LineMap.new(resource).with_helpers(self) + @routes = resource.routes - @q = @line.routes.ransack(params[:q]) + case sort_route_column + when "stop_points", "journey_patterns" + left_join = %Q{LEFT JOIN "#{sort_route_column}" ON "#{sort_route_column}"."route_id" = "routes"."id"} - if sort_route_column && sort_route_direction - @routes ||= @q.result(distinct: true).order(sort_route_column + ' ' + sort_route_direction) + @routes = @routes.joins(left_join).group(:id).order("count(#{sort_route_column}.route_id) #{sort_route_direction}") else - @routes ||= @q.result(distinct: true).order(:name) + @routes = @routes.order("#{sort_route_column} #{sort_route_direction}") end + + @q = @routes.ransack(params[:q]) + @routes = @q.result + @routes = @routes.paginate(page: params[:page], per_page: 10) - @group_of_lines = @line.group_of_lines show! do build_breadcrumb :show end @@ -106,7 +110,7 @@ class ReferentialLinesController < ChouetteController end def sort_route_column - @line.routes.column_names.include?(params[:sort]) ? params[:sort] : 'name' + (@line.routes.column_names + %w{stop_points journey_patterns}).include?(params[:sort]) ? params[:sort] : 'name' end def sort_route_direction %w[asc desc].include?(params[:direction]) ? params[:direction] : 'asc' diff --git a/app/helpers/pagination_helper.rb b/app/helpers/pagination_helper.rb index 350d796ea..02eec39dc 100644 --- a/app/helpers/pagination_helper.rb +++ b/app/helpers/pagination_helper.rb @@ -20,8 +20,8 @@ module PaginationHelper end def new_pagination collection, cls = nil - k = collection.first.class - pinfos = page_entries_info collection, model: k, html: false + # k = collection.first.class unless collection.empty? + pinfos = page_entries_info collection, html: false if collection.total_pages > 1 links = content_tag :div, '', class: 'page_links' do diff --git a/app/views/referential_lines/show.html.slim b/app/views/referential_lines/show.html.slim index 2566550ba..cd15cb0e0 100644 --- a/app/views/referential_lines/show.html.slim +++ b/app/views/referential_lines/show.html.slim @@ -46,21 +46,20 @@ .row .col-lg-12 - if params[:q].present? or @routes.any? - .row.mb-sm - .col-lg-12.text-right - = new_pagination @routes + / .row.mb-sm + / .col-lg-12.text-right + / = new_pagination @routes .row .col-lg-12 = search_form_for @q, url: referential_line_path(@referential, @line), class: 'form form-filter' 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 - - if @routes.any? .row .col-lg-12 diff --git a/db/schema.rb b/db/schema.rb index c0e146677..24e46a26a 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -165,6 +165,22 @@ ActiveRecord::Schema.define(version: 20170317114614) do add_index "connection_links", ["objectid"], :name => "connection_links_objectid_key", :unique => true + create_table "delayed_jobs", force: true do |t| + t.integer "priority", default: 0 + t.integer "attempts", default: 0 + t.text "handler" + t.text "last_error" + t.datetime "run_at" + t.datetime "locked_at" + t.datetime "failed_at" + t.string "locked_by" + t.string "queue" + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "delayed_jobs", ["priority", "run_at"], :name => "delayed_jobs_priority" + create_table "exports", force: true do |t| t.integer "referential_id", limit: 8 t.string "status" @@ -834,6 +850,8 @@ ActiveRecord::Schema.define(version: 20170317114614) do add_index "workbenches", ["stop_area_referential_id"], :name => "index_workbenches_on_stop_area_referential_id" Foreigner.load + add_foreign_key "access_links", "access_points", name: "aclk_acpt_fkey", dependent: :delete + add_foreign_key "group_of_lines_lines", "group_of_lines", name: "groupofline_group_fkey", dependent: :delete add_foreign_key "journey_frequencies", "timebands", name: "journey_frequencies_timeband_id_fk", dependent: :nullify |
