Add jobs to time reports

Refs #2771
This commit is contained in:
Trevor Vallender 2024-01-16 13:10:16 +00:00
parent bf2a207429
commit 472d2b0479
2 changed files with 26 additions and 0 deletions

View File

@ -16,6 +16,7 @@ Redmine::Plugin.register :jobs do
TimeEntryQuery.send(:include, TimeEntryQueryPatch) TimeEntryQuery.send(:include, TimeEntryQueryPatch)
TimeEntry.send(:include, TimeEntryPatch) TimeEntry.send(:include, TimeEntryPatch)
Project.send(:include, ProjectPatch) Project.send(:include, ProjectPatch)
Redmine::Helpers::TimeReport.send(:include, TimeReportHelperPatch)
end end
project_module :jobs do project_module :jobs do

View File

@ -0,0 +1,25 @@
# frozen_string_literal: true
# Add jobs
module TimeReportHelperPatch
extend ActiveSupport::Concern
included do
include InstanceMethods
alias_method :load_available_criteria_without_jobs, :load_available_criteria
alias_method :load_available_criteria, :load_available_criteria_with_jobs
end
module InstanceMethods
def load_available_criteria_with_jobs
@available_criteria = load_available_criteria_without_jobs
@available_criteria['job'] = {
sql: "#{TimeEntry.table_name}.job_id",
klass: Job,
label: 'Job'
}
@available_criteria
end
end
end