From b429ee23a873382f191681f4c3652c78cf5fdb12 Mon Sep 17 00:00:00 2001 From: Eric Davis Date: Wed, 21 May 2008 11:51:28 -0700 Subject: [PATCH] Fully hooked the Deliverable columns into the filters and Queries * The Deliverable subject can now be filtered on the issues list * The Deliverable subject can now be displayed on the issues lists with as a default column or part of a saved query * The issues can be sorted by the deliverable #1148 --- init.rb | 1 + lang/en.yml | 1 + lib/issue_patch.rb | 50 ++++++++++++++++++++++++++++++++++++++++++++++ lib/query_patch.rb | 2 +- 4 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 lib/issue_patch.rb diff --git a/init.rb b/init.rb index 6f08650..4d94f7a 100644 --- a/init.rb +++ b/init.rb @@ -1,6 +1,7 @@ require 'redmine' # Patches to the Redmine core. Will not work in development mode +require_dependency 'issue_patch' require_dependency 'query_patch' RAILS_DEFAULT_LOGGER.info 'Starting Budget plugin for RedMine' diff --git a/lang/en.yml b/lang/en.yml index 26af03f..d7868b6 100644 --- a/lang/en.yml +++ b/lang/en.yml @@ -8,3 +8,4 @@ field_fixed_cost: Fixed Bid field_project_manager_signoff: Project Manager Signoff field_client_signoff: Client Signoff field_deliverable: Deliverable +field_deliverable_subject: Deliverable diff --git a/lib/issue_patch.rb b/lib/issue_patch.rb new file mode 100644 index 0000000..dea64fa --- /dev/null +++ b/lib/issue_patch.rb @@ -0,0 +1,50 @@ +require_dependency 'issue' + +module IssuePatch + def self.included(base) + base.extend(ClassMethods) + + base.send(:include, InstanceMethods) + + # Same as typing in the class + base.class_eval do + unloadable # Send unloadable so it will not be unloaded in development + belongs_to :deliverable + + end + + end + + module ClassMethods + + # Muck with the find arguements to append an include for deliverables + def find(*args) + # Options defined + if args[1].is_a?(Hash) + # include used? + if args[1].has_key?(:include) + # Add our include + args[1][:include] << :deliverable + else + # Add an include + args[1][:include] = [:deliverable] + end + end + super + end + + end + + module InstanceMethods + def deliverable_subject + unless self.deliverable.nil? + return self.deliverable.subject + end + end + end +end + +# Add module to Issue +Issue.send(:include, IssuePatch) + + diff --git a/lib/query_patch.rb b/lib/query_patch.rb index f2effa8..eda585a 100644 --- a/lib/query_patch.rb +++ b/lib/query_patch.rb @@ -9,7 +9,7 @@ module QueryPatch # Same as typing in the class base.class_eval do unloadable # Send unloadable so it will not be unloaded in development - base.add_available_column(QueryColumn.new(:deliverable, :sortable => "#{Deliverable.table_name}.name")) + base.add_available_column(QueryColumn.new(:deliverable_subject, :sortable => "#{Deliverable.table_name}.subject")) alias_method :redmine_available_filters, :available_filters alias_method :available_filters, :budget_available_filters