]> source.dussan.org Git - redmine.git/commitdiff
Add time entries tab to issue history tabs (#3058).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Thu, 20 Jun 2019 07:11:26 +0000 (07:11 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Thu, 20 Jun 2019 07:11:26 +0000 (07:11 +0000)
Patch by Marius BALTEANU.

git-svn-id: http://svn.redmine.org/redmine/trunk@18274 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/issues_controller.rb
app/helpers/issues_helper.rb
app/views/issues/tabs/_time_entries.html.erb [new file with mode: 0644]
test/functional/issues_controller_test.rb

index dcc80646255e5d2ab88373c0b21cacec9df3eeae..73afc79d52a7cd333369dcd994790779aa3cf44e 100644 (file)
@@ -104,6 +104,7 @@ class IssuesController < ApplicationController
         @allowed_statuses = @issue.new_statuses_allowed_to(User.current)
         @priorities = IssuePriority.active
         @time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project)
+        @time_entries = @issue.time_entries.visible.preload(:activity, :user)
         @relation = IssueRelation.new
         retrieve_previous_and_next_issue_ids
         render :template => 'issues/show'
index 16ac246026b0e41e0e682827cb1fecdf527964c1..3068afe09d0d3f6f831e52d60c55ec25327fb38e 100644 (file)
@@ -557,6 +557,7 @@ module IssuesHelper
       tabs << {:name => 'notes', :label => :label_issue_history_notes, :onclick => 'showIssueHistory("notes", this.href)'} if journals_with_notes.any?
       tabs << {:name => 'properties', :label => :label_issue_history_properties, :onclick => 'showIssueHistory("properties", this.href)'} if journals_without_notes.any?
     end
+    tabs << {:name => 'time_entries', :label => :label_time_entry_plural, :partial => 'issues/tabs/time_entries', :locals => {:time_entries => @time_entries}} if User.current.allowed_to?(:view_time_entries, @project) && @issue.spent_hours > 0
     tabs << {:name => 'changesets', :label => :label_associated_revisions, :partial => 'issues/tabs/changesets', :locals => {:changesets => @changesets}} if @changesets.present?
     tabs
   end
diff --git a/app/views/issues/tabs/_time_entries.html.erb b/app/views/issues/tabs/_time_entries.html.erb
new file mode 100644 (file)
index 0000000..931a8df
--- /dev/null
@@ -0,0 +1,28 @@
+<% for time_entry in tab[:locals][:time_entries] %>
+  <div id="time-entry-<%= time_entry.id %>" class="time_entry journal">
+    <% if time_entry.editable_by?(User.current) -%>
+      <div class="contextual">
+        <%= link_to l(:button_edit), edit_time_entry_path(time_entry),
+                    :title => l(:button_edit),
+                    :class => 'icon-only icon-edit' %>
+        <%= link_to l(:button_delete), time_entry_path(time_entry),
+                    :data => {:confirm => l(:text_are_you_sure)},
+                    :method => :delete,
+                    :title => l(:button_delete),
+                    :class => 'icon-only icon-del' %>
+      </div>
+    <% end -%>
+    <h4>
+      <%= avatar(time_entry.user, :size => "24") %>
+      <%= authoring time_entry.created_on, time_entry.user, :label => :label_added_time_by %>
+    </h4>
+    <ul class="details">
+      <li>
+        <strong><%= l(:label_time_entry_plural) %></strong>:
+        <%= l_hours_short time_entry.hours %>
+      </li>
+    </ul>
+    <p><%= time_entry.comments %></p>
+  </div>
+  <%= call_hook(:view_issues_history_time_entry_bottom, { :time_entry => time_entry }) %>
+<% end %>
\ No newline at end of file
index 517d7ce01c79a68d9597aa442e65b6cfe43c6a81..f625c6e8b169c14d64588158e5a93f5849ffa751 100644 (file)
@@ -2537,12 +2537,12 @@ class IssuesControllerTest < Redmine::ControllerTest
 
   def test_show_display_changesets_tab_for_issue_with_changesets
     project = Project.find(2)
-    issue = Issue.find(3)
+    issue = Issue.find(9)
     issue.changeset_ids = [102]
     issue.save!
 
     @request.session[:user_id] = 2
-    get :show, :params => {:id => 3}
+    get :show, :params => {:id => issue.id}
 
     assert_select '#history' do
       assert_select 'div.tabs ul a', 1
@@ -2550,6 +2550,24 @@ class IssuesControllerTest < Redmine::ControllerTest
     end
   end
 
+  def test_show_should_display_spent_time_tab_for_issue_with_time_entries
+    @request.session[:user_id] = 1
+    get :show, :params => {:id => 3}
+    assert_response :success
+
+    assert_select '#history' do
+      assert_select 'div.tabs ul a', 1
+      assert_select 'div.tabs a[id=?]', 'tab-time_entries', :text => 'Spent time'
+    end
+
+    assert_select 'div[id=?]', 'time-entry-3' do
+      assert_select 'a[title=?][href=?]', 'Edit', '/time_entries/3/edit'
+      assert_select 'a[title=?][href=?]', 'Delete', '/time_entries/3'
+
+      assert_select 'ul[class=?]', 'details', :text => /1.00 h/
+    end
+  end
+
   def test_get_new
     @request.session[:user_id] = 2
     get :new, :params => {