プロジェクト

全般

プロフィール

Vote #80804

完了

Totals of custom fields may not be sorted as configured

Admin Redmine さんが約4年前に追加. 約4年前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
Filters_59
対象バージョン:
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
59
version_id:
162
issue_org_id:
33281
author_id:
332
assigned_to_id:
332
comments:
7
status_id:
5
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
127
ステータス-->[Closed]

説明

Totals for custom fields should be ordered by the position value of the fields, but actually they are ordered by id. They should be ordered according to the position value, like the issues list.

Assume that the positions of the project custom fields are set like this:
!{width: 514px; border: 1px solid grey;}custom-fields-position.png!

Totals for the custom fields are expected to be displayed in the same order as in the image above, but are actually sorted by id values in the database.

!{width: 777px; border: 1px solid #ccc;}.order-of-totals.png!


journals

Fixed the Totals for custom fields to be sorted by field position order. I attached a patch.

<pre><code class="diff">
diff --git a/app/models/query.rb b/app/models/query.rb
index 100728cff..7f1169023 100644
--- a/app/models/query.rb
+++ b/app/models/query.rb
@@ -755,7 +755,13 @@ class Query < ActiveRecord::Base
end

def available_totalable_columns
- available_columns.select(&:totalable)
+ available_columns.select(&:totalable).sort do |a, b|
+ if a.is_a?(QueryCustomFieldColumn) && b.is_a?(QueryCustomFieldColumn)
+ a.custom_field <=> b.custom_field
+ else
+ 0
+ end
+ end
end

def default_columns_names
</code></pre>
--------------------------------------------------------------------------------
Setting the target version to 4.1.2.
--------------------------------------------------------------------------------
Custom fields that are normally stored in "@Query#available_columns@" are in position order, but the cross-project's projects, issues, and spent time tabs do not store them in "@Query#available_columns@" in position order.
I fixed the patch as follows.
<pre><code class="diff">
diff --git a/app/models/project_query.rb b/app/models/project_query.rb
index 72a0922bd..b8c79072f 100644
--- a/app/models/project_query.rb
+++ b/app/models/project_query.rb
@@ -69,7 +69,7 @@ class ProjectQuery < Query
def available_columns
return @available_columns if @available_columns
@available_columns = self.class.available_columns.dup
- @available_columns += ProjectCustomField.visible.
+ @available_columns += project_custom_fields.visible.
map {|cf| QueryCustomFieldColumn.new(cf) }
@available_columns
end
diff --git a/app/models/query.rb b/app/models/query.rb
index 100728cff..31c5c911b 100644
--- a/app/models/query.rb
+++ b/app/models/query.rb
@@ -609,13 +609,13 @@ class Query < ActiveRecord::Base
if project
project.rolled_up_custom_fields
else
- IssueCustomField.all
+ IssueCustomField.sorted
end
end

# Returns a scope of project custom fields that are available as columns or filters
def project_custom_fields
- ProjectCustomField.all
+ ProjectCustomField.sorted
end

# Returns a scope of project statuses that are available as columns or filters
diff --git a/app/models/time_entry_query.rb b/app/models/time_entry_query.rb
index 610e7628e..39c931d4a 100644
--- a/app/models/time_entry_query.rb
+++ b/app/models/time_entry_query.rb
@@ -113,7 +113,7 @@ class TimeEntryQuery < Query
map {|cf| QueryCustomFieldColumn.new(cf) }
@available_columns += issue_custom_fields.visible.
map {|cf| QueryAssociationCustomFieldColumn.new(:issue, cf, :totalable => false) }
- @available_columns += ProjectCustomField.visible.
+ @available_columns += project_custom_fields.visible.
map {|cf| QueryAssociationCustomFieldColumn.new(:project, cf) }
@available_columns
end
</code></pre>
--------------------------------------------------------------------------------
Yuichi HARADA wrote:
> Custom fields that are normally stored in "@Query#available_columns@" are in position order, but the cross-project's projects, issues, and spent time tabs do not store them in "@Query#available_columns@" in position order.
> I fixed the patch as follows.
> [...]

Thank you for deeply inspecting the issue. But I found that the order of totals on Spent time page still ignores the position value of custom fields even after applying attachment:33281-v2.patch.

Could you look into it?

--------------------------------------------------------------------------------
Go MAEDA wrote:
> Thank you for deeply inspecting the issue. But I found that the order of totals on Spent time page still ignores the position value of custom fields even after applying attachment:33281-v2.patch.
>
> Could you look into it?

Thank you for pointing out.
I confirmed that TimeEntryCustomFields are not arranged in order of position. It was solved by adding the following patch to attachment:33281-v2.patch.

<pre><code class="diff">
diff --git a/app/models/query.rb b/app/models/query.rb
index 31c5c911b..45e9882a7 100644
--- a/app/models/query.rb
+++ b/app/models/query.rb
@@ -618,6 +618,11 @@ class Query < ActiveRecord::Base
ProjectCustomField.sorted
end

+ # Returns a scope of time entry custom fields that are available as columns or filters
+ def time_entry_custom_fields
+ TimeEntryCustomField.sorted
+ end
+
# Returns a scope of project statuses that are available as columns or filters
def project_statuses_values
[
diff --git a/app/models/time_entry_query.rb b/app/models/time_entry_query.rb
index 39c931d4a..c8f8eeaeb 100644
--- a/app/models/time_entry_query.rb
+++ b/app/models/time_entry_query.rb
@@ -100,7 +100,7 @@ class TimeEntryQuery < Query
add_available_filter "comments", :type => :text
add_available_filter "hours", :type => :float

- add_custom_fields_filters(TimeEntryCustomField)
+ add_custom_fields_filters(time_entry_custom_fields)
add_associations_custom_fields_filters :project
add_custom_fields_filters(issue_custom_fields, :issue)
add_associations_custom_fields_filters :user
@@ -109,7 +109,7 @@ class TimeEntryQuery < Query
def available_columns
return @available_columns if @available_columns
@available_columns = self.class.available_columns.dup
- @available_columns += TimeEntryCustomField.visible.
+ @available_columns += time_entry_custom_fields.visible.
map {|cf| QueryCustomFieldColumn.new(cf) }
@available_columns += issue_custom_fields.visible.
map {|cf| QueryAssociationCustomFieldColumn.new(:issue, cf, :totalable => false) }
</code></pre>
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
Committed the patch. Thank you.
--------------------------------------------------------------------------------

Admin Redmine さんが約4年前に更新

  • カテゴリFilters_59 にセット
  • 対象バージョン4.1.2_162 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0