Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- field_spent_hours: Spent time
- field_spent_hours: Spent time
- # 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
- require 'spent_time_query_patch'
- Query.class_eval do
- include QueryPatch
- end
- base.add_available_column(QueryColumn.new(:spent_hours,
- :sortable => "(select sum(hours) from time_entries where time_entries.issue_id = t0_r0)")
- )
- when 'Fixnum', 'Float'
- if column.name == :done_ratio
- progress_bar(value, :width => '80px')
- else
- value.to_s
- end
- when 'Fixnum', 'Float'
- if column.name == :done_ratio
- progress_bar(value, :width => '80px')
- elsif column.name == :spent_hours
- sprintf "%.2f", value
- else
- value.to_s
- end
Add Comment
Please, Sign In to add comment