Added radio buttons on the documents list to sort documents by category, date, title or author.

git-svn-id: http://redmine.rubyforge.org/svn/trunk@879 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2007-11-04 11:15:04 +00:00
parent 11cf016c58
commit d4e47d5d64
22 changed files with 50 additions and 27 deletions

View File

@@ -188,7 +188,19 @@ class ProjectsController < ApplicationController
# Show documents list of @project
def list_documents
@documents = @project.documents.find :all, :include => :category
@sort_by = %w(category date title author).include?(params[:sort_by]) ? params[:sort_by] : 'category'
documents = @project.documents.find :all, :include => [:attachments, :category]
case @sort_by
when 'date'
@grouped = documents.group_by {|d| d.created_on.to_date }
when 'title'
@grouped = documents.group_by {|d| d.title.first.upcase}
when 'author'
@grouped = documents.select{|d| d.attachments.any?}.group_by {|d| d.attachments.last.author}
else
@grouped = documents.group_by(&:category)
end
render :layout => false if request.xhr?
end
# Add a new issue to @project