summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2007-03-25 18:18:29 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2007-03-25 18:18:29 +0000
commite951209d6824361b985032e7c8aa2ad82158ae7d (patch)
tree3968512acad9b0d54b7597b31a12f2f1dbf5e310
parent0ef114e00641a3cdb8771675a30cae31177b2d61 (diff)
downloadredmine-e951209d6824361b985032e7c8aa2ad82158ae7d.tar.gz
redmine-e951209d6824361b985032e7c8aa2ad82158ae7d.zip
added pagination on revisions list
git-svn-id: http://redmine.rubyforge.org/svn/trunk@381 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/controllers/repositories_controller.rb11
-rw-r--r--app/models/repository.rb9
-rw-r--r--app/views/repositories/revisions.rhtml4
3 files changed, 22 insertions, 2 deletions
diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb
index 276b88162..7a8e0de2e 100644
--- a/app/controllers/repositories_controller.rb
+++ b/app/controllers/repositories_controller.rb
@@ -47,7 +47,16 @@ class RepositoriesController < ApplicationController
@entry = @repository.scm.entry(@path, @rev)
show_error and return unless @entry
end
- @changesets = @repository.changesets_for_path(@path)
+ @repository.changesets_with_path @path do
+ @changeset_count = @repository.changesets.count
+ @changeset_pages = Paginator.new self, @changeset_count,
+ 25,
+ params['page']
+ @changesets = @repository.changesets.find(:all,
+ :limit => @changeset_pages.items_per_page,
+ :offset => @changeset_pages.current.offset)
+ end
+ render :action => "revisions", :layout => false if request.xhr?
end
def entry
diff --git a/app/models/repository.rb b/app/models/repository.rb
index 465c4ba62..8f12ccc4c 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -36,6 +36,15 @@ class Repository < ActiveRecord::Base
super if root_url.blank?
end
+ def changesets_with_path(path="")
+ path = "/#{path}%"
+ path = url.gsub(/^#{root_url}/, '') + path if root_url && root_url != url
+ path.squeeze!("/")
+ Changeset.with_scope(:find => { :include => :changes, :conditions => ["#{Change.table_name}.path LIKE ?", path] }) do
+ yield
+ end
+ end
+
def changesets_for_path(path="")
path = "/#{path}%"
path = url.gsub(/^#{root_url}/, '') + path if root_url && root_url != url
diff --git a/app/views/repositories/revisions.rhtml b/app/views/repositories/revisions.rhtml
index 52564472d..b438201cc 100644
--- a/app/views/repositories/revisions.rhtml
+++ b/app/views/repositories/revisions.rhtml
@@ -15,7 +15,9 @@
<h3>Revisions</h3>
<%= render :partial => 'revisions', :locals => {:project => @project, :path => @path, :changesets => @changesets, :entry => @entry }%>
-<p><%= lwr(:label_modification, @changesets.length) %></p>
+
+<p><%= pagination_links_full @changeset_pages %>
+[ <%= @changeset_pages.current.first_item %> - <%= @changeset_pages.current.last_item %> / <%= @changeset_count %> ]</p>
<% content_for :header_tags do %>
<%= stylesheet_link_tag "scm" %>