From 088b2fa08169a2d4d950918cef6d0a9245f63836 Mon Sep 17 00:00:00 2001 From: Toru Takahashi Date: Sun, 27 May 2018 00:33:05 +0900 Subject: [PATCH] [phase-10]modified terms index with category grouping --- .../_index_in_category.html.erb | 28 +++++++++++++ app/views/glossary_terms/index.html.erb | 40 ++++++------------- config/locales/en.yml | 3 +- config/locales/ja.yml | 3 +- 4 files changed, 44 insertions(+), 30 deletions(-) create mode 100644 app/views/glossary_terms/_index_in_category.html.erb diff --git a/app/views/glossary_terms/_index_in_category.html.erb b/app/views/glossary_terms/_index_in_category.html.erb new file mode 100644 index 0000000..81015f8 --- /dev/null +++ b/app/views/glossary_terms/_index_in_category.html.erb @@ -0,0 +1,28 @@ + + + + + + + + + + + <% terms.each do |term| %> + + + + + + + <% end %> + +
#<%=l :field_name %><%=l :field_category %><%=l :field_description %>
+ <%= term.id %> + + <%= link_to term.name, [@project, term] %> + + <%= term.category.try!(:name) %> + + <%= term.description %> +
diff --git a/app/views/glossary_terms/index.html.erb b/app/views/glossary_terms/index.html.erb index a9d6326..3e237a8 100644 --- a/app/views/glossary_terms/index.html.erb +++ b/app/views/glossary_terms/index.html.erb @@ -8,31 +8,15 @@ <%= render partial: 'sidebar' %> - - - - - - - - - - - <% @glossary_terms.each do |term| %> - - - - - - - <% end %> - -
#<%=l :field_name %><%=l :field_category %><%=l :field_description %>
- <%= term.id %> - - <%= link_to term.name, [@project, term] %> - - <%= term.category.try!(:name) %> - - <%= term.description %> -
+<% categorized_terms = @glossary_terms.reject { |t| t.category_id.nil? } %> +<% uncategorized_terms = @glossary_terms.where(category_id: nil) %> + +<% categorized_terms.group_by(&:category).each do |category, terms| %> +

<%= category.name %>

+ <%= render partial: 'index_in_category', locals: {terms: terms} %> +<% end %> + +

<%=l :label_not_categorized %>

+<%= render 'index_in_category', terms: uncategorized_terms %> + + diff --git a/config/locales/en.yml b/config/locales/en.yml index 22d97eb..238ea40 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -12,7 +12,8 @@ en: label_view: View label_glossary_index: index - + label_not_categorized: Not categorized + index_en: | A B C D E F G H I J K L diff --git a/config/locales/ja.yml b/config/locales/ja.yml index ebc1266..d997de3 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -10,7 +10,8 @@ ja: project_module_glossary: 用語集 label_view: 表示 - label_glossary_index: 索引 + label_glossary_index: 索引 + label_not_categorized: 未分類 permission_view_glossary: 用語集の閲覧 permission_manage_glossary: 用語集の管理