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