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:
parent
11cf016c58
commit
d4e47d5d64
|
@ -188,7 +188,19 @@ class ProjectsController < ApplicationController
|
||||||
|
|
||||||
# Show documents list of @project
|
# Show documents list of @project
|
||||||
def list_documents
|
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
|
end
|
||||||
|
|
||||||
# Add a new issue to @project
|
# Add a new issue to @project
|
||||||
|
|
|
@ -138,7 +138,7 @@ module SortHelper
|
||||||
#
|
#
|
||||||
def sort_header_tag(column, options = {})
|
def sort_header_tag(column, options = {})
|
||||||
caption = options.delete(:caption) || titleize(Inflector::humanize(column))
|
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)
|
content_tag('th', sort_link(column, caption), options)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,10 @@ class Enumeration < ActiveRecord::Base
|
||||||
Enumeration.update_all("is_default = #{connection.quoted_false}", {:opt => opt}) if is_default?
|
Enumeration.update_all("is_default = #{connection.quoted_false}", {:opt => opt}) if is_default?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def <=>(enumeration)
|
||||||
|
position <=> enumeration.position
|
||||||
|
end
|
||||||
|
|
||||||
def to_s; name end
|
def to_s; name end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -19,12 +19,19 @@
|
||||||
|
|
||||||
<h2><%=l(:label_document_plural)%></h2>
|
<h2><%=l(:label_document_plural)%></h2>
|
||||||
|
|
||||||
<% if @documents.empty? %>
|
<% if @grouped.empty? %><p class="nodata"><%= l(:label_no_data) %></p><% end %>
|
||||||
<p class="nodata"><%= l(:label_no_data) %></p>
|
|
||||||
|
<% @grouped.keys.sort.each do |group| %>
|
||||||
|
<h3><%= group %></h3>
|
||||||
|
<%= render :partial => 'documents/document', :collection => @grouped[group] %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% documents = @documents.group_by {|d| d.category } %>
|
<% content_for :sidebar do %>
|
||||||
<% documents.each do |category, docs| %>
|
<h3><%= l(:label_sort_by, '') %></h3>
|
||||||
<h3><%= category.name %></h3>
|
<% form_tag({}, :method => :get) do %>
|
||||||
<%= render :partial => 'documents/document', :collection => docs %>
|
<label><%= radio_button_tag 'sort_by', 'category', (@sort_by == 'category'), :onclick => 'this.form.submit();' %> <%= l(:field_category) %></label><br />
|
||||||
<% end %>
|
<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 %>
|
||||||
|
|
|
@ -416,7 +416,7 @@ label_week: Седмица
|
||||||
label_date_from: От
|
label_date_from: От
|
||||||
label_date_to: До
|
label_date_to: До
|
||||||
label_language_based: В зависимост от езика
|
label_language_based: В зависимост от езика
|
||||||
label_sort_by: Sort by "%s"
|
label_sort_by: Sort by %s
|
||||||
label_send_test_email: Изпращане на тестов e-mail
|
label_send_test_email: Изпращане на тестов e-mail
|
||||||
label_feeds_access_key_created_on: %s от създаването на RSS ключа
|
label_feeds_access_key_created_on: %s от създаването на RSS ключа
|
||||||
label_module_plural: Модули
|
label_module_plural: Модули
|
||||||
|
|
|
@ -414,7 +414,7 @@ label_week: Týden
|
||||||
label_date_from: Od
|
label_date_from: Od
|
||||||
label_date_to: Do
|
label_date_to: Do
|
||||||
label_language_based: Language based
|
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_send_test_email: Poslat testovací email
|
||||||
label_feeds_access_key_created_on: Přístupový klíč pro RSS byl vytvořen před %s
|
label_feeds_access_key_created_on: Přístupový klíč pro RSS byl vytvořen před %s
|
||||||
|
|
||||||
|
|
|
@ -416,7 +416,7 @@ label_week: Woche
|
||||||
label_date_from: Von
|
label_date_from: Von
|
||||||
label_date_to: Bis
|
label_date_to: Bis
|
||||||
label_language_based: Sprachabhängig
|
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_send_test_email: Test-E-Mail senden
|
||||||
label_feeds_access_key_created_on: RSS-Zugriffsschlüssel vor %s erstellt
|
label_feeds_access_key_created_on: RSS-Zugriffsschlüssel vor %s erstellt
|
||||||
label_module_plural: Module
|
label_module_plural: Module
|
||||||
|
|
|
@ -427,7 +427,7 @@ label_week: Week
|
||||||
label_date_from: From
|
label_date_from: From
|
||||||
label_date_to: To
|
label_date_to: To
|
||||||
label_language_based: Language based
|
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_send_test_email: Send a test email
|
||||||
label_feeds_access_key_created_on: RSS access key created %s ago
|
label_feeds_access_key_created_on: RSS access key created %s ago
|
||||||
label_module_plural: Modules
|
label_module_plural: Modules
|
||||||
|
|
|
@ -501,7 +501,7 @@ label_this_week: this week
|
||||||
label_index_by_title: Index by title
|
label_index_by_title: Index by title
|
||||||
label_jump_to_a_project: Jump to a project...
|
label_jump_to_a_project: Jump to a project...
|
||||||
field_assignable: Issues can be assigned to this role
|
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
|
setting_issue_list_default_columns: Default columns displayed on the issue list
|
||||||
text_issue_updated: Issue %s has been updated.
|
text_issue_updated: Issue %s has been updated.
|
||||||
notice_feeds_access_key_reseted: Your RSS access key was reseted.
|
notice_feeds_access_key_reseted: Your RSS access key was reseted.
|
||||||
|
|
|
@ -427,7 +427,7 @@ label_week: Semaine
|
||||||
label_date_from: Du
|
label_date_from: Du
|
||||||
label_date_to: Au
|
label_date_to: Au
|
||||||
label_language_based: Basé sur la langue
|
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_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_feeds_access_key_created_on: Clé d'accès RSS créée il y a %s
|
||||||
label_module_plural: Modules
|
label_module_plural: Modules
|
||||||
|
|
|
@ -421,7 +421,7 @@ label_week: שבו
|
||||||
label_date_from: מאת
|
label_date_from: מאת
|
||||||
label_date_to: אל
|
label_date_to: אל
|
||||||
label_language_based: מבוסס שפה
|
label_language_based: מבוסס שפה
|
||||||
label_sort_by: מין לפי "%s"
|
label_sort_by: מין לפי %s
|
||||||
label_send_test_email: שלח דו"ל בדיקה
|
label_send_test_email: שלח דו"ל בדיקה
|
||||||
label_feeds_access_key_created_on: מפתח הזנת RSS נוצר לפני%s
|
label_feeds_access_key_created_on: מפתח הזנת RSS נוצר לפני%s
|
||||||
label_module_plural: מודולים
|
label_module_plural: מודולים
|
||||||
|
|
|
@ -416,7 +416,7 @@ label_week: Week
|
||||||
label_date_from: From
|
label_date_from: From
|
||||||
label_date_to: To
|
label_date_to: To
|
||||||
label_language_based: Language based
|
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_send_test_email: Send a test email
|
||||||
label_feeds_access_key_created_on: RSS access key created %s ago
|
label_feeds_access_key_created_on: RSS access key created %s ago
|
||||||
label_module_plural: Modules
|
label_module_plural: Modules
|
||||||
|
|
|
@ -417,7 +417,7 @@ label_week: Week
|
||||||
label_date_from: From
|
label_date_from: From
|
||||||
label_date_to: To
|
label_date_to: To
|
||||||
label_language_based: 既定の言語の設定に従う
|
label_language_based: 既定の言語の設定に従う
|
||||||
label_sort_by: Sort by "%s"
|
label_sort_by: Sort by %s
|
||||||
label_send_test_email: テストメールを送信
|
label_send_test_email: テストメールを送信
|
||||||
label_feeds_access_key_created_on: RSS access key created %s ago
|
label_feeds_access_key_created_on: RSS access key created %s ago
|
||||||
label_module_plural: Modules
|
label_module_plural: Modules
|
||||||
|
|
|
@ -423,7 +423,7 @@ label_week: 주
|
||||||
label_date_from: From
|
label_date_from: From
|
||||||
label_date_to: To
|
label_date_to: To
|
||||||
label_language_based: Language based
|
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_send_test_email: Send a test email
|
||||||
label_feeds_access_key_created_on: RSS access key created %s ago
|
label_feeds_access_key_created_on: RSS access key created %s ago
|
||||||
label_module_plural: Modules
|
label_module_plural: Modules
|
||||||
|
|
|
@ -416,7 +416,7 @@ label_week: Week
|
||||||
label_date_from: From
|
label_date_from: From
|
||||||
label_date_to: To
|
label_date_to: To
|
||||||
label_language_based: Language based
|
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_send_test_email: Send a test email
|
||||||
label_feeds_access_key_created_on: RSS access key created %s ago
|
label_feeds_access_key_created_on: RSS access key created %s ago
|
||||||
label_module_plural: Modules
|
label_module_plural: Modules
|
||||||
|
|
|
@ -497,7 +497,7 @@ label_module_plural: Moduły
|
||||||
label_this_week: ten tydzień
|
label_this_week: ten tydzień
|
||||||
label_jump_to_a_project: Skocz do projektu...
|
label_jump_to_a_project: Skocz do projektu...
|
||||||
field_assignable: Zgłoszenia mogą być przypisane do tej roli
|
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.
|
text_issue_updated: Zgłoszenie %s zostało zaktualizowane.
|
||||||
notice_feeds_access_key_reseted: Twój klucz dostępu RSS został zrestetowany.
|
notice_feeds_access_key_reseted: Twój klucz dostępu RSS został zrestetowany.
|
||||||
field_redirect_existing_links: Przekierowanie istniejących odnośników
|
field_redirect_existing_links: Przekierowanie istniejących odnośników
|
||||||
|
|
|
@ -416,7 +416,7 @@ label_week: Week
|
||||||
label_date_from: From
|
label_date_from: From
|
||||||
label_date_to: To
|
label_date_to: To
|
||||||
label_language_based: Language based
|
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_send_test_email: Send a test email
|
||||||
label_feeds_access_key_created_on: RSS access key created %s ago
|
label_feeds_access_key_created_on: RSS access key created %s ago
|
||||||
label_module_plural: Modules
|
label_module_plural: Modules
|
||||||
|
|
|
@ -416,7 +416,7 @@ label_week: Week
|
||||||
label_date_from: From
|
label_date_from: From
|
||||||
label_date_to: To
|
label_date_to: To
|
||||||
label_language_based: Language based
|
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_send_test_email: Send a test email
|
||||||
label_feeds_access_key_created_on: RSS access key created %s ago
|
label_feeds_access_key_created_on: RSS access key created %s ago
|
||||||
label_module_plural: Modules
|
label_module_plural: Modules
|
||||||
|
|
|
@ -414,7 +414,7 @@ label_week: Saptamana
|
||||||
label_date_from: De la
|
label_date_from: De la
|
||||||
label_date_to: Pentru
|
label_date_to: Pentru
|
||||||
label_language_based: Bazat pe limbaj
|
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_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_feeds_access_key_created_on: Parola de acces RSS creat cu %s mai devreme
|
||||||
label_module_plural: Module
|
label_module_plural: Module
|
||||||
|
|
|
@ -426,7 +426,7 @@ label_week: Nedelja
|
||||||
label_date_from: Od
|
label_date_from: Od
|
||||||
label_date_to: Do
|
label_date_to: Do
|
||||||
label_language_based: Bazirano na jeziku
|
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_send_test_email: Pošalji probni email
|
||||||
label_feeds_access_key_created_on: RSS ključ za pristup je kreiran pre %s
|
label_feeds_access_key_created_on: RSS ključ za pristup je kreiran pre %s
|
||||||
label_module_plural: Modulovi
|
label_module_plural: Modulovi
|
||||||
|
|
|
@ -416,7 +416,7 @@ label_week: Week
|
||||||
label_date_from: From
|
label_date_from: From
|
||||||
label_date_to: To
|
label_date_to: To
|
||||||
label_language_based: Language based
|
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_send_test_email: Send a test email
|
||||||
label_feeds_access_key_created_on: RSS access key created %s ago
|
label_feeds_access_key_created_on: RSS access key created %s ago
|
||||||
label_module_plural: Modules
|
label_module_plural: Modules
|
||||||
|
|
|
@ -418,7 +418,7 @@ label_week: Week
|
||||||
label_date_from: From
|
label_date_from: From
|
||||||
label_date_to: To
|
label_date_to: To
|
||||||
label_language_based: Language based
|
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_send_test_email: Send a test email
|
||||||
label_feeds_access_key_created_on: RSS access key created %s ago
|
label_feeds_access_key_created_on: RSS access key created %s ago
|
||||||
label_module_plural: Modules
|
label_module_plural: Modules
|
||||||
|
|
Loading…
Reference in New Issue