[phase-10]add radio_button to select terms view with grouping by categories or without grouping.
This commit is contained in:
parent
088b2fa081
commit
de8ef224d4
@ -6,6 +6,7 @@ class GlossaryTermsController < ApplicationController
|
|||||||
def index
|
def index
|
||||||
@glossary_terms = GlossaryTerm.where(project_id: @project.id)
|
@glossary_terms = GlossaryTerm.where(project_id: @project.id)
|
||||||
@glossary_terms = @glossary_terms.search_by_name(params[:index]) unless params[:index].nil?
|
@glossary_terms = @glossary_terms.search_by_name(params[:index]) unless params[:index].nil?
|
||||||
|
@grouping = params[:grouping]
|
||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
|
@ -1,6 +1,17 @@
|
|||||||
<% content_for :sidebar do %>
|
<% content_for :sidebar do %>
|
||||||
<h3><%=l :label_view %></h3>
|
<h3><%=l :label_view %></h3>
|
||||||
|
|
||||||
|
<%= form_with url: project_glossary_terms_path, method: :get, local: true do |form| %>
|
||||||
|
<fieldset>
|
||||||
|
<legend><%=l :label_grouping %></legend>
|
||||||
|
<%= 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 %>
|
||||||
|
</fieldset>
|
||||||
|
<%= form.submit l(:label_view) %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<h3><%=l :label_glossary_term %></h3>
|
<h3><%=l :label_glossary_term %></h3>
|
||||||
<p><%= link_to_if_authorized l(:label_glossary_term_new),
|
<p><%= link_to_if_authorized l(:label_glossary_term_new),
|
||||||
{ controller: :glossary_terms, action: :new, project_id: @project },
|
{ controller: :glossary_terms, action: :new, project_id: @project },
|
||||||
|
@ -8,15 +8,19 @@
|
|||||||
|
|
||||||
<%= render partial: 'sidebar' %>
|
<%= render partial: 'sidebar' %>
|
||||||
|
|
||||||
|
<% if @grouping == '1' %>
|
||||||
<% categorized_terms = @glossary_terms.reject { |t| t.category_id.nil? } %>
|
<% categorized_terms = @glossary_terms.reject { |t| t.category_id.nil? } %>
|
||||||
<% uncategorized_terms = @glossary_terms.where(category_id: nil) %>
|
<% uncategorized_terms = @glossary_terms.where(category_id: nil) %>
|
||||||
|
|
||||||
<% categorized_terms.group_by(&:category).each do |category, terms| %>
|
<% categorized_terms.group_by(&:category).each do |category, terms| %>
|
||||||
<h3><%= category.name %></h3>
|
<h3><%= category.name %></h3>
|
||||||
<%= render partial: 'index_in_category', locals: {terms: terms} %>
|
<%= render partial: 'index_terms', locals: {terms: terms} %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<h3><%=l :label_not_categorized %></h3>
|
<h3><%=l :label_not_categorized %></h3>
|
||||||
<%= render 'index_in_category', terms: uncategorized_terms %>
|
<%= render 'index_terms', terms: uncategorized_terms %>
|
||||||
|
<% else %>
|
||||||
|
<%= render 'index_terms', terms: @glossary_terms %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,6 +13,8 @@ en:
|
|||||||
label_view: View
|
label_view: View
|
||||||
label_glossary_index: index
|
label_glossary_index: index
|
||||||
label_not_categorized: Not categorized
|
label_not_categorized: Not categorized
|
||||||
|
label_grouping: Grouping
|
||||||
|
label_categorized: Categorized
|
||||||
|
|
||||||
index_en: |
|
index_en: |
|
||||||
A B C D E F
|
A B C D E F
|
||||||
|
@ -12,6 +12,8 @@ ja:
|
|||||||
label_view: 表示
|
label_view: 表示
|
||||||
label_glossary_index: 索引
|
label_glossary_index: 索引
|
||||||
label_not_categorized: 未分類
|
label_not_categorized: 未分類
|
||||||
|
label_grouping: グループ化
|
||||||
|
label_categorized: カテゴリで分類
|
||||||
|
|
||||||
permission_view_glossary: 用語集の閲覧
|
permission_view_glossary: 用語集の閲覧
|
||||||
permission_manage_glossary: 用語集の管理
|
permission_manage_glossary: 用語集の管理
|
||||||
|
Loading…
Reference in New Issue
Block a user