我创建了一个插件。我想在项目设置中添加任何设置。我想在redmine项目设置中创建一个带有我的设置的新选项卡。我使用redmine版本3.1.0.devel。我能做些什么呢?
更新
这是一个代码,我使用@General Failure
帮助创建require 'projects_helper'
module ProjectsHelperPatch
def self.included(base)
base.send(:include, InstanceMethods)
base.send(:include, ApplicationHelper)
base.class_eval do
unloadable
alias_method_chain :project_settings_tabs, :sph
end
end
module InstanceMethods
def project_settings_tabs_with_sph
abort('asdasd')
tabs = project_settings_tabs_without_sph
tabs.push({ :name => 'some_name',
:action => :some_action,
:partial => 'projects/settings/some_page',
:label => :label_some_label })
return tabs
end
end
end
ProjectsHelper.send:include,ProjectsHelperPatch
init.rb:
require_relative '../../plugins/sph/app/patches/controllers/projects_helper_patch'
但它的代码不起作用。为什么呢?
答案 0 :(得分:2)
您可以修补ProjectsHelper
课程并将alias_method_chain添加到project_settings_tabs
方法,请参阅Redmine论坛上的topic。
在:partial => 'projects/settings/some_page'
中,部分值是插件中视图的相对路径,也必须添加到routes.rb
。
如果您还有任何疑问,请在评论中提问。
<小时/> 更新:
我的Redmine修补(没有添加设置标签,只是修补示例):
require_dependency 'issues_controller'
module IssuesControllerPatch
def self.included(base) # :nodoc:
base.send(:include, InstanceMethods)
base.send(:include, ApplicationHelper) # You can use helpers in patches
base.class_eval do
unloadable # Send unloadable so it will not be unloaded in development
alias_method_chain :new, :patch
end
end
module InstanceMethods
def new_with_patch
my_action # my code
new_without_land_using # call original method
end
end
end
end
IssuesController.send :include, IssuesControllerPatch
init.rb
行:
require 'patches/controllers/issues_controller_patch'