From 07aa3c55bdc72a7ab3565c5903a4560b6785aac5 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Wed, 21 Oct 2009 17:07:18 +0000 Subject: [PATCH] Contextual quick search (#3263). Eg. when viewing issues, the quick search will search issues only. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2943 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/application_controller.rb | 1 + app/controllers/boards_controller.rb | 1 + app/controllers/documents_controller.rb | 1 + app/controllers/issues_controller.rb | 1 + app/controllers/messages_controller.rb | 1 + app/controllers/news_controller.rb | 1 + app/controllers/repositories_controller.rb | 2 + app/controllers/wiki_controller.rb | 1 + app/views/layouts/base.rhtml | 1 + lib/redmine/search.rb | 55 ++++++++++++++++++++++ test/functional/issues_controller_test.rb | 7 +++ 11 files changed, 72 insertions(+) create mode 100644 lib/redmine/search.rb diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 59d117e4f..68377b6f7 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -26,6 +26,7 @@ class ApplicationController < ActionController::Base before_filter :user_setup, :check_if_login_required, :set_localization filter_parameter_logging :password + include Redmine::Search::Controller include Redmine::MenuManager::MenuController helper Redmine::MenuManager::MenuHelper diff --git a/app/controllers/boards_controller.rb b/app/controllers/boards_controller.rb index eaac14e5b..436398d1c 100644 --- a/app/controllers/boards_controller.rb +++ b/app/controllers/boards_controller.rb @@ -16,6 +16,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class BoardsController < ApplicationController + default_search_scope :messages before_filter :find_project, :authorize helper :messages diff --git a/app/controllers/documents_controller.rb b/app/controllers/documents_controller.rb index c2e08768f..c9eecf4f7 100644 --- a/app/controllers/documents_controller.rb +++ b/app/controllers/documents_controller.rb @@ -16,6 +16,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class DocumentsController < ApplicationController + default_search_scope :documents before_filter :find_project, :only => [:index, :new] before_filter :find_document, :except => [:index, :new] before_filter :authorize diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 74fe25d78..bebba10a4 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -17,6 +17,7 @@ class IssuesController < ApplicationController menu_item :new_issue, :only => :new + default_search_scope :issues before_filter :find_issue, :only => [:show, :edit, :reply] before_filter :find_issues, :only => [:bulk_edit, :move, :destroy] diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index f328e9b60..88609738a 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -17,6 +17,7 @@ class MessagesController < ApplicationController menu_item :boards + default_search_scope :messages before_filter :find_board, :only => [:new, :preview] before_filter :find_message, :except => [:new, :preview] before_filter :authorize, :except => [:preview, :edit, :destroy] diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb index a8ad716ee..68d2b2a8b 100644 --- a/app/controllers/news_controller.rb +++ b/app/controllers/news_controller.rb @@ -16,6 +16,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class NewsController < ApplicationController + default_search_scope :news before_filter :find_news, :except => [:new, :index, :preview] before_filter :find_project, :only => [:new, :preview] before_filter :authorize, :except => [:index, :preview] diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 7527f0d9a..8e39d42c7 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -24,6 +24,8 @@ class InvalidRevisionParam < Exception; end class RepositoriesController < ApplicationController menu_item :repository + default_search_scope :changesets + before_filter :find_repository, :except => :edit before_filter :find_project, :only => :edit before_filter :authorize diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb index b000b0596..63382f81c 100644 --- a/app/controllers/wiki_controller.rb +++ b/app/controllers/wiki_controller.rb @@ -18,6 +18,7 @@ require 'diff' class WikiController < ApplicationController + default_search_scope :wiki_pages before_filter :find_wiki, :authorize before_filter :find_existing_page, :only => [:rename, :protect, :history, :diff, :annotate, :add_attachment, :destroy] diff --git a/app/views/layouts/base.rhtml b/app/views/layouts/base.rhtml index 471953a66..d8fdcf0d5 100644 --- a/app/views/layouts/base.rhtml +++ b/app/views/layouts/base.rhtml @@ -31,6 +31,7 @@