]> source.dussan.org Git - redmine.git/commitdiff
Search in project and its subprojects by default (#9909).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Wed, 7 Jun 2017 20:50:17 +0000 (20:50 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Wed, 7 Jun 2017 20:50:17 +0000 (20:50 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@16641 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/helpers/application_helper.rb
app/views/layouts/base.html.erb

index 616356a071cd52f009e6ec1690d18ea006162c53..4915cddad55e7f9d5030b018fb66842805f5d6f7 100644 (file)
@@ -346,6 +346,14 @@ module ApplicationHelper
     end
   end
 
+  # Returns the default scope for the quick search form
+  # Could be 'all', 'my_projects', 'subprojects' or nil (current project)
+  def default_search_project_scope
+    if @project && !@project.leaf?
+      'subprojects'
+    end
+  end
+
   # Returns an array of projects that are displayed in the quick-jump box
   def projects_for_jump_box(user=User.current)
     if user.logged?
index 126d86b41851ecb3444b844a524d5b89a3fb2027..4cdefbd47c235ffc8eaaeb25d8a3c1e0742c3b2d 100644 (file)
@@ -75,6 +75,7 @@
     <% if User.current.logged? || !Setting.login_required? %>
     <div id="quick-search">
         <%= form_tag({:controller => 'search', :action => 'index', :id => @project}, :method => :get ) do %>
+        <%= hidden_field_tag 'scope', default_search_project_scope, :id => nil %>
         <%= hidden_field_tag(controller.default_search_scope, 1, :id => nil) if controller.default_search_scope %>
         <label for='q'>
           <%= link_to l(:label_search), {:controller => 'search', :action => 'index', :id => @project}, :accesskey => accesskey(:search) %>: