parent
0a265fbbce
commit
62d924dadc
|
@ -1,2 +1,3 @@
|
||||||
en:
|
en:
|
||||||
|
field_jobs: Jobs
|
||||||
field_job: Job
|
field_job: Job
|
||||||
|
|
1
init.rb
1
init.rb
|
@ -15,5 +15,6 @@ Redmine::Plugin.register :jobs do
|
||||||
Rails.logger.info "Patch Jobs"
|
Rails.logger.info "Patch Jobs"
|
||||||
TimeEntryQuery.send(:include, TimeEntryQueryPatch)
|
TimeEntryQuery.send(:include, TimeEntryQueryPatch)
|
||||||
TimeEntry.send(:include, TimeEntryPatch)
|
TimeEntry.send(:include, TimeEntryPatch)
|
||||||
|
Project.send(:include, ProjectPatch)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require_dependency 'project'
|
||||||
|
|
||||||
|
module ProjectPatch
|
||||||
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
|
included do
|
||||||
|
has_many :jobs
|
||||||
|
end
|
||||||
|
end
|
|
@ -9,18 +9,18 @@ module TimeEntryQueryPatch
|
||||||
included do
|
included do
|
||||||
include InstanceMethods
|
include InstanceMethods
|
||||||
|
|
||||||
# alias_method :initialize_available_filters_without_jobs, :initialize_available_filters
|
alias_method :initialize_available_filters_without_jobs, :initialize_available_filters
|
||||||
# alias_method :initialize_available_filters, :initialize_available_filters_with_jobs
|
alias_method :initialize_available_filters, :initialize_available_filters_with_jobs
|
||||||
|
|
||||||
alias_method :available_columns_without_jobs, :available_columns
|
alias_method :available_columns_without_jobs, :available_columns
|
||||||
alias_method :available_columns, :available_columns_with_jobs
|
alias_method :available_columns, :available_columns_with_jobs
|
||||||
end
|
end
|
||||||
|
|
||||||
module InstanceMethods
|
module InstanceMethods
|
||||||
# def initialize_available_filters_with_jobs
|
def initialize_available_filters_with_jobs
|
||||||
# initialize_available_filters_without_jobs
|
initialize_available_filters_without_jobs
|
||||||
# initialize_issue_jobs_filter
|
initialize_issue_jobs_filter
|
||||||
# end
|
end
|
||||||
|
|
||||||
def available_columns_with_jobs
|
def available_columns_with_jobs
|
||||||
if @available_columns.nil?
|
if @available_columns.nil?
|
||||||
|
@ -32,8 +32,21 @@ module TimeEntryQueryPatch
|
||||||
@available_columns
|
@available_columns
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def initialize_issue_jobs_filter(position: nil)
|
||||||
|
add_available_filter("job_id", order: position,
|
||||||
|
type: :list_optional,
|
||||||
|
values: jobs_list
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
def sql_for_issue_jobs_field(_field, operator, values)
|
def sql_for_issue_jobs_field(_field, operator, values)
|
||||||
build_sql_for_jobs_field klass: Issue, operator: operator, values: values
|
build_sql_for_jobs_field klass: Issue, operator: operator, values: values
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def jobs_list
|
||||||
|
Job.where(project: [project, project&.parent]).map do |job|
|
||||||
|
[job.name, job.id.to_s]
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue