##// END OF EJS Templates
Adds autocomplete to issue field on time logging form....
Jean-Philippe Lang -
r9999:f1650b8ff48a
parent child
Show More
@@ -22,7 +22,7 class AutoCompletesController < ApplicationController
22 22 @issues = []
23 23 q = (params[:q] || params[:term]).to_s.strip
24 24 if q.present?
25 scope = (params[:scope] == "all" ? Issue : @project.issues).visible
25 scope = (params[:scope] == "all" || @project.nil? ? Issue : @project.issues).visible
26 26 if q.match(/^\d+$/)
27 27 @issues << scope.find_by_id(q.to_i)
28 28 end
@@ -35,7 +35,9 class AutoCompletesController < ApplicationController
35 35 private
36 36
37 37 def find_project
38 @project = Project.find(params[:project_id])
38 if params[:project_id].present?
39 @project = Project.find(params[:project_id])
40 end
39 41 rescue ActiveRecord::RecordNotFound
40 42 render_404
41 43 end
@@ -19,3 +19,5
19 19 <% end %>
20 20 <%= call_hook(:view_timelog_edit_form_bottom, { :time_entry => @time_entry, :form => f }) %>
21 21 </div>
22
23 <%= javascript_tag "observeAutocompleteField('time_entry_issue_id', '#{escape_javascript auto_complete_issues_path(:project_id => @project, :scope => (@project ? nil : 'all'))}')" %>
@@ -40,6 +40,13 class AutoCompletesControllerTest < ActionController::TestCase
40 40 assert assigns(:issues).include?(Issue.find(13))
41 41 end
42 42
43 def test_auto_complete_without_project_should_search_all_projects
44 get :issues, :q => '13'
45 assert_response :success
46 assert_not_nil assigns(:issues)
47 assert assigns(:issues).include?(Issue.find(13))
48 end
49
43 50 def test_auto_complete_without_scope_all_should_not_search_other_projects
44 51 get :issues, :project_id => 'ecookbook', :q => '13'
45 52 assert_response :success
General Comments 0
You need to be logged in to leave comments. Login now