リビジョン b1b7d669
| 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?
|
||
|
end
|
||
|
|
||
|
def new
|
||
| app/models/glossary_term.rb | ||
|---|---|---|
|
class GlossaryTerm < ActiveRecord::Base
|
||
|
belongs_to :category, class_name: 'GlossaryCategory', foreign_key: 'category_id'
|
||
|
belongs_to :project
|
||
|
|
||
|
scope :search_by_name, -> (keyword) {
|
||
|
where 'name like ?', "#{sanitize_sql_like(keyword)}%"
|
||
|
}
|
||
|
|
||
|
end
|
||
| app/views/glossary_terms/_sidebar.html.erb | ||
|---|---|---|
|
<% content_for :sidebar do %>
|
||
|
<h3><%=l :label_view %></h3>
|
||
|
|
||
|
<h3><%=l :label_glossary_term %></h3>
|
||
|
<p><%= link_to l(:label_glossary_term_new), new_project_glossary_term_path,
|
||
|
class: 'icon icon-add' %></p>
|
||
|
|
||
|
<h3><%=l :label_glossary_category %></h3>
|
||
|
<p><%= link_to l(:label_glossary_category_new),
|
||
|
new_project_glossary_category_path, class: 'icon icon-add' %></p>
|
||
|
<p><%= link_to l(:label_glossary_categories),
|
||
|
project_glossary_categories_path %></p>
|
||
|
|
||
|
<h3><%=l :label_glossary_index %></h3>
|
||
|
<table>
|
||
|
<% l(:index_en).each_line do |line| %>
|
||
|
<tr>
|
||
|
<% line.split(" ").each do |ch| %>
|
||
|
<td><%= link_to ch, project_glossary_terms_path(index: ch) %></td>
|
||
|
<% end %>
|
||
|
</tr>
|
||
|
<% end %>
|
||
|
</table>
|
||
|
<% end %>
|
||
| app/views/glossary_terms/index.html.erb | ||
|---|---|---|
|
<div class="contextual">
|
||
|
<%= link_to l(:label_glossary_term_new), new_project_glossary_term_path, class: 'icon icon-add' %>
|
||
|
</div>
|
||
|
|
||
|
|
||
|
<%= render partial: 'sidebar' %>
|
||
|
|
||
|
<table class="list">
|
||
|
<thead>
|
||
|
<tr>
|
||
| config/locales/en.yml | ||
|---|---|---|
|
label_glossary_category: "Glossary category"
|
||
|
label_glossary_category_new: "New glossary category"
|
||
|
|
||
|
glossary_title: Glossary
|
||
|
glossary_title: Glossary
|
||
|
|
||
|
label_view: View
|
||
|
label_glossary_index: index
|
||
|
|
||
|
index_en: |
|
||
|
A B C D E F
|
||
|
G H I J K L
|
||
|
M N O P Q R
|
||
|
S T U V W X
|
||
|
Y Z
|
||
|
|
||
| config/locales/ja.yml | ||
|---|---|---|
|
label_glossary_terms: "用語集"
|
||
|
label_glossary_term: "用語"
|
||
|
label_glossary_term_new: "用語の作成"
|
||
|
label_glossary_categories: "用語のカテゴリ"
|
||
|
label_glossary_categories: "用語のカテゴリ一覧"
|
||
|
label_glossary_category: "用語のカテゴリ"
|
||
|
label_glossary_category_new: "カテゴリの作成"
|
||
|
glossary_title: 用語集
|
||
|
glossary_title: 用語集
|
||
|
|
||
|
label_view: 表示
|
||
|
label_glossary_index: 索引
|
||
|
|
||
[phase-7]add sidebar with some links, index link and search