menu_item :settings, :only => :settings
menu_item :projects, :only => [:index, :new, :copy, :create]
- before_action :find_project, :except => [ :index, :list, :new, :create, :copy ]
- before_action :authorize, :except => [ :index, :list, :new, :create, :copy, :archive, :unarchive, :destroy]
+ before_action :find_project, :except => [ :index, :autocomplete, :list, :new, :create, :copy ]
+ before_action :authorize, :except => [ :index, :autocomplete, :list, :new, :create, :copy, :archive, :unarchive, :destroy]
before_action :authorize_global, :only => [:new, :create]
before_action :require_admin, :only => [ :copy, :archive, :unarchive, :destroy ]
accept_rss_auth :index
end
@projects = scope.to_a
}
- format.js {
- if params[:q].present?
- @projects = Project.visible.like(params[:q]).to_a
- else
- @projects = User.current.projects.to_a
- end
- }
format.api {
@offset, @limit = api_offset_and_limit
@project_count = scope.count
end
end
+ def autocomplete
+ respond_to do |format|
+ format.js {
+ if params[:q].present?
+ @projects = Project.visible.like(params[:q]).to_a
+ else
+ @projects = User.current.projects.to_a
+ end
+ }
+ end
+ end
+
def new
@issue_custom_fields = IssueCustomField.sorted.to_a
@trackers = Tracker.sorted.to_a
projects = projects_for_jump_box(User.current)
text = @project.try(:name) || l(:label_jump_to_a_project)
trigger = content_tag('span', text, :class => 'drdn-trigger')
- q = text_field_tag('q', '', :id => 'projects-quick-search', :class => 'autocomplete', :data => {:automcomplete_url => projects_path(:format => 'js')}, :autocomplete => 'off')
+ q = text_field_tag('q', '', :id => 'projects-quick-search', :class => 'autocomplete', :data => {:automcomplete_url => autocomplete_projects_path(:format => 'js')}, :autocomplete => 'off')
all = link_to(l(:label_project_all), projects_path(:jump => current_menu_item), :class => (@project.nil? && controller.class.main_menu ? 'selected' : nil))
content = content_tag('div',
content_tag('div', q, :class => 'quick-search') +
--- /dev/null
+<% s = @projects.any? ? render_projects_for_jump_box(@projects) : content_tag('span', l(:label_no_data)) %>
+$('#project-jump .drdn-items.projects').html('<%= escape_javascript s %>');
+++ /dev/null
-<% s = @projects.any? ? render_projects_for_jump_box(@projects) : content_tag('span', l(:label_no_data)) %>
-$('#project-jump .drdn-items.projects').html('<%= escape_javascript s %>');
delete 'issues/:object_id/watchers/:user_id' => 'watchers#destroy', :object_type => 'issue'
resources :projects do
+ collection do
+ get 'autocomplete'
+ end
+
member do
get 'settings(/:tab)', :action => 'settings', :as => 'settings'
post 'modules'
assert_select 'feed>entry', :count => Project.visible(User.current).count
end
- def test_index_js
- xhr :get, :index, :format => 'js', :q => 'coo'
+ def test_autocomplete_js
+ xhr :get, :autocomplete, :format => 'js', :q => 'coo'
assert_response :success
assert_equal 'text/javascript', response.content_type
end
should_route 'GET /projects/new' => 'projects#new'
should_route 'POST /projects' => 'projects#create'
+ should_route 'GET /projects/autocomplete.js' => 'projects#autocomplete', :format => 'js'
+
should_route 'GET /projects/foo' => 'projects#show', :id => 'foo'
should_route 'PUT /projects/foo' => 'projects#update', :id => 'foo'
should_route 'DELETE /projects/foo' => 'projects#destroy', :id => 'foo'