mirror of
https://github.com/redmine/redmine.git
synced 2026-05-06 15:17:23 +02:00
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:
@@ -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
|
||||
|
||||
@@ -138,7 +138,7 @@ module SortHelper
|
||||
#
|
||||
def sort_header_tag(column, options = {})
|
||||
caption = options.delete(:caption) || titleize(Inflector::humanize(column))
|
||||
options[:title]= l(:label_sort_by, caption) unless options[:title]
|
||||
options[:title]= l(:label_sort_by, "\"#{caption}\"") unless options[:title]
|
||||
content_tag('th', sort_link(column, caption), options)
|
||||
end
|
||||
|
||||
|
||||
@@ -47,6 +47,10 @@ class Enumeration < ActiveRecord::Base
|
||||
Enumeration.update_all("is_default = #{connection.quoted_false}", {:opt => opt}) if is_default?
|
||||
end
|
||||
|
||||
def <=>(enumeration)
|
||||
position <=> enumeration.position
|
||||
end
|
||||
|
||||
def to_s; name end
|
||||
|
||||
private
|
||||
|
||||
@@ -19,12 +19,19 @@
|
||||
|
||||
<h2><%=l(:label_document_plural)%></h2>
|
||||
|
||||
<% if @documents.empty? %>
|
||||
<p class="nodata"><%= l(:label_no_data) %></p>
|
||||
<% if @grouped.empty? %><p class="nodata"><%= l(:label_no_data) %></p><% end %>
|
||||
|
||||
<% @grouped.keys.sort.each do |group| %>
|
||||
<h3><%= group %></h3>
|
||||
<%= render :partial => 'documents/document', :collection => @grouped[group] %>
|
||||
<% end %>
|
||||
|
||||
<% documents = @documents.group_by {|d| d.category } %>
|
||||
<% documents.each do |category, docs| %>
|
||||
<h3><%= category.name %></h3>
|
||||
<%= render :partial => 'documents/document', :collection => docs %>
|
||||
<% end %>
|
||||
<% content_for :sidebar do %>
|
||||
<h3><%= l(:label_sort_by, '') %></h3>
|
||||
<% form_tag({}, :method => :get) do %>
|
||||
<label><%= radio_button_tag 'sort_by', 'category', (@sort_by == 'category'), :onclick => 'this.form.submit();' %> <%= l(:field_category) %></label><br />
|
||||
<label><%= radio_button_tag 'sort_by', 'date', (@sort_by == 'date'), :onclick => 'this.form.submit();' %> <%= l(:label_date) %></label><br />
|
||||
<label><%= radio_button_tag 'sort_by', 'title', (@sort_by == 'title'), :onclick => 'this.form.submit();' %> <%= l(:field_title) %></label><br />
|
||||
<label><%= radio_button_tag 'sort_by', 'author', (@sort_by == 'author'), :onclick => 'this.form.submit();' %> <%= l(:field_author) %></label>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
Reference in New Issue
Block a user