aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichel Etienne2014-05-02 09:41:36 +0200
committerMichel Etienne2014-05-02 09:41:36 +0200
commit62e398c96e60ecb1a424a7fbbde4022220441f69 (patch)
treef3835ba8ba42ffe779a37d55cc9e952094f45229
parent31455ed1e2dfe68bbba0173821a8c47ad39eccaf (diff)
downloadchouette-core-62e398c96e60ecb1a424a7fbbde4022220441f69.tar.bz2
Fix filters use with will paginate when active filter return less pages than current, Mantis 20954
-rw-r--r--CHANGELOG.md1
-rw-r--r--app/controllers/access_points_controller.rb11
-rw-r--r--app/controllers/companies_controller.rb15
-rw-r--r--app/controllers/connection_links_controller.rb10
-rw-r--r--app/controllers/group_of_lines_controller.rb10
-rw-r--r--app/controllers/networks_controller.rb10
-rw-r--r--app/controllers/time_tables_controller.rb13
-rw-r--r--app/controllers/vehicle_journeys_controller.rb11
8 files changed, 74 insertions, 7 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6ea374f8e..7b1cc9129 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,7 @@
* Mieux expliquer les espaces de données dans l'aide (Mantis 22286 et 22811)
* Créer un calendrier avec des dates ou périodes vides, crée un calendrier vide (Mantis 24425)
* Remplacer détruire par supprimer dans les confirmation de suppression (Mantis 24414)
+ * Protection des listes avec filtre si la page courante est au dela du nombre de pages (Mantis 20954)
# Version 2.3.0 (18/04/14)
* Migration technique de chouette (Java)
diff --git a/app/controllers/access_points_controller.rb b/app/controllers/access_points_controller.rb
index d26595a85..6203cefab 100644
--- a/app/controllers/access_points_controller.rb
+++ b/app/controllers/access_points_controller.rb
@@ -8,9 +8,16 @@ class AccessPointsController < ChouetteController
respond_to :html, :kml, :xml, :json
- def index
+ def index
request.format.kml? ? @per_page = nil : @per_page = 12
- index!
+
+ index! do |format|
+ format.html {
+ if collection.out_of_bounds?
+ redirect_to params.merge(:page => 1)
+ end
+ }
+ end
end
def show
diff --git a/app/controllers/companies_controller.rb b/app/controllers/companies_controller.rb
index a895c4f61..27f0f9235 100644
--- a/app/controllers/companies_controller.rb
+++ b/app/controllers/companies_controller.rb
@@ -6,11 +6,16 @@ class CompaniesController < ChouetteController
belongs_to :referential, :parent_class => Referential
- # def update
- # update! do |success, failure|
- # failure.html { redirect_to referential_companies_path(@resource, @referential) }
- # end
- # end
+ def index
+
+ index! do |format|
+ format.html {
+ if collection.out_of_bounds?
+ redirect_to params.merge(:page => 1)
+ end
+ }
+ end
+ end
protected
def collection
diff --git a/app/controllers/connection_links_controller.rb b/app/controllers/connection_links_controller.rb
index cbb8346c6..6f225af1f 100644
--- a/app/controllers/connection_links_controller.rb
+++ b/app/controllers/connection_links_controller.rb
@@ -9,6 +9,16 @@ class ConnectionLinksController < ChouetteController
respond_to :html, :xml, :json
respond_to :kml, :only => :show
+ def index
+ index! do |format|
+ format.html {
+ if collection.out_of_bounds?
+ redirect_to params.merge(:page => 1)
+ end
+ }
+ end
+ end
+
def show
@map = ConnectionLinkMap.new(resource).with_helpers(self)
show!
diff --git a/app/controllers/group_of_lines_controller.rb b/app/controllers/group_of_lines_controller.rb
index c758ad16d..a38b22c10 100644
--- a/app/controllers/group_of_lines_controller.rb
+++ b/app/controllers/group_of_lines_controller.rb
@@ -13,6 +13,16 @@ class GroupOfLinesController < ChouetteController
show!
end
+ def index
+ index! do |format|
+ format.html {
+ if collection.out_of_bounds?
+ redirect_to params.merge(:page => 1)
+ end
+ }
+ end
+ end
+
def name_filter
respond_to do |format|
format.json { render :json => filtered_group_of_lines_maps}
diff --git a/app/controllers/networks_controller.rb b/app/controllers/networks_controller.rb
index aabdadaf4..b911ab603 100644
--- a/app/controllers/networks_controller.rb
+++ b/app/controllers/networks_controller.rb
@@ -12,6 +12,16 @@ class NetworksController < ChouetteController
show!
end
+ def index
+ index! do |format|
+ format.html {
+ if collection.out_of_bounds?
+ redirect_to params.merge(:page => 1)
+ end
+ }
+ end
+ end
+
protected
def collection
diff --git a/app/controllers/time_tables_controller.rb b/app/controllers/time_tables_controller.rb
index a9f799e9d..00109aa76 100644
--- a/app/controllers/time_tables_controller.rb
+++ b/app/controllers/time_tables_controller.rb
@@ -18,6 +18,19 @@ class TimeTablesController < ChouetteController
end
+ def index
+ request.format.kml? ? @per_page = nil : @per_page = 12
+
+ index! do |format|
+ format.html {
+ if collection.out_of_bounds?
+ redirect_to params.merge(:page => 1)
+ end
+ }
+ end
+ end
+
+
protected
def filtered_time_tables_maps
diff --git a/app/controllers/vehicle_journeys_controller.rb b/app/controllers/vehicle_journeys_controller.rb
index 1aec533c1..0e8bca9cb 100644
--- a/app/controllers/vehicle_journeys_controller.rb
+++ b/app/controllers/vehicle_journeys_controller.rb
@@ -30,6 +30,17 @@ class VehicleJourneysController < ChouetteController
update!(:alert => t('activerecord.errors.models.vehicle_journey.invalid_times'))
end
+ def index
+ index! do |format|
+ format.html {
+ if collection.out_of_bounds?
+ redirect_to params.merge(:page => 1)
+ end
+ }
+ end
+ end
+
+
# overwrite inherited resources to use delete instead of destroy
# foreign keys will propagate deletion)
def destroy_resource(object)