Feature #10314

Make the only enabled activity in a project the default one for time entry

Added by Fayez Naccache over 10 years ago. Updated about 1 month ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Go MAEDA% Done:

0%

Category:Time tracking
Target version:5.1.0
Resolution:Fixed

Description

Example: In administration, if we have 4 activities (A, B, C, D) and A by default,
If activity C is the only one we can set in a project, so when submitting time entry we have to choose C as activity although it is the only choice in the combobox.

The field is compulsory so it is disturbing to set C as activity wherever we input time.

feature-10314.patch Magnifier (2.62 KB) Mizuki ISHIKAWA, 2022-06-22 09:42

feature-10314-v2.patch Magnifier (2.64 KB) Go MAEDA, 2022-07-08 10:30

Associated revisions

Revision 21709
Added by Go MAEDA about 1 month ago

Make the only enabled activity in a project the default one for time entry (#10314).

Patch by Mizuki ISHIKAWA.

History

#1 Updated by Bo Hansen over 10 years ago

I agree. Maybe the best solution would be to allow setting a default activity per project?

Here's a simple patch which removes blank field if only one activity is present:

diff --git a/app/helpers/timelog_helper.rb b/app/helpers/timelog_helper.rb
index 6be6c58..04ac1bc 100644
--- a/app/helpers/timelog_helper.rb
+++ b/app/helpers/timelog_helper.rb
@@ -49,7 +49,8 @@ module TimelogHelper
     if time_entry && time_entry.activity && !time_entry.activity.active?
       collection << [ "--- #{l(:actionview_instancetag_blank_option)} ---", '' ]
     else
-      collection << [ "--- #{l(:actionview_instancetag_blank_option)} ---", '' ] unless activities.detect(&:is_default)
+      collection << [ "--- #{l(:actionview_instancetag_blank_option)} ---", '' ] unless activities.detect(&:is_default) ||
+                                                                                        activities.count == 1
     end
     activities.each { |a| collection << [a.name, a.id] }
     collection

#2 Updated by Etienne Massip over 10 years ago

  • Category changed from Issues to Time tracking

#3 Updated by Mizuki ISHIKAWA about 1 month ago

I have attached the patch.

#4 Updated by Go MAEDA about 1 month ago

Mizuki ISHIKAWA wrote:

I have attached the patch.

Thank you for posting the patch. I slightly updated it.

  • Changed the method name of TimeEntryActivity.chooseable_activities to available_activities
  • Fixed a RuboCop offense Layout/LineLength
  • Changed the argument of method call at line 29 in app/helpers/timelog_helper.rb from @project to project (I think this is a typo. Please review this change)

#5 Updated by Fernando Hartmann about 1 month ago

+1

#6 Updated by Go MAEDA about 1 month ago

  • Target version changed from Candidate for next major release to 5.1.0

Setting the target version to 5.1.0.

#7 Updated by Go MAEDA about 1 month ago

  • Status changed from New to Closed
  • Assignee set to Go MAEDA
  • Resolution set to Fixed

Committed the patch. Thank you for your contribution.

Also available in: Atom PDF