Defect #32959

Fix selected user on log time edit page when user has permissions to log time for another user

Added by 15 days ago. Updated 12 days ago.

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

0%

Category:Time tracking
Target version:4.1.1
Resolution:Fixed Affected version:4.1.0

Description

when you're editing a existing timelog entry and have the rights to adjust the user ( or log on behalf of another user ), the current value will not be selected in the drop down due to this line:

https://www.redmine.org/projects/redmine/repository/revisions/19326/entry/branches/4.1-stable/app/helpers/application_helper.rb#L578

the fix is quite simple, just drop the .to_s

      selected_attribute = ' selected="selected"' if option_value_selected?(element, selected) || element.id == selected

and its working.

diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index b40f42ecc..e13825082 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -575,7 +575,7 @@ module ApplicationHelper
     end
     groups = +''
     collection.sort.each do |element|
-      selected_attribute = ' selected="selected"' if option_value_selected?(element, selected) || element.id == selected
+      selected_attribute = ' selected="selected"' if option_value_selected?(element, selected) || element.id.to_s == selected
       (element.is_a?(Group) ? groups : s) << %(<option value="#{element.id}"#{selected_attribute}>#{h element.name}</option>)
     end
     unless groups.empty?

0001-Fix-selected-user-on-timelog-edit.patch Magnifier (1.67 KB) Marius BALTEANU, 2020-02-08 21:36


Related issues

Related to Redmine - Feature #3848: Permission to log time for another user Closed 2009-09-11

Associated revisions

Revision 19501
Added by Go MAEDA 12 days ago

Fix that selected user on timelog#edit is incorrect (#32959).

Patch by Marius BALTEANU.

Revision 19502
Added by Go MAEDA 12 days ago

Merged r19501 from trunk to 4.1-stable (#32959).

History

#1 Updated by 15 days ago

missed the selected version, this applies to 4.1-stable

#2 Updated by Go MAEDA 15 days ago

  • Related to Feature #3848: Permission to log time for another user added

#3 Updated by Go MAEDA 15 days ago

  • Tracker changed from Patch to Defect
  • Status changed from New to Confirmed
  • Target version set to Candidate for next minor release
  • Affected version set to 4.1.0

#4 Updated by Marius BALTEANU 13 days ago

  • Assignee set to Marius BALTEANU
  • Target version changed from Candidate for next minor release to 4.1.1

#5 Updated by Marius BALTEANU 12 days ago

Thanks easter egg for detecting the issue.

I have attached a patch that fixes the code added in #3848 and adds a test for this case. Regarding your fix from app/helpers/application_helper.rb, maybe it's better to cast both values to_s.

#6 Updated by Marius BALTEANU 12 days ago

  • Subject changed from fix for selected user on timelogentry edit to Fix selected user on log time edit page when user has permissions to log time for another user
  • Assignee deleted (Marius BALTEANU)

#7 Updated by Go MAEDA 12 days ago

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

Committed the patch. Thank you.

Also available in: Atom PDF