From d1360a67ab6a0909ed5d4164bcc7c403828ac2ed Mon Sep 17 00:00:00 2001
From: Jean-Philippe Lang
Date: Sun, 5 Apr 2020 11:19:53 +0000
Subject: [PATCH] Merged r19653, r19654 and r19662 to 4.1-stable (#3800).
git-svn-id: http://svn.redmine.org/redmine/branches/4.1-stable@19664 e93f8b46-1217-0410-a6f0-8f06a7374b81
---
app/views/timelog/_form.html.erb | 6 ++++++
app/views/timelog/bulk_edit.html.erb | 11 ++++++++---
test/functional/timelog_controller_test.rb | 9 ++++++++-
3 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/app/views/timelog/_form.html.erb b/app/views/timelog/_form.html.erb
index bfeb67337..24bce8b6d 100644
--- a/app/views/timelog/_form.html.erb
+++ b/app/views/timelog/_form.html.erb
@@ -16,8 +16,14 @@
<%= link_to_issue(@time_entry.issue) if @time_entry.issue.try(:visible?) %>
+
<% if User.current.allowed_to?(:log_time_for_other_users, @project) %>
<%= f.select :user_id, user_collection_for_select_options(@time_entry), :required => true %>
+ <% elsif !@time_entry.new_record? %>
+
+ <%= f.label_for_field :user_id %>
+ <%= link_to_user(@time_entry.user) %>
+
<% end %>
<%= f.date_field :spent_on, :size => 10, :required => true %><%= calendar_for('time_entry_spent_on') %>
<%= f.hours_field :hours, :size => 6, :required => true %>
diff --git a/app/views/timelog/bulk_edit.html.erb b/app/views/timelog/bulk_edit.html.erb
index 5d82c54d5..bb7caa14b 100644
--- a/app/views/timelog/bulk_edit.html.erb
+++ b/app/views/timelog/bulk_edit.html.erb
@@ -18,8 +18,13 @@
<% @time_entries.each do |entry| %>
- <%= content_tag 'li',
- link_to("#{format_date(entry.spent_on)} - #{entry.project}: #{l(:label_f_hour_plural, :value => entry.hours)}", edit_time_entry_path(entry)) %>
+ <%=
+ content_tag 'li',
+ link_to(
+ "#{format_date(entry.spent_on)} - #{entry.project}: #{l(:label_f_hour_plural, :value => entry.hours)} (#{entry.user})",
+ edit_time_entry_path(entry)
+ )
+ %>
<% end %>
@@ -115,4 +120,4 @@
}
);
<% end %>
-<% end %>
\ No newline at end of file
+<% end %>
diff --git a/test/functional/timelog_controller_test.rb b/test/functional/timelog_controller_test.rb
index 8b701432b..43c53a576 100644
--- a/test/functional/timelog_controller_test.rb
+++ b/test/functional/timelog_controller_test.rb
@@ -46,6 +46,8 @@ class TimelogControllerTest < Redmine::ControllerTest
# blank option for project
assert_select 'option[value=""]'
end
+ assert_select 'label[for=?]', 'time_entry_user_id', 0
+ assert_select 'select[name=?]', 'time_entry[user_id]', 0
end
def test_new_with_project_id
@@ -150,6 +152,11 @@ class TimelogControllerTest < Redmine::ControllerTest
assert_response :success
assert_select 'form[action=?]', '/time_entries/2'
+
+ # Time entry user should be shown as text
+ # for user without permission to log time for other users
+ assert_select 'label[for=?]', 'time_entry_user_id', 1
+ assert_select 'a.user.active', :text => 'Redmine Admin'
end
def test_get_edit_with_an_existing_time_entry_with_inactive_activity
@@ -704,7 +711,7 @@ class TimelogControllerTest < Redmine::ControllerTest
assert_select 'ul#bulk-selection' do
assert_select 'li', 2
- assert_select 'li a', :text => '03/23/2007 - eCookbook: 4.25 hours'
+ assert_select 'li a', :text => '03/23/2007 - eCookbook: 4.25 hours (John Smith)'
end
assert_select 'form#bulk_edit_form[action=?]', '/time_entries/bulk_update' do
--
2.39.5