リビジョン de8ef224
| app/controllers/glossary_terms_controller.rb | ||
|---|---|---|
|
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
|
||
| app/views/glossary_terms/_index_in_category.html.erb | ||
|---|---|---|
|
<table class="list">
|
||
|
<thead>
|
||
|
<tr>
|
||
|
<th>#</th>
|
||
|
<th><%=l :field_name %></th>
|
||
|
<th><%=l :field_category %></th>
|
||
|
<th><%=l :field_description %></th>
|
||
|
</tr>
|
||
|
</thead>
|
||
|
<tbody>
|
||
|
<% terms.each do |term| %>
|
||
|
<tr>
|
||
|
<td class="id">
|
||
|
<%= term.id %>
|
||
|
</td>
|
||
|
<td class="name">
|
||
|
<%= link_to term.name, [@project, term] %>
|
||
|
</td>
|
||
|
<td class="roles">
|
||
|
<%= term.category.try!(:name) %>
|
||
|
</td>
|
||
|
<td class="description">
|
||
|
<%= term.description %>
|
||
|
</td>
|
||
|
</tr>
|
||
|
<% end %>
|
||
|
</tbody>
|
||
|
</table>
|
||
| app/views/glossary_terms/_index_terms.html.erb | ||
|---|---|---|
|
<table class="list">
|
||
|
<thead>
|
||
|
<tr>
|
||
|
<th>#</th>
|
||
|
<th><%=l :field_name %></th>
|
||
|
<th><%=l :field_category %></th>
|
||
|
<th><%=l :field_description %></th>
|
||
|
</tr>
|
||
|
</thead>
|
||
|
<tbody>
|
||
|
<% terms.each do |term| %>
|
||
|
<tr>
|
||
|
<td class="id">
|
||
|
<%= term.id %>
|
||
|
</td>
|
||
|
<td class="name">
|
||
|
<%= link_to term.name, [@project, term] %>
|
||
|
</td>
|
||
|
<td class="roles">
|
||
|
<%= term.category.try!(:name) %>
|
||
|
</td>
|
||
|
<td class="description">
|
||
|
<%= term.description %>
|
||
|
</td>
|
||
|
</tr>
|
||
|
<% end %>
|
||
|
</tbody>
|
||
|
</table>
|
||
| app/views/glossary_terms/_sidebar.html.erb | ||
|---|---|---|
|
<% content_for :sidebar do %>
|
||
|
<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>
|
||
|
<p><%= link_to_if_authorized l(:label_glossary_term_new),
|
||
|
{ controller: :glossary_terms, action: :new, project_id: @project },
|
||
| app/views/glossary_terms/index.html.erb | ||
|---|---|---|
|
|
||
|
<%= 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| %>
|
||
|
<h3><%= category.name %></h3>
|
||
|
<%= render partial: 'index_in_category', locals: {terms: terms} %>
|
||
|
<% end %>
|
||
|
<% categorized_terms.group_by(&:category).each do |category, terms| %>
|
||
|
<h3><%= category.name %></h3>
|
||
|
<%= render partial: 'index_terms', locals: {terms: terms} %>
|
||
|
<% end %>
|
||
|
|
||
|
<h3><%=l :label_not_categorized %></h3>
|
||
|
<%= render 'index_in_category', terms: uncategorized_terms %>
|
||
|
<h3><%=l :label_not_categorized %></h3>
|
||
|
<%= render 'index_terms', terms: uncategorized_terms %>
|
||
|
<% else %>
|
||
|
<%= render 'index_terms', terms: @glossary_terms %>
|
||
|
<% end %>
|
||
|
|
||
|
|
||
| config/locales/en.yml | ||
|---|---|---|
|
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
|
||
| config/locales/ja.yml | ||
|---|---|---|
|
label_view: 表示
|
||
|
label_glossary_index: 索引
|
||
|
label_not_categorized: 未分類
|
||
|
label_grouping: グループ化
|
||
|
label_categorized: カテゴリで分類
|
||
|
|
||
|
permission_view_glossary: 用語集の閲覧
|
||
|
permission_manage_glossary: 用語集の管理
|
||
[phase-10]add radio_button to select terms view with grouping by categories or without grouping.