This commit is contained in:
Karel.Picman 2022-03-16 13:17:06 +01:00
parent a6f1716fb9
commit d441310db4
17 changed files with 112 additions and 74 deletions

View File

@ -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

View File

@ -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|

View File

@ -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'

View File

@ -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
end

View File

@ -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

View File

@ -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'
# 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

View File

@ -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'
# 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

View File

@ -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'
# 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

View File

@ -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

View File

@ -51,5 +51,9 @@ module RedmineCustomWorkflows
end
end
RedmineExtensions::PatchManager.register_model_patch 'Mailer',
'RedmineCustomWorkflows::Patches::MailerPatch'
# 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

View File

@ -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'
# 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

View File

@ -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

View File

@ -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'
# 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

View File

@ -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'
# 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

View File

@ -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'
# 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

View File

@ -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'
# 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

View File

@ -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'
# 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