RE: Time & Expense 1.6 ยป init.rb.patch
| init.rb 2014-03-10 13:47:13.000000000 -0500 | ||
|---|---|---|
|
base.send(:include, InstanceMethods)
|
||
|
|
||
|
base.class_eval do
|
||
|
alias_method_chain :custom_fields_tabs, :wktime_tab
|
||
|
if Redmine::VERSION::MAJOR >= 2 && Redmine::VERSION::MINOR >= 5
|
||
|
alias_method_chain :render_custom_fields_tabs, :render_wktime_tab
|
||
|
alias_method_chain :custom_field_type_options, :wktime_tab_options
|
||
|
else
|
||
|
alias_method_chain :custom_fields_tabs, :wktime_tab
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
|
||
|
module InstanceMethods
|
||
|
# Adds a wktime tab to the custom fields administration page
|
||
|
def custom_fields_tabs_with_wktime_tab
|
||
|
tabs = custom_fields_tabs_without_wktime_tab
|
||
|
# Code added to check if the tab already exist - to fix the multiple tab issue
|
||
|
appendTab = true
|
||
|
tabs.each do |tab|
|
||
|
if tab[:name].eql? 'WktimeCustomField'
|
||
|
appendTab = false
|
||
|
break
|
||
|
end
|
||
|
end
|
||
|
if appendTab
|
||
|
tabs << {:name => 'WktimeCustomField', :partial => 'custom_fields/index', :label => :label_wk_time}
|
||
|
end
|
||
|
return tabs
|
||
|
add_wktime_cf
|
||
|
custom_fields_tabs_without_wktime_tab
|
||
|
end
|
||
|
|
||
|
def render_custom_fields_tabs_with_render_wktime_tab(types)
|
||
|
add_wktime_cf
|
||
|
render_custom_fields_tabs_without_render_wktime_tab(types)
|
||
|
end
|
||
|
|
||
|
def custom_field_type_options_with_wktime_tab_options
|
||
|
add_wktime_cf
|
||
|
custom_field_type_options_without_wktime_tab_options
|
||
|
end
|
||
|
|
||
|
private
|
||
|
|
||
|
def add_wktime_cf
|
||
|
cf = {:name => 'WktimeCustomField', :partial => 'custom_fields/index', :label => :label_wk_time}
|
||
|
unless CustomFieldsHelper::CUSTOM_FIELDS_TABS.index { |f| f[:name] == cf[:name] }
|
||
|
CustomFieldsHelper::CUSTOM_FIELDS_TABS << cf
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
|
||
|
CustomFieldsHelper.send(:include, WktimeHelperPatch)
|
||
|
# Apply patch
|
||
|
Rails.configuration.to_prepare do
|
||
|
unless CustomFieldsHelper.included_modules.include?(WktimeHelperPatch)
|
||
|
CustomFieldsHelper.send(:include, WktimeHelperPatch)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
Redmine::Plugin.register :redmine_wktime do
|
||
|
name 'Time & Expense'
|
||