我如何将"花费时间"添加为要在问题列表中显示的列?
巩固Eric和Joel的答案,这就是我需要做的就是在Redmine 1.0.3中添加一个"花费时间"列.不确定是否有更好的方法来添加翻译文本.
要为新字段指定一个本地化名称,请在字段定义末尾的第299行添加到config/locales/en.yml:
field_spent_hours: Spent time
要添加新列,请使用内容创建lib/spent_time_query_patch.rb:
# Based on http://github.com/edavis10/question_plugin/blob/master/lib/question_query_patch.rb
require_dependency 'query'
module QueryPatch
def self.included(base) # :nodoc:
base.extend(ClassMethods)
# Same as typing in the class
base.class_eval do
unloadable # Send unloadable so it will not be unloaded in development
base.add_available_column(QueryColumn.new(:spent_hours))
end
end
module ClassMethods
unless Query.respond_to?(:available_columns=)
# Setter for +available_columns+ that isn't provided by the core.
def available_columns=(v)
self.available_columns = (v)
end
end
unless Query.respond_to?(:add_available_column)
# Method to add a column to the +available_columns+ that isn't provided by the core.
def add_available_column(column)
self.available_columns << (column)
end
end
end
end
要使上面的spent_time_query_patch实际加载,请创建包含内容的config/initializers/spent_time_query_patch.rb:
require 'spent_time_query_patch' Query.class_eval do include QueryPatch end
您也可以通过在运行时添加列来完成此操作.这将添加花费的小时列而不修改Redmine核心.只需将以下代码放入lib /中的文件中
改编自:
Redmine预算插件
Redmine问题插件
require_dependency 'query' module QueryPatch def self.included(base) # :nodoc: base.extend(ClassMethods) # Same as typing in the class base.class_eval do unloadable # Send unloadable so it will not be unloaded in development base.add_available_column(QueryColumn.new(:spent_hours)) end end module ClassMethods unless Query.respond_to?(:available_columns=) # Setter for +available_columns+ that isn't provided by the core. def available_columns=(v) self.available_columns = (v) end end unless Query.respond_to?(:add_available_column) # Method to add a column to the +available_columns+ that isn't provided by the core. def add_available_column(column) self.available_columns