[phase-7]add sidebar with some links, index link and search
This commit is contained in:
parent
5fa6412720
commit
b1b7d66976
@ -5,6 +5,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?
|
||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
|
@ -1,4 +1,9 @@
|
|||||||
class GlossaryTerm < ActiveRecord::Base
|
class GlossaryTerm < ActiveRecord::Base
|
||||||
belongs_to :category, class_name: 'GlossaryCategory', foreign_key: 'category_id'
|
belongs_to :category, class_name: 'GlossaryCategory', foreign_key: 'category_id'
|
||||||
belongs_to :project
|
belongs_to :project
|
||||||
|
|
||||||
|
scope :search_by_name, -> (keyword) {
|
||||||
|
where 'name like ?', "#{sanitize_sql_like(keyword)}%"
|
||||||
|
}
|
||||||
|
|
||||||
end
|
end
|
||||||
|
24
app/views/glossary_terms/_sidebar.html.erb
Normal file
24
app/views/glossary_terms/_sidebar.html.erb
Normal 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 %>
|
@ -4,6 +4,8 @@
|
|||||||
<%= link_to l(:label_glossary_term_new), new_project_glossary_term_path, class: 'icon icon-add' %>
|
<%= link_to l(:label_glossary_term_new), new_project_glossary_term_path, class: 'icon icon-add' %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<%= render partial: 'sidebar' %>
|
||||||
|
|
||||||
<table class="list">
|
<table class="list">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -8,3 +8,14 @@ en:
|
|||||||
label_glossary_category_new: "New 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
|
||||||
|
|
@ -2,7 +2,11 @@ ja:
|
|||||||
label_glossary_terms: "用語集"
|
label_glossary_terms: "用語集"
|
||||||
label_glossary_term: "用語"
|
label_glossary_term: "用語"
|
||||||
label_glossary_term_new: "用語の作成"
|
label_glossary_term_new: "用語の作成"
|
||||||
label_glossary_categories: "用語のカテゴリ"
|
label_glossary_categories: "用語のカテゴリ一覧"
|
||||||
label_glossary_category: "用語のカテゴリ"
|
label_glossary_category: "用語のカテゴリ"
|
||||||
label_glossary_category_new: "カテゴリの作成"
|
label_glossary_category_new: "カテゴリの作成"
|
||||||
glossary_title: 用語集
|
glossary_title: 用語集
|
||||||
|
|
||||||
|
label_view: 表示
|
||||||
|
label_glossary_index: 索引
|
||||||
|
|
Loading…
Reference in New Issue
Block a user