From 472d2b04799da566216fc80a12db0b7074ac0938 Mon Sep 17 00:00:00 2001 From: Trevor Vallender Date: Tue, 16 Jan 2024 13:10:16 +0000 Subject: [PATCH] Add jobs to time reports Refs #2771 --- init.rb | 1 + lib/time_report_helper_patch.rb | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 lib/time_report_helper_patch.rb diff --git a/init.rb b/init.rb index eaef23e..dc28573 100644 --- a/init.rb +++ b/init.rb @@ -16,6 +16,7 @@ Redmine::Plugin.register :jobs do TimeEntryQuery.send(:include, TimeEntryQueryPatch) TimeEntry.send(:include, TimeEntryPatch) Project.send(:include, ProjectPatch) + Redmine::Helpers::TimeReport.send(:include, TimeReportHelperPatch) end project_module :jobs do diff --git a/lib/time_report_helper_patch.rb b/lib/time_report_helper_patch.rb new file mode 100644 index 0000000..25f59ed --- /dev/null +++ b/lib/time_report_helper_patch.rb @@ -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