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

View File

@ -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

View File

@ -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

View File

@ -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 %>

View File

@ -416,7 +416,7 @@ label_week: Седмица
label_date_from: От
label_date_to: До
label_language_based: В зависимост от езика
label_sort_by: Sort by "%s"
label_sort_by: Sort by %s
label_send_test_email: Изпращане на тестов e-mail
label_feeds_access_key_created_on: %s от създаването на RSS ключа
label_module_plural: Модули

View File

@ -414,7 +414,7 @@ label_week: Týden
label_date_from: Od
label_date_to: Do
label_language_based: Language based
label_sort_by: Seřadit podle "%s"
label_sort_by: Seřadit podle %s
label_send_test_email: Poslat testovací email
label_feeds_access_key_created_on: Přístupový klíč pro RSS byl vytvořen před %s

View File

@ -416,7 +416,7 @@ label_week: Woche
label_date_from: Von
label_date_to: Bis
label_language_based: Sprachabhängig
label_sort_by: Sortiert nach "%s"
label_sort_by: Sortiert nach %s
label_send_test_email: Test-E-Mail senden
label_feeds_access_key_created_on: RSS-Zugriffsschlüssel vor %s erstellt
label_module_plural: Module

View File

@ -427,7 +427,7 @@ label_week: Week
label_date_from: From
label_date_to: To
label_language_based: Language based
label_sort_by: Sort by "%s"
label_sort_by: Sort by %s
label_send_test_email: Send a test email
label_feeds_access_key_created_on: RSS access key created %s ago
label_module_plural: Modules

View File

@ -501,7 +501,7 @@ label_this_week: this week
label_index_by_title: Index by title
label_jump_to_a_project: Jump to a project...
field_assignable: Issues can be assigned to this role
label_sort_by: Sort by "%s"
label_sort_by: Sort by %s
setting_issue_list_default_columns: Default columns displayed on the issue list
text_issue_updated: Issue %s has been updated.
notice_feeds_access_key_reseted: Your RSS access key was reseted.

View File

@ -427,7 +427,7 @@ label_week: Semaine
label_date_from: Du
label_date_to: Au
label_language_based: Basé sur la langue
label_sort_by: Trier par "%s"
label_sort_by: Trier par %s
label_send_test_email: Envoyer un email de test
label_feeds_access_key_created_on: Clé d'accès RSS créée il y a %s
label_module_plural: Modules

View File

@ -421,7 +421,7 @@ label_week: שבו
label_date_from: מאת
label_date_to: אל
label_language_based: מבוסס שפה
label_sort_by: מין לפי "%s"
label_sort_by: מין לפי %s
label_send_test_email: שלח דו"ל בדיקה
label_feeds_access_key_created_on: מפתח הזנת RSS נוצר לפני%s
label_module_plural: מודולים

View File

@ -416,7 +416,7 @@ label_week: Week
label_date_from: From
label_date_to: To
label_language_based: Language based
label_sort_by: Sort by "%s"
label_sort_by: Sort by %s
label_send_test_email: Send a test email
label_feeds_access_key_created_on: RSS access key created %s ago
label_module_plural: Modules

View File

@ -417,7 +417,7 @@ label_week: Week
label_date_from: From
label_date_to: To
label_language_based: 既定の言語の設定に従う
label_sort_by: Sort by "%s"
label_sort_by: Sort by %s
label_send_test_email: テストメールを送信
label_feeds_access_key_created_on: RSS access key created %s ago
label_module_plural: Modules

View File

@ -423,7 +423,7 @@ label_week: 주
label_date_from: From
label_date_to: To
label_language_based: Language based
label_sort_by: Sort by "%s"
label_sort_by: Sort by %s
label_send_test_email: Send a test email
label_feeds_access_key_created_on: RSS access key created %s ago
label_module_plural: Modules

View File

@ -416,7 +416,7 @@ label_week: Week
label_date_from: From
label_date_to: To
label_language_based: Language based
label_sort_by: Sort by "%s"
label_sort_by: Sort by %s
label_send_test_email: Send a test email
label_feeds_access_key_created_on: RSS access key created %s ago
label_module_plural: Modules

View File

@ -497,7 +497,7 @@ label_module_plural: Moduły
label_this_week: ten tydzień
label_jump_to_a_project: Skocz do projektu...
field_assignable: Zgłoszenia mogą być przypisane do tej roli
label_sort_by: Sortuj po "%s"
label_sort_by: Sortuj po %s
text_issue_updated: Zgłoszenie %s zostało zaktualizowane.
notice_feeds_access_key_reseted: Twój klucz dostępu RSS został zrestetowany.
field_redirect_existing_links: Przekierowanie istniejących odnośników

View File

@ -416,7 +416,7 @@ label_week: Week
label_date_from: From
label_date_to: To
label_language_based: Language based
label_sort_by: Sort by "%s"
label_sort_by: Sort by %s
label_send_test_email: Send a test email
label_feeds_access_key_created_on: RSS access key created %s ago
label_module_plural: Modules

View File

@ -416,7 +416,7 @@ label_week: Week
label_date_from: From
label_date_to: To
label_language_based: Language based
label_sort_by: Sort by "%s"
label_sort_by: Sort by %s
label_send_test_email: Send a test email
label_feeds_access_key_created_on: RSS access key created %s ago
label_module_plural: Modules

View File

@ -414,7 +414,7 @@ label_week: Saptamana
label_date_from: De la
label_date_to: Pentru
label_language_based: Bazat pe limbaj
label_sort_by: Sortare dupa "%s"
label_sort_by: Sortare dupa %s
label_send_test_email: trimite un e-mail de test
label_feeds_access_key_created_on: Parola de acces RSS creat cu %s mai devreme
label_module_plural: Module

View File

@ -426,7 +426,7 @@ label_week: Nedelja
label_date_from: Od
label_date_to: Do
label_language_based: Bazirano na jeziku
label_sort_by: Sortiraj po "%s"
label_sort_by: Sortiraj po %s
label_send_test_email: Pošalji probni email
label_feeds_access_key_created_on: RSS ključ za pristup je kreiran pre %s
label_module_plural: Modulovi

View File

@ -416,7 +416,7 @@ label_week: Week
label_date_from: From
label_date_to: To
label_language_based: Language based
label_sort_by: Sort by "%s"
label_sort_by: Sort by %s
label_send_test_email: Send a test email
label_feeds_access_key_created_on: RSS access key created %s ago
label_module_plural: Modules

View File

@ -418,7 +418,7 @@ label_week: Week
label_date_from: From
label_date_to: To
label_language_based: Language based
label_sort_by: Sort by "%s"
label_sort_by: Sort by %s
label_send_test_email: Send a test email
label_feeds_access_key_created_on: RSS access key created %s ago
label_module_plural: Modules