Skip to content
This repository has been archived by the owner on Oct 1, 2020. It is now read-only.

fixes the tracker patch so tracker config can be saved again #20 #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion init.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
require_dependency 'workflow_enhancements/hooks'
require_dependency 'workflow_enhancements/patches/action_view_rendering'
require_dependency 'workflow_enhancements/patches/tracker_patch'

Redmine::Plugin.register :redmine_workflow_enhancements do
name 'Redmine Workflow Enhancements'
Expand All @@ -16,3 +15,8 @@
permission :workflow_graph_view, :workflow_enhancements => :show
end
end

Rails.configuration.to_prepare do
WorkflowEnhancements::Patches::TrackerPatch.apply
end

48 changes: 28 additions & 20 deletions lib/workflow_enhancements/patches/tracker_patch.rb
Original file line number Diff line number Diff line change
@@ -1,29 +1,37 @@
require_dependency 'tracker'
module WorkflowEnhancements
module Patches
module TrackerPatch
def self.apply
unless Tracker < self
Tracker.prepend self
Tracker.class_eval do
safe_attributes :predef_issue_status_ids
has_many :tracker_statuses
has_many :predef_issue_statuses, :through => :tracker_statuses
end
end
end

class Tracker
has_many :tracker_statuses
has_many :predef_issue_statuses, :through => :tracker_statuses
def issue_statuses
if @issue_statuses
return @issue_statuses
elsif new_record?
return []
end

def issue_statuses_with_workflow_enhancements
if @issue_statuses
return @issue_statuses
elsif new_record?
return []
end

ids = WorkflowTransition.connection.select_rows(
"SELECT DISTINCT old_status_id, new_status_id
ids = WorkflowTransition.connection.select_rows(
"SELECT DISTINCT old_status_id, new_status_id
FROM #{WorkflowTransition.table_name}
WHERE tracker_id = #{id} AND type = 'WorkflowTransition'").flatten
ids.concat TrackerStatus.connection.select_rows(
"SELECT issue_status_id
ids.concat TrackerStatus.connection.select_rows(
"SELECT issue_status_id
FROM #{TrackerStatus.table_name}
WHERE tracker_id = #{id}")

ids = ids.flatten.uniq
@issue_statuses = IssueStatus.where(:id => ids).all.sort
end
ids = ids.flatten.uniq
@issue_statuses = IssueStatus.where(:id => ids).all.sort
end
end

alias_method_chain :issue_statuses, :workflow_enhancements
end
end