From 8ca4d35dcc466df18b0fa6a322d00b030b183d15 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Mon, 22 Oct 2007 17:45:41 +0000 Subject: [PATCH] Added a bit of AJAX on the SCM browser (tree view). git-svn-id: http://redmine.rubyforge.org/svn/trunk@862 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/repositories_controller.rb | 6 +++- app/views/repositories/_dir_list.rhtml | 21 +++--------- .../repositories/_dir_list_content.rhtml | 32 ++++++++++++++++++ public/images/folder.png | Bin 1026 -> 506 bytes public/images/folder_open.png | Bin 0 -> 488 bytes public/javascripts/prototype.js | 2 +- public/stylesheets/application.css | 1 + 7 files changed, 44 insertions(+), 18 deletions(-) create mode 100644 app/views/repositories/_dir_list_content.rhtml create mode 100644 public/images/folder_open.png diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 9439481e2..945cb2623 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -56,7 +56,11 @@ class RepositoriesController < ApplicationController def browse @entries = @repository.entries(@path, @rev) - show_error and return unless @entries + if request.xhr? + @entries ? render(:partial => 'dir_list_content') : render(:nothing => true) + else + show_error unless @entries + end end def changes diff --git a/app/views/repositories/_dir_list.rhtml b/app/views/repositories/_dir_list.rhtml index 5555ee87e..b9c3fd54c 100644 --- a/app/views/repositories/_dir_list.rhtml +++ b/app/views/repositories/_dir_list.rhtml @@ -1,26 +1,15 @@ - + + - - -<% total_size = 0 -@entries.each do |entry| %> - - - - - - -<% changeset = @project.repository.changesets.find_by_revision(entry.lastrev.identifier) if entry.lastrev %> - -<% total_size += entry.size if entry.size -end %> + + +<%= render :partial => 'dir_list_content' %>
<%= l(:field_name) %> <%= l(:field_filesize) %> <%= l(:label_revision) %> <%= l(:label_date) %> <%= l(:field_author) %> <%= l(:field_comments) %>
<%= link_to h(entry.name), { :action => (entry.is_dir? ? 'browse' : 'changes'), :id => @project, :path => entry.path, :rev => @rev }, :class => ("icon " + (entry.is_dir? ? 'icon-folder' : 'icon-file')) %><%= (entry.size ? number_to_human_size(entry.size) : "?") unless entry.is_dir? %><%= link_to(entry.lastrev.name, :action => 'revision', :id => @project, :rev => entry.lastrev.identifier) if entry.lastrev && entry.lastrev.identifier %><%= format_time(entry.lastrev.time) if entry.lastrev %><%=h(entry.lastrev.author) if entry.lastrev %><%=h truncate(changeset.comments, 100) unless changeset.nil? %>
-

<%= l(:label_total) %>: <%= number_to_human_size(total_size) %>

\ No newline at end of file diff --git a/app/views/repositories/_dir_list_content.rhtml b/app/views/repositories/_dir_list_content.rhtml new file mode 100644 index 000000000..742da4951 --- /dev/null +++ b/app/views/repositories/_dir_list_content.rhtml @@ -0,0 +1,32 @@ +<% @entries.each do |entry| %> +<% tr_id = Digest::MD5.hexdigest(entry.path) + depth = params[:depth].to_i %> + + +<%= if entry.is_dir? + link_to_remote h(entry.name), + {:url => {:action => 'browse', :id => @project, :path => entry.path, :rev => @rev, :depth => (depth + 1)}, + :update => tr_id, + :position => :after, + :success => "Element.addClassName('#{tr_id}', 'open');", + :condition => "!Element.hasClassName('#{tr_id}', 'open')" + }, + {:href => url_for({:action => 'browse', :id => @project, :path => entry.path, :rev => @rev}), + :class => ('icon icon-folder'), + :style => "margin-left: #{18 * depth}px;" + } +else + link_to h(entry.name), + {:action => (entry.is_dir? ? 'browse' : 'changes'), :id => @project, :path => entry.path, :rev => @rev}, + :class => 'icon icon-file', + :style => "margin-left: #{18 * depth}px;" +end %> + +<%= (entry.size ? number_to_human_size(entry.size) : "?") unless entry.is_dir? %> +<%= link_to(entry.lastrev.name, :action => 'revision', :id => @project, :rev => entry.lastrev.identifier) if entry.lastrev && entry.lastrev.identifier %> +<%= format_time(entry.lastrev.time) if entry.lastrev %> +<%=h(entry.lastrev.author) if entry.lastrev %> +<% changeset = @project.repository.changesets.find_by_revision(entry.lastrev.identifier) if entry.lastrev %> +<%=h truncate(changeset.comments, 50) unless changeset.nil? %> + +<% end %> diff --git a/public/images/folder.png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