From 01a4f1f1d5b0ac4fd23f71342f6928d5bbc3ff35 Mon Sep 17 00:00:00 2001 From: friflaj Date: Sun, 28 Mar 2010 21:51:03 +0200 Subject: [PATCH] add story-points column to the issue display --- init.rb | 4 ++++ lib/query_patch.rb | 28 ++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 lib/query_patch.rb diff --git a/init.rb b/init.rb index 9480b54911..bedbce163f 100644 --- a/init.rb +++ b/init.rb @@ -2,11 +2,15 @@ require 'redmine' require 'dispatcher' +require 'query_patch' + Dispatcher.to_prepare do require_dependency 'version' require_dependency 'issue' Issue::SAFE_ATTRIBUTES << "story_points" if Issue.const_defined? "SAFE_ATTRIBUTES" Issue::SAFE_ATTRIBUTES << "position" if Issue.const_defined? "SAFE_ATTRIBUTES" + + Query.send(:include, QueryPatch) unless Query.included_modules.include? QueryPatch end require_dependency 'backlogs_layout_hooks' diff --git a/lib/query_patch.rb b/lib/query_patch.rb new file mode 100644 index 0000000000..b98f4cdcf1 --- /dev/null +++ b/lib/query_patch.rb @@ -0,0 +1,28 @@ +require_dependency 'query' + +module QueryPatch + def self.included(base) # :nodoc: + base.extend(ClassMethods) + + # 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(:story_points, :sortable => "#{Issue.table_name}.story_points")) + end + + end + + module ClassMethods + # Setter for +available_columns+ that isn't provided by the core. + def available_columns=(v) + self.available_columns = (v) + end + + # Method to add a column to the +available_columns+ that isn't provided by the core. + def add_available_column(column) + self.available_columns << (column) + end + end +end + +