diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 394e545d0..ae9c242e0 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -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 diff --git a/app/helpers/sort_helper.rb b/app/helpers/sort_helper.rb index e1e87cbbb..dfd681fff 100644 --- a/app/helpers/sort_helper.rb +++ b/app/helpers/sort_helper.rb @@ -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 diff --git a/app/models/enumeration.rb b/app/models/enumeration.rb index 744bc1a88..400681a43 100644 --- a/app/models/enumeration.rb +++ b/app/models/enumeration.rb @@ -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 diff --git a/app/views/projects/list_documents.rhtml b/app/views/projects/list_documents.rhtml index 595b15fd1..bb272ee86 100644 --- a/app/views/projects/list_documents.rhtml +++ b/app/views/projects/list_documents.rhtml @@ -19,12 +19,19 @@

<%=l(:label_document_plural)%>

-<% if @documents.empty? %> -

<%= l(:label_no_data) %>

+<% if @grouped.empty? %>

<%= l(:label_no_data) %>

<% end %> + +<% @grouped.keys.sort.each do |group| %> +

<%= group %>

+ <%= render :partial => 'documents/document', :collection => @grouped[group] %> <% end %> -<% documents = @documents.group_by {|d| d.category } %> -<% documents.each do |category, docs| %> -

<%= category.name %>

- <%= render :partial => 'documents/document', :collection => docs %> -<% end %> \ No newline at end of file +<% content_for :sidebar do %> +

<%= l(:label_sort_by, '') %>

+ <% form_tag({}, :method => :get) do %> +
+
+
+ + <% end %> +<% end %> diff --git a/lang/bg.yml b/lang/bg.yml index 469792535..07360a3c4 100644 --- a/lang/bg.yml +++ b/lang/bg.yml @@ -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: Модули diff --git a/lang/cs.yml b/lang/cs.yml index d62746633..86d9a494c 100644 --- a/lang/cs.yml +++ b/lang/cs.yml @@ -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 diff --git a/lang/de.yml b/lang/de.yml index 9a5fcee2b..c1acaa367 100644 --- a/lang/de.yml +++ b/lang/de.yml @@ -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 diff --git a/lang/en.yml b/lang/en.yml index 2ab4c11a2..480f30a13 100644 --- a/lang/en.yml +++ b/lang/en.yml @@ -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 diff --git a/lang/es.yml b/lang/es.yml index e93fb5bd8..16a2d3ac3 100644 --- a/lang/es.yml +++ b/lang/es.yml @@ -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. diff --git a/lang/fr.yml b/lang/fr.yml index 1f35272c1..9bd28c082 100644 --- a/lang/fr.yml +++ b/lang/fr.yml @@ -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 diff --git a/lang/he.yml b/lang/he.yml index 73f72d5bb..97fa51e06 100644 --- a/lang/he.yml +++ b/lang/he.yml @@ -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: מודולים diff --git a/lang/it.yml b/lang/it.yml index 224843e0e..03442eb41 100644 --- a/lang/it.yml +++ b/lang/it.yml @@ -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 diff --git a/lang/ja.yml b/lang/ja.yml index caf0f292e..226f56569 100644 --- a/lang/ja.yml +++ b/lang/ja.yml @@ -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 diff --git a/lang/ko.yml b/lang/ko.yml index 6629a14b0..2ff051e80 100644 --- a/lang/ko.yml +++ b/lang/ko.yml @@ -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 diff --git a/lang/nl.yml b/lang/nl.yml index f43f5a5b9..820242869 100644 --- a/lang/nl.yml +++ b/lang/nl.yml @@ -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 diff --git a/lang/pl.yml b/lang/pl.yml index e636afe5b..ea7485d2d 100644 --- a/lang/pl.yml +++ b/lang/pl.yml @@ -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 diff --git a/lang/pt-br.yml b/lang/pt-br.yml index 707baffcd..bce1d2630 100644 --- a/lang/pt-br.yml +++ b/lang/pt-br.yml @@ -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 diff --git a/lang/pt.yml b/lang/pt.yml index 687ab512b..e9233f333 100644 --- a/lang/pt.yml +++ b/lang/pt.yml @@ -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 diff --git a/lang/ro.yml b/lang/ro.yml index f31bd6f84..b6002ac87 100644 --- a/lang/ro.yml +++ b/lang/ro.yml @@ -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 diff --git a/lang/sr.yml b/lang/sr.yml index d95855731..39ae09da3 100644 --- a/lang/sr.yml +++ b/lang/sr.yml @@ -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 diff --git a/lang/sv.yml b/lang/sv.yml index 0cd4f1a1f..df814fbae 100644 --- a/lang/sv.yml +++ b/lang/sv.yml @@ -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 diff --git a/lang/zh.yml b/lang/zh.yml index 715010922..6b3d095e5 100644 --- a/lang/zh.yml +++ b/lang/zh.yml @@ -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