[phase-7]add sidebar with some links, index link and search

This commit is contained in:
Toru Takahashi 2018-05-20 04:43:22 +09:00 committed by TAKAHASHI,Toru
parent 5fa6412720
commit b1b7d66976
6 changed files with 51 additions and 4 deletions

View File

@ -5,6 +5,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?
end
def new

View File

@ -1,4 +1,9 @@
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

View File

@ -0,0 +1,24 @@
<% 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 %>

View File

@ -3,7 +3,9 @@
<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>

View File

@ -7,4 +7,15 @@ en:
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

View File

@ -2,7 +2,11 @@ ja:
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: 索引