kanbanworkflowstimelinescrumrubyroadmapproject-planningproject-managementopenprojectangularissue-trackerifcgantt-chartganttbug-trackerboardsbcf
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
72 lines
2.0 KiB
72 lines
2.0 KiB
15 years ago
|
require_dependency 'query'
|
||
|
|
||
12 years ago
|
module OpenProject::Costs::Patches::QueryPatch
|
||
15 years ago
|
class CurrencyQueryColumn < QueryColumn
|
||
15 years ago
|
unloadable
|
||
15 years ago
|
include ActionView::Helpers::NumberHelper
|
||
13 years ago
|
alias :super_value :value
|
||
15 years ago
|
|
||
|
def value(issue)
|
||
15 years ago
|
number_to_currency(issue.send(name))
|
||
15 years ago
|
end
|
||
13 years ago
|
|
||
|
def real_value(issue)
|
||
|
super_value issue
|
||
|
end
|
||
15 years ago
|
end
|
||
|
|
||
15 years ago
|
def self.included(base) # :nodoc:
|
||
|
base.extend(ClassMethods)
|
||
|
|
||
|
base.send(:include, InstanceMethods)
|
||
|
|
||
12 years ago
|
# Same as typing in the class
|
||
15 years ago
|
base.class_eval do
|
||
|
unloadable # Send unloadable so it will not be unloaded in development
|
||
12 years ago
|
|
||
15 years ago
|
add_available_column(QueryColumn.new(:cost_object_subject))
|
||
15 years ago
|
add_available_column(CurrencyQueryColumn.new(:material_costs))
|
||
|
add_available_column(CurrencyQueryColumn.new(:labor_costs))
|
||
|
add_available_column(CurrencyQueryColumn.new(:overall_costs))
|
||
12 years ago
|
|
||
15 years ago
|
alias_method_chain :available_filters, :costs
|
||
15 years ago
|
end
|
||
|
end
|
||
12 years ago
|
|
||
15 years ago
|
module ClassMethods
|
||
12 years ago
|
|
||
15 years ago
|
# 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
|
||
12 years ago
|
|
||
15 years ago
|
module InstanceMethods
|
||
12 years ago
|
|
||
15 years ago
|
# Wrapper around the +available_filters+ to add a new Cost Object filter
|
||
15 years ago
|
def available_filters_with_costs
|
||
|
@available_filters = available_filters_without_costs
|
||
12 years ago
|
|
||
15 years ago
|
if project && project.module_enabled?(:costs_module)
|
||
15 years ago
|
redmine_costs_filters = {
|
||
|
"cost_object_id" => {
|
||
|
:type => :list_optional,
|
||
|
:order => 14,
|
||
12 years ago
|
:values => CostObject.all(:conditions => ["project_id IN (?)", project], :order => 'subject ASC').collect { |d| [d.subject, d.id.to_s]}
|
||
15 years ago
|
},
|
||
|
}
|
||
15 years ago
|
else
|
||
|
redmine_costs_filters = { }
|
||
|
end
|
||
|
return @available_filters.merge(redmine_costs_filters)
|
||
|
end
|
||
15 years ago
|
end
|
||
15 years ago
|
end
|
||
|
|
||
12 years ago
|
Query.send(:include, OpenProject::Costs::Patches::QueryPatch)
|