]> source.dussan.org Git - redmine.git/commitdiff
Always show previous/next when there are more than one page.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 28 Nov 2015 12:24:23 +0000 (12:24 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 28 Nov 2015 12:24:23 +0000 (12:24 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@14901 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/redmine/pagination.rb

index 053269a58a67f8ce00b43523353dfdd73d5d3b2a..e6faa8a68b3d96faa3a5e728ed959d0522a86f2e 100644 (file)
@@ -67,6 +67,10 @@ module Redmine
         end
       end
 
+      def multiple_pages?
+        per_page < item_count
+      end
+
       def first_item
         item_count == 0 ? 0 : (offset + 1)
       end
@@ -173,13 +177,18 @@ module Redmine
         page_param = paginator.page_param
 
         html = '<ul class="pages">'
-        if paginator.previous_page
+
+        if paginator.multiple_pages?
           # \xc2\xab(utf-8) = &#171;
           text = "\xc2\xab " + l(:label_previous)
-          html << content_tag('li',
-                              yield(text, {page_param => paginator.previous_page},
-                                    :accesskey => accesskey(:previous)),
-                              :class => 'previous page')
+          if paginator.previous_page
+            html << content_tag('li',
+                                yield(text, {page_param => paginator.previous_page},
+                                      :accesskey => accesskey(:previous)),
+                                :class => 'previous page')
+          else
+            html << content_tag('li', content_tag('span', text), :class => 'previous')
+          end
         end
 
         previous = nil
@@ -197,13 +206,17 @@ module Redmine
           previous = page
         end
 
-        if paginator.next_page
+        if paginator.multiple_pages?
           # \xc2\xbb(utf-8) = &#187;
           text = l(:label_next) + " \xc2\xbb"
-          html << content_tag('li',
-                              yield(text, {page_param => paginator.next_page},
-                                    :accesskey => accesskey(:next)),
-                              :class => 'next page')
+          if paginator.next_page
+            html << content_tag('li',
+                                yield(text, {page_param => paginator.next_page},
+                                      :accesskey => accesskey(:next)),
+                                :class => 'next page')
+          else
+            html << content_tag('li', content_tag('span', text), :class => 'next')
+          end
         end
         html << '</ul>'