diff --git a/Gemfile b/Gemfile index 9745bdc..75ce5b8 100644 --- a/Gemfile +++ b/Gemfile @@ -22,9 +22,4 @@ source 'https://rubygems.org' do gem 'acts_as_list' gem 'activemodel-serializers-xml' - - # Redmine extensions - unless %w(easyproject easy_gantt).any? { |plugin| Dir.exist?(File.expand_path("../../#{plugin}", __FILE__)) } - gem 'redmine_extensions', '~> 0.3.9' - end end diff --git a/after_init.rb b/after_init.rb index 397868c..2e1f564 100644 --- a/after_init.rb +++ b/after_init.rb @@ -22,8 +22,6 @@ require_dependency File.dirname(__FILE__) + '/lib/redmine_custom_workflows.rb' -ActiveSupport::Dependencies.autoload_paths << File.join(File.dirname(__FILE__), 'app') - def custom_workflows_init # Administration menu extension Redmine::MenuManager.map :admin_menu do |menu| diff --git a/lib/redmine_custom_workflows.rb b/lib/redmine_custom_workflows.rb index 055527a..3c0fd7f 100644 --- a/lib/redmine_custom_workflows.rb +++ b/lib/redmine_custom_workflows.rb @@ -21,20 +21,20 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Hooks -require 'redmine_custom_workflows/hooks/hooks' +require File.dirname(__FILE__) + '/redmine_custom_workflows/hooks/views/base_view_hooks' # Errors -require 'redmine_custom_workflows/errors/workflow_error' +require File.dirname(__FILE__) + '/redmine_custom_workflows/errors/workflow_error' # Patches -require 'redmine_custom_workflows/patches/attachment_patch' -require 'redmine_custom_workflows/patches/group_patch' -require 'redmine_custom_workflows/patches/issue_patch' -require 'redmine_custom_workflows/patches/issue_relation_patch' -require 'redmine_custom_workflows/patches/project_patch' -require 'redmine_custom_workflows/patches/projects_helper_patch' -require 'redmine_custom_workflows/patches/time_entry_patch' -require 'redmine_custom_workflows/patches/user_patch' -require 'redmine_custom_workflows/patches/version_patch' -require 'redmine_custom_workflows/patches/wiki_content_patch' -require 'redmine_custom_workflows/patches/wiki_page_patch' +require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/attachment_patch' +require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/group_patch' +require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/issue_patch' +require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/issue_relation_patch' +require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/project_patch' +require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/projects_helper_patch' +require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/time_entry_patch' +require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/user_patch' +require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/version_patch' +require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/wiki_content_patch' +require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/wiki_page_patch' diff --git a/lib/redmine_custom_workflows/errors/workflow_error.rb b/lib/redmine_custom_workflows/errors/workflow_error.rb index 7613889..fb6c8f7 100644 --- a/lib/redmine_custom_workflows/errors/workflow_error.rb +++ b/lib/redmine_custom_workflows/errors/workflow_error.rb @@ -20,11 +20,16 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -class WorkflowError < StandardError - attr_accessor :error +module RedmineCustomWorkflows + module Errors - def initialize(message) - @error = message - super message + class WorkflowError < StandardError + attr_accessor :error + + def initialize(message) + @error = message + super message + end + end end -end \ No newline at end of file +end diff --git a/lib/redmine_custom_workflows/hooks/hooks.rb b/lib/redmine_custom_workflows/hooks/views/base_view_hooks.rb similarity index 72% rename from lib/redmine_custom_workflows/hooks/hooks.rb rename to lib/redmine_custom_workflows/hooks/views/base_view_hooks.rb index f9f42ae..69afe6e 100644 --- a/lib/redmine_custom_workflows/hooks/hooks.rb +++ b/lib/redmine_custom_workflows/hooks/views/base_view_hooks.rb @@ -21,14 +21,18 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. module RedmineCustomWorkflows + module Hooks + module Views - class Hooks < Redmine::Hook::ViewListener + class BaseViewHooks < Redmine::Hook::ViewListener + + def view_layouts_base_html_head(context={}) + return unless /^(CustomWorkflows|Projects)/.match?(context[:controller].class.name) + "\n".html_safe + stylesheet_link_tag('custom_workflows.css', plugin: :redmine_custom_workflows) + end + + end - def view_layouts_base_html_head(context={}) - return unless /^(CustomWorkflows|Projects)/.match?(context[:controller].class.name) - "\n".html_safe + stylesheet_link_tag('custom_workflows.css', plugin: :redmine_custom_workflows) end - end - end \ No newline at end of file diff --git a/lib/redmine_custom_workflows/patches/attachment_patch.rb b/lib/redmine_custom_workflows/patches/attachment_patch.rb index 60ffdf3..5f89b7f 100644 --- a/lib/redmine_custom_workflows/patches/attachment_patch.rb +++ b/lib/redmine_custom_workflows/patches/attachment_patch.rb @@ -24,7 +24,7 @@ module RedmineCustomWorkflows module Patches module AttachmentPatch - def self.included(base) + def self.prepended(base) base.class_eval do before_save :before_save_custom_workflows after_save :after_save_custom_workflows @@ -60,6 +60,9 @@ module RedmineCustomWorkflows end end -# Apply patch -RedmineExtensions::PatchManager.register_model_patch 'Attachment', - 'RedmineCustomWorkflows::Patches::AttachmentPatch' \ No newline at end of file +# Apply the patch +if Redmine::Plugin.installed?(:easy_extensions) + RedmineExtensions::PatchManager.register_model_patch 'Attachment', 'RedmineCustomWorkflows::Patches::AttachmentPatch' +else + Attachment.prepend RedmineCustomWorkflows::Patches::AttachmentPatch +end \ No newline at end of file diff --git a/lib/redmine_custom_workflows/patches/group_patch.rb b/lib/redmine_custom_workflows/patches/group_patch.rb index 2874dfe..ec87d33 100644 --- a/lib/redmine_custom_workflows/patches/group_patch.rb +++ b/lib/redmine_custom_workflows/patches/group_patch.rb @@ -24,7 +24,7 @@ module RedmineCustomWorkflows module Patches module GroupPatch - def self.included(base) + def self.prepended(base) base.class_eval do before_save :before_save_custom_workflows after_save :after_save_custom_workflows @@ -74,6 +74,10 @@ module RedmineCustomWorkflows end end -# Apply patch -RedmineExtensions::PatchManager.register_model_patch 'Group', - 'RedmineCustomWorkflows::Patches::GroupPatch' \ No newline at end of file +# Apply the patch +if Redmine::Plugin.installed?(:easy_extensions) + RedmineExtensions::PatchManager.register_model_patch 'Group', + 'RedmineCustomWorkflows::Patches::GroupPatch' +else + Group.prepend RedmineCustomWorkflows::Patches::GroupPatch +end \ No newline at end of file diff --git a/lib/redmine_custom_workflows/patches/issue_patch.rb b/lib/redmine_custom_workflows/patches/issue_patch.rb index 522b4d0..3ff5df4 100644 --- a/lib/redmine_custom_workflows/patches/issue_patch.rb +++ b/lib/redmine_custom_workflows/patches/issue_patch.rb @@ -24,7 +24,7 @@ module RedmineCustomWorkflows module Patches module IssuePatch - def self.included(base) + def self.prepended(base) base.class_eval do before_save :before_save_custom_workflows after_save :after_save_custom_workflows @@ -88,6 +88,9 @@ module RedmineCustomWorkflows end end -# Apply patch -RedmineExtensions::PatchManager.register_model_patch 'Issue', - 'RedmineCustomWorkflows::Patches::IssuePatch' \ No newline at end of file +# Apply the patch +if Redmine::Plugin.installed?(:easy_extensions) + RedmineExtensions::PatchManager.register_model_patch 'Issue', 'RedmineCustomWorkflows::Patches::IssuePatch' +else + Issue.prepend RedmineCustomWorkflows::Patches::IssuePatch +end \ No newline at end of file diff --git a/lib/redmine_custom_workflows/patches/issue_relation_patch.rb b/lib/redmine_custom_workflows/patches/issue_relation_patch.rb index ae90399..1733e17 100644 --- a/lib/redmine_custom_workflows/patches/issue_relation_patch.rb +++ b/lib/redmine_custom_workflows/patches/issue_relation_patch.rb @@ -24,7 +24,7 @@ module RedmineCustomWorkflows module Patches module IssueRelationPatch - def self.included(base) + def self.prepended(base) base.class_eval do before_save :before_save_custom_workflows after_save :after_save_custom_workflows @@ -73,6 +73,9 @@ module RedmineCustomWorkflows end end -# Apply patch -RedmineExtensions::PatchManager.register_model_patch 'IssueRelation', - 'RedmineCustomWorkflows::Patches::IssueRelationPatch' +# Apply the patch +if Redmine::Plugin.installed?(:easy_extensions) + RedmineExtensions::PatchManager.register_model_patch 'IssueRelation', 'RedmineCustomWorkflows::Patches::IssueRelationPatch' +else + IssueRelation.prepend RedmineCustomWorkflows::Patches::IssueRelationPatch +end diff --git a/lib/redmine_custom_workflows/patches/mailer_patch.rb b/lib/redmine_custom_workflows/patches/mailer_patch.rb index 7bdee9d..6dd3e1c 100644 --- a/lib/redmine_custom_workflows/patches/mailer_patch.rb +++ b/lib/redmine_custom_workflows/patches/mailer_patch.rb @@ -51,5 +51,9 @@ module RedmineCustomWorkflows end end -RedmineExtensions::PatchManager.register_model_patch 'Mailer', - 'RedmineCustomWorkflows::Patches::MailerPatch' \ No newline at end of file +# Apply the patch +if Redmine::Plugin.installed?(:easy_extensions) + RedmineExtensions::PatchManager.register_model_patch 'Mailer', 'RedmineCustomWorkflows::Patches::MailerPatch' +else + Mailer.prepend RedmineCustomWorkflows::Patches::MailerPatch +end \ No newline at end of file diff --git a/lib/redmine_custom_workflows/patches/project_patch.rb b/lib/redmine_custom_workflows/patches/project_patch.rb index 2083ef6..9052ac8 100644 --- a/lib/redmine_custom_workflows/patches/project_patch.rb +++ b/lib/redmine_custom_workflows/patches/project_patch.rb @@ -24,7 +24,7 @@ module RedmineCustomWorkflows module Patches module ProjectPatch - def self.included(base) + def self.prepended(base) base.class_eval do has_and_belongs_to_many :custom_workflows safe_attributes :custom_workflow_ids, if: @@ -75,6 +75,9 @@ module RedmineCustomWorkflows end end -# Apply patch -RedmineExtensions::PatchManager.register_model_patch 'Project', - 'RedmineCustomWorkflows::Patches::ProjectPatch' \ No newline at end of file +# Apply the patch +if Redmine::Plugin.installed?(:easy_extensions) + RedmineExtensions::PatchManager.register_model_patch 'Project', 'RedmineCustomWorkflows::Patches::ProjectPatch' +else + Project.prepend RedmineCustomWorkflows::Patches::ProjectPatch +end \ No newline at end of file diff --git a/lib/redmine_custom_workflows/patches/projects_helper_patch.rb b/lib/redmine_custom_workflows/patches/projects_helper_patch.rb index 4385c2d..3f1c012 100644 --- a/lib/redmine_custom_workflows/patches/projects_helper_patch.rb +++ b/lib/redmine_custom_workflows/patches/projects_helper_patch.rb @@ -35,6 +35,7 @@ module RedmineCustomWorkflows end end +# Apply the patch if Redmine::Plugin.installed?(:easy_extensions) RedmineExtensions::PatchManager.register_helper_patch 'ProjectsHelper', 'RedmineCustomWorkflows::Patches::ProjectsHelperPatch', prepend: true diff --git a/lib/redmine_custom_workflows/patches/time_entry_patch.rb b/lib/redmine_custom_workflows/patches/time_entry_patch.rb index e688157..b29d1b9 100644 --- a/lib/redmine_custom_workflows/patches/time_entry_patch.rb +++ b/lib/redmine_custom_workflows/patches/time_entry_patch.rb @@ -24,7 +24,7 @@ module RedmineCustomWorkflows module Patches module TimeEntryPatch - def self.included(base) + def self.prepended(base) base.class_eval do before_save :before_save_custom_workflows after_save :after_save_custom_workflows @@ -60,6 +60,9 @@ module RedmineCustomWorkflows end end -# Apply patch -RedmineExtensions::PatchManager.register_model_patch 'TimeEntry', - 'RedmineCustomWorkflows::Patches::TimeEntryPatch' \ No newline at end of file +# Apply the patch +if Redmine::Plugin.installed?(:easy_extensions) + RedmineExtensions::PatchManager.register_model_patch 'TimeEntry', 'RedmineCustomWorkflows::Patches::TimeEntryPatch' +else + TimeEntry.prepend RedmineCustomWorkflows::Patches::TimeEntryPatch +end \ No newline at end of file diff --git a/lib/redmine_custom_workflows/patches/user_patch.rb b/lib/redmine_custom_workflows/patches/user_patch.rb index 4132c96..824f893 100644 --- a/lib/redmine_custom_workflows/patches/user_patch.rb +++ b/lib/redmine_custom_workflows/patches/user_patch.rb @@ -24,7 +24,7 @@ module RedmineCustomWorkflows module Patches module UserPatch - def self.included(base) + def self.prepended(base) base.class_eval do before_save :before_save_custom_workflows after_save :after_save_custom_workflows @@ -60,6 +60,9 @@ module RedmineCustomWorkflows end end -# Apply patch -RedmineExtensions::PatchManager.register_model_patch 'User', - 'RedmineCustomWorkflows::Patches::UserPatch' \ No newline at end of file +# Apply the patch +if Redmine::Plugin.installed?(:easy_extensions) + RedmineExtensions::PatchManager.register_model_patch 'User', 'RedmineCustomWorkflows::Patches::UserPatch' +else + User.prepend RedmineCustomWorkflows::Patches::UserPatch +end \ No newline at end of file diff --git a/lib/redmine_custom_workflows/patches/version_patch.rb b/lib/redmine_custom_workflows/patches/version_patch.rb index 3a0b88c..fc7f67d 100644 --- a/lib/redmine_custom_workflows/patches/version_patch.rb +++ b/lib/redmine_custom_workflows/patches/version_patch.rb @@ -24,7 +24,7 @@ module RedmineCustomWorkflows module Patches module VersionPatch - def self.included(base) + def self.prepended(base) base.class_eval do before_save :before_save_custom_workflows after_save :after_save_custom_workflows @@ -60,6 +60,9 @@ module RedmineCustomWorkflows end end -# Apply patch -RedmineExtensions::PatchManager.register_model_patch 'Version', -'RedmineCustomWorkflows::Patches::VersionPatch' \ No newline at end of file +# Apply the patch +if Redmine::Plugin.installed?(:easy_extensions) + RedmineExtensions::PatchManager.register_model_patch 'Version', 'RedmineCustomWorkflows::Patches::VersionPatch' +else + Version.prepend RedmineCustomWorkflows::Patches::VersionPatch +end \ No newline at end of file diff --git a/lib/redmine_custom_workflows/patches/wiki_content_patch.rb b/lib/redmine_custom_workflows/patches/wiki_content_patch.rb index f21f329..68f5537 100644 --- a/lib/redmine_custom_workflows/patches/wiki_content_patch.rb +++ b/lib/redmine_custom_workflows/patches/wiki_content_patch.rb @@ -24,7 +24,7 @@ module RedmineCustomWorkflows module Patches module WikiContentPatch - def self.included(base) + def self.prepended(base) base.class_eval do before_save :before_save_custom_workflows after_save :after_save_custom_workflows @@ -60,6 +60,9 @@ module RedmineCustomWorkflows end end -# Apply patch -RedmineExtensions::PatchManager.register_model_patch 'WikiContent', - 'RedmineCustomWorkflows::Patches::WikiContentPatch' \ No newline at end of file +# Apply the patch +if Redmine::Plugin.installed?(:easy_extensions) + RedmineExtensions::PatchManager.register_model_patch 'WikiContent', 'RedmineCustomWorkflows::Patches::WikiContentPatch' +else + WikiContent.prepend RedmineCustomWorkflows::Patches::WikiContentPatch +end \ No newline at end of file diff --git a/lib/redmine_custom_workflows/patches/wiki_page_patch.rb b/lib/redmine_custom_workflows/patches/wiki_page_patch.rb index 863c330..b076b75 100644 --- a/lib/redmine_custom_workflows/patches/wiki_page_patch.rb +++ b/lib/redmine_custom_workflows/patches/wiki_page_patch.rb @@ -24,7 +24,7 @@ module RedmineCustomWorkflows module Patches module WikiPagePatch - def self.included(base) + def self.prepended(base) base.class_eval do def self.attachments_callback(event, page, attachment) page.instance_variable_set :@page, page @@ -43,6 +43,9 @@ module RedmineCustomWorkflows end end -# Apply patch -RedmineExtensions::PatchManager.register_model_patch 'WikiPage', - 'RedmineCustomWorkflows::Patches::WikiPagePatch' \ No newline at end of file +# Apply the patch +if Redmine::Plugin.installed?(:easy_extensions) + RedmineExtensions::PatchManager.register_model_patch 'WikiPage', 'RedmineCustomWorkflows::Patches::WikiPagePatch' +else + WikiPage.prepend RedmineCustomWorkflows::Patches::WikiPagePatch +end \ No newline at end of file