Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redmine - Add "Spent Time" Field to Issues Display

Tags:

redmine

How would I go about adding the "Spent Time" as a column to be displayed in the issues list?

like image 585
Joel Meador Avatar asked Nov 26 '08 16:11

Joel Meador


People also ask

How do I add news in Redmine?

If you have the permission to create new news items, you have a green plus sign (+ Add news) in the upper right of you screen. If you click on that, you can add a new news item. On this page, you have to insert the Title, Summary and Description of the news item.

How do I create an issue in Redmine?

To create a new issue, go to Projects. Use + (quick menu) or go to Issues and then select New issue. You can also create an issue from a project page. If you have not selected a project (i.e., you are not on a project page), the New issue form will also contain a Project field.


1 Answers

Consolidating Eric and Joel's answers, this is what I needed to do to get a 'Spent time' column added to Redmine 1.0.3. Not sure if there's a better way to get the translation text added.

To give the new field a localised name, added to config/locales/en.yml around line 299 at the end of the field definitions:

  field_spent_hours: Spent time

To add the new column, created lib/spent_time_query_patch.rb with content:

# Based on http://github.com/edavis10/question_plugin/blob/master/lib/question_query_patch.rb
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(:spent_hours))
    end

  end

  module ClassMethods
    unless Query.respond_to?(:available_columns=)
      # Setter for +available_columns+ that isn't provided by the core.
      def available_columns=(v)
        self.available_columns = (v)
      end
    end

    unless Query.respond_to?(:add_available_column)
      # 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
end

To get the spent_time_query_patch above to actually load, created config/initializers/spent_time_query_patch.rb with content:

require 'spent_time_query_patch'

Query.class_eval do
  include QueryPatch
end
like image 76
user2067021 Avatar answered Oct 05 '22 10:10

user2067021