diff --git a/app/controllers/glossary_terms_controller.rb b/app/controllers/glossary_terms_controller.rb index 6292367..12aa62b 100644 --- a/app/controllers/glossary_terms_controller.rb +++ b/app/controllers/glossary_terms_controller.rb @@ -6,6 +6,7 @@ class GlossaryTermsController < ApplicationController def index @glossary_terms = GlossaryTerm.where(project_id: @project.id) @glossary_terms = @glossary_terms.search_by_name(params[:index]) unless params[:index].nil? + @grouping = params[:grouping] end def new diff --git a/app/views/glossary_terms/_index_in_category.html.erb b/app/views/glossary_terms/_index_terms.html.erb similarity index 100% rename from app/views/glossary_terms/_index_in_category.html.erb rename to app/views/glossary_terms/_index_terms.html.erb diff --git a/app/views/glossary_terms/_sidebar.html.erb b/app/views/glossary_terms/_sidebar.html.erb index dda5e16..4232024 100644 --- a/app/views/glossary_terms/_sidebar.html.erb +++ b/app/views/glossary_terms/_sidebar.html.erb @@ -1,6 +1,17 @@ <% content_for :sidebar do %>

<%=l :label_view %>

+ <%= form_with url: project_glossary_terms_path, method: :get, local: true do |form| %> +
+ <%=l :label_grouping %> + <%= form.radio_button :grouping, 1, checked: @grouping == '1' ? 'checked' : nil %> + <%= form.label :grouping, l(:label_categorized), vaule: 1 %> + <%= form.radio_button :grouping, 0, checked: @grouping == '0' ? 'checked' : nil %> + <%= form.label :grouping, l(:label_not_categorized), value: 0 %> +
+ <%= form.submit l(:label_view) %> + <% end %> +

<%=l :label_glossary_term %>

<%= link_to_if_authorized l(:label_glossary_term_new), { controller: :glossary_terms, action: :new, project_id: @project }, diff --git a/app/views/glossary_terms/index.html.erb b/app/views/glossary_terms/index.html.erb index 3e237a8..5d5a996 100644 --- a/app/views/glossary_terms/index.html.erb +++ b/app/views/glossary_terms/index.html.erb @@ -8,15 +8,19 @@ <%= render partial: 'sidebar' %> -<% categorized_terms = @glossary_terms.reject { |t| t.category_id.nil? } %> -<% uncategorized_terms = @glossary_terms.where(category_id: nil) %> +<% if @grouping == '1' %> + <% 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} %> + <% categorized_terms.group_by(&:category).each do |category, terms| %> +

<%= category.name %>

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

<%=l :label_not_categorized %>

+ <%= render 'index_terms', terms: uncategorized_terms %> +<% else %> + <%= render 'index_terms', terms: @glossary_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 238ea40..c4a8839 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -13,6 +13,8 @@ en: label_view: View label_glossary_index: index label_not_categorized: Not categorized + label_grouping: Grouping + label_categorized: Categorized index_en: | A B C D E F diff --git a/config/locales/ja.yml b/config/locales/ja.yml index d997de3..2034a95 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -12,6 +12,8 @@ ja: label_view: 表示 label_glossary_index: 索引 label_not_categorized: 未分類 + label_grouping: グループ化 + label_categorized: カテゴリで分類 permission_view_glossary: 用語集の閲覧 permission_manage_glossary: 用語集の管理