6 |
6 |
base.send(:include, InstanceMethods)
|
7 |
7 |
|
8 |
8 |
base.class_eval do
|
9 |
|
alias_method_chain :custom_fields_tabs, :wktime_tab
|
|
9 |
if Redmine::VERSION::MAJOR >= 2 && Redmine::VERSION::MINOR >= 5
|
|
10 |
alias_method_chain :render_custom_fields_tabs, :render_wktime_tab
|
|
11 |
alias_method_chain :custom_field_type_options, :wktime_tab_options
|
|
12 |
else
|
|
13 |
alias_method_chain :custom_fields_tabs, :wktime_tab
|
|
14 |
end
|
10 |
15 |
end
|
11 |
16 |
end
|
12 |
17 |
|
13 |
18 |
module InstanceMethods
|
14 |
19 |
# Adds a wktime tab to the custom fields administration page
|
15 |
20 |
def custom_fields_tabs_with_wktime_tab
|
16 |
|
tabs = custom_fields_tabs_without_wktime_tab
|
17 |
|
# Code added to check if the tab already exist - to fix the multiple tab issue
|
18 |
|
appendTab = true
|
19 |
|
tabs.each do |tab|
|
20 |
|
if tab[:name].eql? 'WktimeCustomField'
|
21 |
|
appendTab = false
|
22 |
|
break
|
23 |
|
end
|
24 |
|
end
|
25 |
|
if appendTab
|
26 |
|
tabs << {:name => 'WktimeCustomField', :partial => 'custom_fields/index', :label => :label_wk_time}
|
27 |
|
end
|
28 |
|
return tabs
|
|
21 |
add_wktime_cf
|
|
22 |
custom_fields_tabs_without_wktime_tab
|
29 |
23 |
end
|
|
24 |
|
|
25 |
def render_custom_fields_tabs_with_render_wktime_tab(types)
|
|
26 |
add_wktime_cf
|
|
27 |
render_custom_fields_tabs_without_render_wktime_tab(types)
|
|
28 |
end
|
|
29 |
|
|
30 |
def custom_field_type_options_with_wktime_tab_options
|
|
31 |
add_wktime_cf
|
|
32 |
custom_field_type_options_without_wktime_tab_options
|
|
33 |
end
|
|
34 |
|
|
35 |
private
|
|
36 |
|
|
37 |
def add_wktime_cf
|
|
38 |
cf = {:name => 'WktimeCustomField', :partial => 'custom_fields/index', :label => :label_wk_time}
|
|
39 |
unless CustomFieldsHelper::CUSTOM_FIELDS_TABS.index { |f| f[:name] == cf[:name] }
|
|
40 |
CustomFieldsHelper::CUSTOM_FIELDS_TABS << cf
|
|
41 |
end
|
|
42 |
end
|
30 |
43 |
end
|
31 |
44 |
end
|
32 |
45 |
|
33 |
|
CustomFieldsHelper.send(:include, WktimeHelperPatch)
|
|
46 |
# Apply patch
|
|
47 |
Rails.configuration.to_prepare do
|
|
48 |
unless CustomFieldsHelper.included_modules.include?(WktimeHelperPatch)
|
|
49 |
CustomFieldsHelper.send(:include, WktimeHelperPatch)
|
|
50 |
end
|
|
51 |
end
|
34 |
52 |
|
35 |
53 |
Redmine::Plugin.register :redmine_wktime do
|
36 |
54 |
name 'Time & Expense'
|