プロジェクト

全般

プロフィール

« | » 

リビジョン 517decb4

高徹 高橋 徹 さんが約6年前に追加

[phase-22]Make it possible to search from redmine global search function.

差分を表示:

app/models/glossary_term.rb
belongs_to :category, class_name: 'GlossaryCategory', foreign_key: 'category_id'
belongs_to :project
belongs_to :author, class_name: 'User', foreign_key: 'author_id'
belongs_to :updater, class_name: 'User', foreign_key: 'updater_id'
# class method from Redmine::Acts::Attachable::ClassMethods
acts_as_attachable view_permission: :view_glossary, edit_permission: :manage_glossary, delete_permission: :manage_glossary
acts_as_attachable view_permission: :view_glossary_terms, edit_permission: :manage_glossary_terms,
delete_permission: :manage_glossary_terms
acts_as_event datetime: :updated_at,
description: :description,
......
project_id: o.project }
}
acts_as_searchable columns: [ "#{table_name}.name", "#{table_name}.description", "#{table_name}.rubi"],
preload: [:project ],
date_column: "#{table_name}.created_at",
scope: joins(:project),
permission: :view_glossary_terms
acts_as_activity_provider scope: joins(:project),
type: 'glossary_terms',
permission: :view_glossary,
permission: :view_glossary_terms,
timestamp: :updated_at
scope :search_by_name, -> (keyword) {
where 'name like ?', "#{sanitize_sql_like(keyword)}%"
}
app/views/glossary_terms/show.html.erb
<%= render partial: 'attachments/links',
locals: {attachments: @term.attachments,
options: {deletable: User.current.allowed_to?(:manage_glossary, @project)}
options: {deletable: User.current.allowed_to?(:manage_glossary_terms, @project)}
}%>
config/locales/en.yml
index_rubi: |
permission_view_glossary: View glossary
permission_manage_glossary: Manage glossary
permission_view_glossary_terms: View glossary
permission_manage_glossary_terms: Manage glossary
field_name_en: English
field_abbr_whole: Whole word for Abbreviation
config/locales/ja.yml
わ を ん
permission_view_glossary: 用語集の閲覧
permission_manage_glossary: 用語集の管理
permission_view_glossary_terms: 用語集の閲覧
permission_manage_glossary_terms: 用語集の管理
field_name_en: 英語名
field_abbr_whole: 略語の展開名称
init.rb
Rails.configuration.to_prepare do
require_dependency "glossary_macros"
Redmine::Activity.register :glossary_terms
Redmine::Search.available_search_types << 'glossary_terms'
end
Redmine::Plugin.register :redmine_glossary do
......
project_module :glossary do
permission :view_glossary, {
permission :view_glossary_terms, {
glossary_terms: [:index, :show],
glossary_categories: [:index, :show]
}
permission :manage_glossary, {
permission :manage_glossary_terms, {
glossary_terms: [:new, :create, :edit, :update, :destroy],
glossary_categories: [:new, :create, :edit, :update, :destroy],
},
......
param: :project_id
end
Redmine::Activity.register :glossary_terms

他の形式にエクスポート: Unified diff