Redmine - Defect #33914
Even if the default value of Activities (time tracking) is set, it may not be reflected.
2020-08-27 10:18 - Mizuki ISHIKAWA

ステータス:

Closed

開始日:

優先度:

Normal期日:担当者:

Marius B

カテゴリ:

Time tracking

対象バージョン:4.2.7

Resolution:

Fixed

LTEANU

進捗率:

0%

予定工数:

0.00時間Affected version:

説明How to reproduce the problem:
1. bundle exec rake db:fixtures:load
2. Open /projects/ecookbook/time̲entries/new and you can see that "Development" is the default Activity choice.
3. Go to /projects/ecookbook/settings/activities and click Save button. At this time TimeEntryActivity.count changes from 4 to 8.
4. When you open /projects/ecookbook/time̲entries/new, the default Activity choice is "--- Please select ---".
If you click the Save button in /projects/ecookbook/settings/activities, project-specific activity data will be created based on theoriginal activity data.
If the underlying activity data is the default, then the project-specific activity data based on it should also be the default.
関係しているリビジョン
リビジョン 21668 - 2022-06-20 17:26 - Marius B

LTEANUFix time entry activity is not set as default when the default activity exists as project specific activity (#33914).
Patch by Mizuki ISHIKAWA.
リビジョン 21669 - 2022-06-20 18:44 - Marius B

LTEANU

Refactor TimeEntryActivity.default() method (#33914).
Patch by Holger Just.
リビジョン 21670 - 2022-06-20 19:40 - Marius B

LTEANU

Merged r21668 and r21669 to 5.0-stable (#33914).
リビジョン 21671 - 2022-06-20 19:41 - Marius B

LTEANU

Merged r21668 and r21669 to 4.2-stable (#33914).

履歴#1 - 2020-08-27 10:20 - Mizuki ISHIKAWA- ファイル fix-33914.patch を追加
I attach the patch.
#3 - 2020-12-21 10:19 - Go MAEDA- ステータス を New から Confirmed に変更#4 - 2022-06-14 04:54 - Mizuki ISHIKAWA
Is it hard to commit to this patch?
I can improve the patch if there are any problems.
#5 - 2022-06-20 08:15 - Marius B- 担当者 を Marius B

LTEANULTEANU にセット

- 対象バージョン を 4.2.7 にセット
#6 - 2022-06-20 17:27 - Marius B

2024-10-11

LTEANU

1/2

- ステータス を Confirmed から Resolved に変更- Resolution を Fixed にセット
#7 - 2022-06-20 18:13 - Holger Just
In TimeEntryActivity.default, all of the project's activities are already loaded from the database in the if statement. As such, the trailing find̲by isredundant and should be replaced by Ruby-only filtering to avoid running another SQL query to load data we already have.
The trailing line of that method could thus be replaced by the following code with matching behavior to avoid the additional SQL query:project.activities.detect { ¦activity¦ activity.parent̲id == default̲activity.id }Also, it is not guaranteed that we have any default activity at all as admins could deselect the default flag on all activities. Thus would result in thesuper call to return nil which in turn would result in an exception in the final line of the overwritten default method. As such, we also have to checkfor default̲activity.nil?. The following method should address both of my points:
def self.default(project=nil)default̲activity = super()if default̲activity.nil? ¦¦ project.nil? ¦¦ project.activities.blank? ¦¦ project.activities.include?(default̲activity)
return default̲activity
endproject.activities.detect { ¦activity¦ activity.parent̲id == default̲activity.id }end#8 - 2022-06-20 19:42 - Marius B

LTEANU- ステータス を Resolved から Closed に変更
Thanks Holger for your quick review on this. I've committed both patches.
#9 - 2022-06-21 07:55 - Mizuki ISHIKAWA
Thank you very much.

ファイル
fix-33914.patch

2024-10-11

3.17 KB

2020-08-27

Mizuki ISHIKAWA

2/2