Use project helper instead of helper patch

This commit is contained in:
Alexander Meindl
2018-07-27 19:49:36 +02:00
parent f670a44c66
commit 4f5868cc57
4 changed files with 20 additions and 32 deletions

View File

@@ -18,7 +18,7 @@ Rails.configuration.to_prepare do
# Patches
require_dependency 'redmine_messenger/patches/issue_patch'
require_dependency 'redmine_messenger/patches/wiki_page_patch'
require_dependency 'redmine_messenger/patches/projects_helper_patch'
ProjectsController.send :helper, MessengerProjectsHelper
require 'redmine_messenger/patches/contact_patch' if RedmineMessenger::REDMINE_CONTACTS_SUPPORT
require 'redmine_messenger/patches/db_entry_patch' if RedmineMessenger::REDMINE_DB_SUPPORT

View File

@@ -1,30 +0,0 @@
module RedmineMessenger
module Patches
module ProjectsHelperPatch
def self.included(base)
base.send(:include, InstanceMethods)
base.class_eval do
alias_method :project_settings_tabs_without_messenger, :project_settings_tabs
alias_method :project_settings_tabs, :project_settings_tabs_with_messenger
end
end
module InstanceMethods
def project_settings_tabs_with_messenger
tabs = project_settings_tabs_without_messenger
action = { name: 'messenger',
action: :show,
partial: 'messenger_settings/show',
label: :label_messenger }
tabs << action if User.current.allowed_to?(:manage_messenger, @project)
tabs
end
end
end
end
end
unless ProjectsHelper.included_modules.include?(RedmineMessenger::Patches::ProjectsHelperPatch)
ProjectsHelper.send(:include, RedmineMessenger::Patches::ProjectsHelperPatch)
end