Project

General

Profile

Patch #3357 ยป repo_browser_path_versions.diff

Lance Sanchez, 2009-05-13 22:18

View differences:

app/helpers/application_helper.rb (working copy)
197 197
    path.to_s.split(%r{[/\\]}).select {|p| !p.blank?}
198 198
  end
199 199

  
200
  def pagination_links_full(paginator, count=nil, options={})
200
  def pagination_links_full(paginator, count=nil, options={:update => 'content'})
201 201
    page_param = options.delete(:page_param) || :page
202 202
    url_param = params.dup
203 203
    # don't reuse params if filters are present
......
205 205

  
206 206
    html = ''
207 207
    html << link_to_remote(('&#171; ' + l(:label_previous)),
208
                            {:update => 'content',
208
                            {:update => options[:update],
209 209
                             :url => url_param.merge(page_param => paginator.current.previous),
210 210
                             :complete => 'window.scrollTo(0,0)'},
211 211
                            {:href => url_for(:params => url_param.merge(page_param => paginator.current.previous))}) + ' ' if paginator.current.previous
......
213 213
    html << (pagination_links_each(paginator, options) do |n|
214 214
      link_to_remote(n.to_s,
215 215
                      {:url => {:params => url_param.merge(page_param => n)},
216
                       :update => 'content',
216
                       :update => options[:update],
217 217
                       :complete => 'window.scrollTo(0,0)'},
218 218
                      {:href => url_for(:params => url_param.merge(page_param => n))})
219 219
    end || '')
220 220

  
221 221
    html << ' ' + link_to_remote((l(:label_next) + ' &#187;'),
222
                                 {:update => 'content',
222
                                 {:update => options[:update],
223 223
                                  :url => url_param.merge(page_param => paginator.current.next),
224 224
                                  :complete => 'window.scrollTo(0,0)'},
225 225
                                 {:href => url_for(:params => url_param.merge(page_param => paginator.current.next))}) if paginator.current.next
226 226

  
227 227
    unless count.nil?
228
      html << [" (#{paginator.current.first_item}-#{paginator.current.last_item}/#{count})", per_page_links(paginator.items_per_page)].compact.join(' | ')
228
      html << [" (#{paginator.current.first_item}-#{paginator.current.last_item}/#{count})", per_page_links(paginator.items_per_page, options[:update])].compact.join(' | ')
229 229
    end
230 230

  
231 231
    html
232 232
  end
233 233

  
234
  def per_page_links(selected=nil)
234
  def per_page_links(selected=nil, update = "content")
235 235
    url_param = params.dup
236 236
    url_param.clear if url_param.has_key?(:set_filter)
237 237

  
238 238
    links = Setting.per_page_options_array.collect do |n|
239
      n == selected ? n : link_to_remote(n, {:update => "content", :url => params.dup.merge(:per_page => n)},
239
      n == selected ? n : link_to_remote(n, {:update => update, :url => params.dup.merge(:per_page => n)},
240 240
                                            {:href => url_for(url_param.merge(:per_page => n))})
241 241
    end
242 242
    links.size > 1 ? l(:label_display_per_page, links.join(', ')) : nil
app/controllers/repositories_controller.rb (working copy)
75 75
  end
76 76
  
77 77
  def browse
78
    @changeset_count = @repository.changesets.count
79
    @changeset_pages = Paginator.new self, @changeset_count,
80
								      per_page_option,
81
								      params['revisions_page']
82
								      
78 83
    @entries = @repository.entries(@path, @rev)
84
    path = @repository.url[/#{@repository.root_url}(.*)/,1] + (@path.starts_with?('/') ? @path : "/#{@path}") + "%"
85
    @changesets = @repository.changesets.find(:all, 
86
      :joins => "INNER JOIN changes on changes.changeset_id = changesets.id",
87
      :group => "changesets.id",
88
      :conditions => ["changes.path like ?", path],
89
      :limit => @changeset_pages.items_per_page,
90
      :offset =>  @changeset_pages.current.offset,
91
      :order => "changesets.committed_on DESC")
79 92
    if request.xhr?
80
      @entries ? render(:partial => 'dir_list_content') : render(:nothing => true)
93
      if params['revisions_page'] or params['per_page']
94
        render(:partial => 'path_revisions')
95
      else
96
        @entries ? render(:partial => 'dir_list_content') : render(:nothing => true)
97
      end
81 98
    else
82 99
      show_error_not_found and return unless @entries
83 100
      @properties = @repository.properties(@path, @rev)
app/views/repositories/_path_revisions.rhtml (revision 0)
1
<% if !@changesets.empty? && authorize_for('repositories', 'revisions') %>
2
  <h3><%= l(:label_latest_revision_plural) %></h3>
3
  <%= render :partial => 'revisions', :locals => {:project => @project, :path => '', :revisions => @changesets, :entry => nil }%>
4
  
5
  <p class="pagination"><%= pagination_links_full @changeset_pages,@changeset_count, {:page_param => 'revisions_page' ,:update => 'revisions'} %></p>
6
  
7
  <p><%= link_to l(:label_view_revisions), :action => 'revisions', :id => @project %></p>
8
<% end %>
app/views/repositories/browse.rhtml (working copy)
12 12
<% content_for :header_tags do %>
13 13
<%= stylesheet_link_tag "scm" %>
14 14
<% end %>
15
<div id="revisions">
16
<%= render :partial => 'path_revisions' %>
17
</div>
    (1-1/1)