GitLab wurde erfolgreich aktualisiert. Durch regelmäßige Updates bleibt das THM GitLab sicher. Danke für Ihre Geduld.

Commit c0548afc authored by jplang's avatar jplang

Consider custom fields that correspond to the project only (#24014).

git-svn-id: https://svn.redmine.org/redmine/trunk@15890 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent c3de8ea4
......@@ -106,7 +106,9 @@ class TimeEntryQuery < Query
add_available_filter "hours", :type => :float
add_custom_fields_filters(TimeEntryCustomField)
add_associations_custom_fields_filters :project, :issue, :user
add_associations_custom_fields_filters :project
add_custom_fields_filters(issue_custom_fields, :issue)
add_associations_custom_fields_filters :user
end
def available_columns
......@@ -114,7 +116,7 @@ class TimeEntryQuery < Query
@available_columns = self.class.available_columns.dup
@available_columns += TimeEntryCustomField.visible.
map {|cf| QueryCustomFieldColumn.new(cf) }
@available_columns += IssueCustomField.visible.
@available_columns += issue_custom_fields.visible.
map {|cf| QueryAssociationCustomFieldColumn.new(:issue, cf, :totalable => false) }
@available_columns
end
......@@ -233,4 +235,12 @@ class TimeEntryQuery < Query
joins.compact!
joins.any? ? joins.join(' ') : nil
end
def issue_custom_fields
if project
project.all_issue_custom_fields
else
IssueCustomField.where(:is_for_all => true)
end
end
end
......@@ -54,4 +54,28 @@ class TimeEntryQueryTest < ActiveSupport::TestCase
query.add_filter('activity_id', '!', [system.id.to_s])
assert_equal 4.0, query.results_scope.sum(:hours)
end
def test_project_query_should_include_project_issue_custom_fields_only_as_filters
global = IssueCustomField.generate!(:is_for_all => true, :is_filter => true)
field_on_project = IssueCustomField.generate!(:is_for_all => false, :project_ids => [3], :is_filter => true)
field_not_on_project = IssueCustomField.generate!(:is_for_all => false, :project_ids => [1,2], :is_filter => true)
query = TimeEntryQuery.new(:project => Project.find(3))
assert_include "issue.cf_#{global.id}", query.available_filters.keys
assert_include "issue.cf_#{field_on_project.id}", query.available_filters.keys
assert_not_include "issue.cf_#{field_not_on_project.id}", query.available_filters.keys
end
def test_project_query_should_include_project_issue_custom_fields_only_as_columns
global = IssueCustomField.generate!(:is_for_all => true, :is_filter => true)
field_on_project = IssueCustomField.generate!(:is_for_all => false, :project_ids => [3], :is_filter => true)
field_not_on_project = IssueCustomField.generate!(:is_for_all => false, :project_ids => [1,2], :is_filter => true)
query = TimeEntryQuery.new(:project => Project.find(3))
assert_include "issue.cf_#{global.id}", query.available_columns.map(&:name).map(&:to_s)
assert_include "issue.cf_#{field_on_project.id}", query.available_columns.map(&:name).map(&:to_s)
assert_not_include "issue.cf_#{field_not_on_project.id}", query.available_columns.map(&:name).map(&:to_s)
end
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment