mirror of
https://github.com/redmine/redmine.git
synced 2025-11-09 23:06:05 +01:00
Moves project quick search to a dedicated action.
git-svn-id: http://svn.redmine.org/redmine/trunk@16550 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -20,8 +20,8 @@ class ProjectsController < ApplicationController
|
|||||||
menu_item :settings, :only => :settings
|
menu_item :settings, :only => :settings
|
||||||
menu_item :projects, :only => [:index, :new, :copy, :create]
|
menu_item :projects, :only => [:index, :new, :copy, :create]
|
||||||
|
|
||||||
before_action :find_project, :except => [ :index, :list, :new, :create, :copy ]
|
before_action :find_project, :except => [ :index, :autocomplete, :list, :new, :create, :copy ]
|
||||||
before_action :authorize, :except => [ :index, :list, :new, :create, :copy, :archive, :unarchive, :destroy]
|
before_action :authorize, :except => [ :index, :autocomplete, :list, :new, :create, :copy, :archive, :unarchive, :destroy]
|
||||||
before_action :authorize_global, :only => [:new, :create]
|
before_action :authorize_global, :only => [:new, :create]
|
||||||
before_action :require_admin, :only => [ :copy, :archive, :unarchive, :destroy ]
|
before_action :require_admin, :only => [ :copy, :archive, :unarchive, :destroy ]
|
||||||
accept_rss_auth :index
|
accept_rss_auth :index
|
||||||
@@ -50,13 +50,6 @@ class ProjectsController < ApplicationController
|
|||||||
end
|
end
|
||||||
@projects = scope.to_a
|
@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 {
|
format.api {
|
||||||
@offset, @limit = api_offset_and_limit
|
@offset, @limit = api_offset_and_limit
|
||||||
@project_count = scope.count
|
@project_count = scope.count
|
||||||
@@ -69,6 +62,18 @@ class ProjectsController < ApplicationController
|
|||||||
end
|
end
|
||||||
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
|
def new
|
||||||
@issue_custom_fields = IssueCustomField.sorted.to_a
|
@issue_custom_fields = IssueCustomField.sorted.to_a
|
||||||
@trackers = Tracker.sorted.to_a
|
@trackers = Tracker.sorted.to_a
|
||||||
|
|||||||
@@ -370,7 +370,7 @@ module ApplicationHelper
|
|||||||
projects = projects_for_jump_box(User.current)
|
projects = projects_for_jump_box(User.current)
|
||||||
text = @project.try(:name) || l(:label_jump_to_a_project)
|
text = @project.try(:name) || l(:label_jump_to_a_project)
|
||||||
trigger = content_tag('span', text, :class => 'drdn-trigger')
|
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))
|
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 = content_tag('div',
|
||||||
content_tag('div', q, :class => 'quick-search') +
|
content_tag('div', q, :class => 'quick-search') +
|
||||||
|
|||||||
@@ -101,6 +101,10 @@ Rails.application.routes.draw do
|
|||||||
delete 'issues/:object_id/watchers/:user_id' => 'watchers#destroy', :object_type => 'issue'
|
delete 'issues/:object_id/watchers/:user_id' => 'watchers#destroy', :object_type => 'issue'
|
||||||
|
|
||||||
resources :projects do
|
resources :projects do
|
||||||
|
collection do
|
||||||
|
get 'autocomplete'
|
||||||
|
end
|
||||||
|
|
||||||
member do
|
member do
|
||||||
get 'settings(/:tab)', :action => 'settings', :as => 'settings'
|
get 'settings(/:tab)', :action => 'settings', :as => 'settings'
|
||||||
post 'modules'
|
post 'modules'
|
||||||
|
|||||||
@@ -52,8 +52,8 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||||||
assert_select 'feed>entry', :count => Project.visible(User.current).count
|
assert_select 'feed>entry', :count => Project.visible(User.current).count
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_index_js
|
def test_autocomplete_js
|
||||||
xhr :get, :index, :format => 'js', :q => 'coo'
|
xhr :get, :autocomplete, :format => 'js', :q => 'coo'
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'text/javascript', response.content_type
|
assert_equal 'text/javascript', response.content_type
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ class RoutingProjectsTest < Redmine::RoutingTest
|
|||||||
should_route 'GET /projects/new' => 'projects#new'
|
should_route 'GET /projects/new' => 'projects#new'
|
||||||
should_route 'POST /projects' => 'projects#create'
|
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 'GET /projects/foo' => 'projects#show', :id => 'foo'
|
||||||
should_route 'PUT /projects/foo' => 'projects#update', :id => 'foo'
|
should_route 'PUT /projects/foo' => 'projects#update', :id => 'foo'
|
||||||
should_route 'DELETE /projects/foo' => 'projects#destroy', :id => 'foo'
|
should_route 'DELETE /projects/foo' => 'projects#destroy', :id => 'foo'
|
||||||
|
|||||||
Reference in New Issue
Block a user