[phase-11]add index by rubi

This commit is contained in:
Toru Takahashi 2018-06-06 01:21:17 +09:00 committed by TAKAHASHI,Toru
parent de8ef224d4
commit f78775ac43
5 changed files with 37 additions and 2 deletions

View File

@ -5,8 +5,12 @@ 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? if not params[:index].nil?
@grouping = params[:grouping] @glossary_terms = @glossary_terms.search_by_name(params[:index])
elsif not params[:index_rubi].nil?
@glossary_terms = @glossary_terms.search_by_rubi(params[:index_rubi])
end
@grouping = params[:grouping] unless params[:grouping].nil?
end end
def new def new

View File

@ -6,4 +6,8 @@ class GlossaryTerm < ActiveRecord::Base
where 'name like ?', "#{sanitize_sql_like(keyword)}%" where 'name like ?', "#{sanitize_sql_like(keyword)}%"
} }
scope :search_by_rubi, -> (keyword) {
where 'rubi like ?', "#{sanitize_sql_like(keyword)}%"
}
end end

View File

@ -35,4 +35,15 @@
</tr> </tr>
<% end %> <% end %>
</table> </table>
<table>
<% l(:index_rubi).each_line do |line| %>
<tr>
<% line.split(" ").each do |char| %>
<td>
<%= link_to char, project_glossary_terms_path(index_rubi: char) %>
</td>
<% end %>
</tr>
<% end %>
</table>
<% end %> <% end %>

View File

@ -23,6 +23,9 @@ en:
S T U V W X S T U V W X
Y Z Y Z
index_rubi: |
permission_view_glossary: View glossary permission_view_glossary: View glossary
permission_manage_glossary: Manage glossary permission_manage_glossary: Manage glossary

View File

@ -15,6 +15,19 @@ ja:
label_grouping: グループ化 label_grouping: グループ化
label_categorized: カテゴリで分類 label_categorized: カテゴリで分類
index_rubi: |
あ い う え お
か き く け こ
さ し す せ そ
た ち つ て と
な に ぬ ね の
は ひ ふ へ ほ
ま み む め も
や ゆ よ
ら り る れ ろ
わ を ん
permission_view_glossary: 用語集の閲覧 permission_view_glossary: 用語集の閲覧
permission_manage_glossary: 用語集の管理 permission_manage_glossary: 用語集の管理