diff --git a/init.rb b/init.rb index 8248f92..ceefa2f 100644 --- a/init.rb +++ b/init.rb @@ -15,13 +15,12 @@ end require 'redmine_custom_workflows/hooks' +require File.dirname(__FILE__) + '/lib/redmine_custom_workflows/projects_helper_patch' + Rails.application.config.to_prepare do unless Project.include?(RedmineCustomWorkflows::ProjectPatch) Project.send(:include, RedmineCustomWorkflows::ProjectPatch) end - unless ProjectsHelper.include?(RedmineCustomWorkflows::ProjectsHelperPatch) - ProjectsHelper.send(:include, RedmineCustomWorkflows::ProjectsHelperPatch) - end unless Attachment.include?(RedmineCustomWorkflows::AttachmentPatch) Attachment.send(:include, RedmineCustomWorkflows::AttachmentPatch) end @@ -52,4 +51,4 @@ Rails.application.config.to_prepare do unless ActionView::Base.include?(RedmineCustomWorkflows::Helper) ActionView::Base.send(:include, RedmineCustomWorkflows::Helper) end -end \ No newline at end of file +end diff --git a/lib/redmine_custom_workflows/projects_helper_patch.rb b/lib/redmine_custom_workflows/projects_helper_patch.rb index 458e54f..af8f4b6 100644 --- a/lib/redmine_custom_workflows/projects_helper_patch.rb +++ b/lib/redmine_custom_workflows/projects_helper_patch.rb @@ -1,20 +1,14 @@ module RedmineCustomWorkflows module ProjectsHelperPatch - def self.included(base) - base.send(:include, InstanceMethods) - base.class_eval do - alias_method_chain :project_settings_tabs, :custom_workflows - end + def project_settings_tabs + tabs = super + tabs << {:name => 'custom_workflows', :action => :manage_project_workflow, :partial => 'projects/settings/custom_workflow', + :label => :label_custom_workflow_plural} if User.current.allowed_to?(:manage_project_workflow, @project) + tabs end - module InstanceMethods - def project_settings_tabs_with_custom_workflows - tabs = project_settings_tabs_without_custom_workflows - tabs << {:name => 'custom_workflows', :action => :manage_project_workflow, :partial => 'projects/settings/custom_workflow', - :label => :label_custom_workflow_plural} if User.current.allowed_to?(:manage_project_workflow, @project) - tabs - end - end end -end \ No newline at end of file +end + +ProjectsHelper.send(:prepend, RedmineCustomWorkflows::ProjectsHelperPatch)