]> source.dussan.org Git - redmine.git/commitdiff
Issue subject is not updated when you select another issue on time entry form (#24041).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Fri, 18 Nov 2016 08:11:11 +0000 (08:11 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Fri, 18 Nov 2016 08:11:11 +0000 (08:11 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@15951 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/views/timelog/_form.html.erb
app/views/timelog/edit.js.erb [new file with mode: 0644]
app/views/timelog/new.js.erb
config/routes.rb
test/functional/timelog_controller_test.rb
test/integration/routing/timelog_test.rb

index f0c042a56cee0e950c9094f8247a6f43765609c0..5b0ec6aaccc95b4eaeb0643b9f3ce58f78eda361 100644 (file)
@@ -13,9 +13,9 @@
   <% end %>
   <p>
     <%= f.text_field :issue_id, :size => 6 %>
-    <% if @time_entry.issue.try(:visible?) %>
-      <span id="time_entry_issue"><%= "#{@time_entry.issue.tracker.name} ##{@time_entry.issue.id}: #{@time_entry.issue.subject}" %></span>
-    <% end %>
+    <span id="time_entry_issue">
+      <%=  link_to_issue(@time_entry.issue) if @time_entry.issue.try(:visible?) %>
+    </span>
   </p>
   <p><%= f.date_field :spent_on, :size => 10, :required => true %><%= calendar_for('time_entry_spent_on') %></p>
   <p><%= f.text_field :hours, :size => 6, :required => true %></p>
 </div>
 
 <%= javascript_tag do %>
-<% if @time_entry.new_record? %>
   $(document).ready(function(){
     $('#time_entry_project_id, #time_entry_issue_id').change(function(){
       $.ajax({
-        url: '<%= escape_javascript new_time_entry_path(:format => 'js') %>',
+        url: '<%= escape_javascript(@time_entry.new_record? ? new_time_entry_path(:format => 'js') : edit_time_entry_path(:format => 'js')) %>',
         type: 'post',
-        data: $('#new_time_entry').serialize()
+        data: $(this).closest('form').serialize()
       });
     });
   });
-<% end %>
 
   observeAutocompleteField('time_entry_issue_id', '<%= escape_javascript auto_complete_issues_path(:project_id => @project, :scope => (@project ? nil : 'all'))%>', {
     select: function(event, ui) {
-      $('#time_entry_issue').text(ui.item.label);
-      $('#time_entry_issue_id').blur();
+      $('#time_entry_issue').text('');
+      $('#time_entry_issue_id').val(ui.item.value).change();
     }
   });
 <% end %>
diff --git a/app/views/timelog/edit.js.erb b/app/views/timelog/edit.js.erb
new file mode 100644 (file)
index 0000000..cd78611
--- /dev/null
@@ -0,0 +1 @@
+$('#time_entry_issue').html('<%= escape_javascript link_to_issue(@time_entry.issue) if @time_entry.issue.try(:visible?) %>');
index f76cbb84f7a79fcc83e9d75e7c578efbd3d21956..4cba8cfe6c6c234d84c7f60b1b0b0946202a4143 100644 (file)
@@ -1 +1,2 @@
 $('#time_entry_activity_id').html('<%= escape_javascript options_for_select(activity_collection_for_select_options(@time_entry), @time_entry.activity_id) %>');
+$('#time_entry_issue').html('<%= escape_javascript link_to_issue(@time_entry.issue) if @time_entry.issue.try(:visible?) %>');
index 97e950c5b71b3d24db730bba4f3d565262538b5a..3a096e127160ae4f19ee27f912729b8ec766cfee 100644 (file)
@@ -215,6 +215,10 @@ Rails.application.routes.draw do
   match '/time_entries/context_menu', :to => 'context_menus#time_entries', :as => :time_entries_context_menu, :via => [:get, :post]
 
   resources :time_entries, :controller => 'timelog', :except => :destroy do
+    member do
+      # Used when updating the edit form of an existing time entry
+      patch 'edit', :to => 'timelog#edit'
+    end
     collection do
       get 'report'
       get 'bulk_edit'
index b392a130fd29e2da564012280982ea49cd00e919..6af830125acd7faf200c76e81401074d640518a6 100644 (file)
@@ -35,6 +35,7 @@ class TimelogControllerTest < Redmine::ControllerTest
 
     assert_select 'input[name=?][type=hidden]', 'project_id', 0
     assert_select 'input[name=?][type=hidden]', 'issue_id', 0
+    assert_select 'span[id=?]', 'time_entry_issue'
     assert_select 'select[name=?]', 'time_entry[project_id]' do
       # blank option for project
       assert_select 'option[value=""]'
@@ -58,6 +59,7 @@ class TimelogControllerTest < Redmine::ControllerTest
 
     assert_select 'input[name=?][type=hidden]', 'project_id', 0
     assert_select 'input[name=?][type=hidden]', 'issue_id'
+    assert_select 'a[href=?]', '/issues/2', :text => /Feature request #2/
     assert_select 'select[name=?]', 'time_entry[project_id]', 0
   end
 
@@ -249,7 +251,7 @@ class TimelogControllerTest < Redmine::ControllerTest
     end
     assert_select_error /Issue is invalid/
     assert_select "input[name=?][value=?]", "time_entry[issue_id]", issue.id.to_s
-    assert_select "#time_entry_issue", 0
+    assert_select "#time_entry_issue a", 0
     assert !response.body.include?('issue_that_is_not_visible')
   end
 
@@ -501,7 +503,7 @@ class TimelogControllerTest < Redmine::ControllerTest
     assert_select 'form#bulk_edit_form[action=?]', '/time_entries/bulk_update' do
       # System wide custom field
       assert_select 'select[name=?]', 'time_entry[custom_field_values][10]'
-  
+
       # Activities
       assert_select 'select[name=?]', 'time_entry[activity_id]' do
         assert_select 'option[value=""]', :text => '(No change)'
@@ -549,7 +551,7 @@ class TimelogControllerTest < Redmine::ControllerTest
     @request.session[:user_id] = 2
     # makes user a manager on the other project
     Member.create!(:user_id => 2, :project_id => 3, :role_ids => [1])
-    
+
     # update time entry activity
     post :bulk_update, :params => {:ids => [1, 2, 4], :time_entry => { :activity_id => 9 }}
 
@@ -677,9 +679,9 @@ class TimelogControllerTest < Redmine::ControllerTest
   def test_index_at_project_level
     get :index, :params => {:project_id => 'ecookbook', :c => ['project']}
     assert_response :success
-    
+
     assert_select 'tr.time-entry', 4
-    
+
     # project and subproject
     projects = css_select('table.time-entries tbody td.project').map(&:text).uniq.sort
     assert_equal ["eCookbook", "eCookbook Subproject 1"], projects
@@ -959,7 +961,7 @@ class TimelogControllerTest < Redmine::ControllerTest
 
   def test_index_at_project_level_should_include_csv_export_dialog
     get :index, :params => {
-      :project_id => 'ecookbook', 
+      :project_id => 'ecookbook',
       :f => ['spent_on'],
       :op => {'spent_on' => '>='},
       :v => {'spent_on' => ['2007-04-01']},
index b7a219c654c05533c21052127b0600d0c56a6492..849e6a3d9aae5bae8f1bcbcb63bb4c9f19a8e52a 100644 (file)
@@ -27,7 +27,8 @@ class RoutingTimelogsTest < Redmine::RoutingTest
     should_route 'POST /time_entries' => 'timelog#create'
 
     should_route 'GET /time_entries/22/edit' => 'timelog#edit', :id => '22'
-    should_route 'PUT /time_entries/22' => 'timelog#update', :id => '22'
+    should_route 'PATCH /time_entries/22/edit' => 'timelog#edit', :id => '22'
+    should_route 'PATCH /time_entries/22' => 'timelog#update', :id => '22'
     should_route 'DELETE /time_entries/22' => 'timelog#destroy', :id => '22'
   end