Commit b0be3b95 authored by Jean-Philippe Lang's avatar Jean-Philippe Lang

Ability to search a project and its subprojects (#1264).

git-svn-id: http://redmine.rubyforge.org/svn/trunk@1439 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 94dbf641
...@@ -30,11 +30,13 @@ class SearchController < ApplicationController ...@@ -30,11 +30,13 @@ class SearchController < ApplicationController
@titles_only = !params[:titles_only].nil? @titles_only = !params[:titles_only].nil?
projects_to_search = projects_to_search =
case params[:projects] case params[:scope]
when 'all' when 'all'
nil nil
when 'my_projects' when 'my_projects'
User.current.memberships.collect(&:project) User.current.memberships.collect(&:project)
when 'subprojects'
@project ? ([ @project ] + @project.active_children) : nil
else else
@project @project
end end
......
...@@ -39,7 +39,8 @@ module SearchHelper ...@@ -39,7 +39,8 @@ module SearchHelper
def project_select_tag def project_select_tag
options = [[l(:label_project_all), 'all']] options = [[l(:label_project_all), 'all']]
options << [l(:label_my_projects), 'my_projects'] unless User.current.memberships.empty? options << [l(:label_my_projects), 'my_projects'] unless User.current.memberships.empty?
options << [l(:label_and_its_subprojects, @project.name), 'subprojects'] unless @project.nil? || @project.active_children.empty?
options << [@project.name, ''] unless @project.nil? options << [@project.name, ''] unless @project.nil?
select_tag('projects', options_for_select(options, params[:projects].to_s)) if options.size > 1 select_tag('scope', options_for_select(options, params[:scope].to_s)) if options.size > 1
end end
end end
...@@ -618,3 +618,4 @@ setting_default_projects_public: Новите проекти са публичн ...@@ -618,3 +618,4 @@ setting_default_projects_public: Новите проекти са публичн
error_scm_annotate: "Обектът не съществува или не може да бъде анотиран." error_scm_annotate: "Обектът не съществува или не може да бъде анотиран."
label_planning: Планиране label_planning: Планиране
text_subprojects_destroy_warning: 'Its subproject(s): %s will be also deleted.' text_subprojects_destroy_warning: 'Its subproject(s): %s will be also deleted.'
label_and_its_subprojects: %s and its subprojects
...@@ -623,3 +623,4 @@ enumeration_activities: Aktivity (sledování času) ...@@ -623,3 +623,4 @@ enumeration_activities: Aktivity (sledování času)
error_scm_annotate: "Položka neexistuje nebo nemůže být komentována." error_scm_annotate: "Položka neexistuje nebo nemůže být komentována."
label_planning: Plánování label_planning: Plánování
text_subprojects_destroy_warning: 'Its subproject(s): %s will be also deleted.' text_subprojects_destroy_warning: 'Its subproject(s): %s will be also deleted.'
label_and_its_subprojects: %s and its subprojects
...@@ -620,3 +620,4 @@ setting_default_projects_public: Nye projekter er offentlige som default ...@@ -620,3 +620,4 @@ setting_default_projects_public: Nye projekter er offentlige som default
error_scm_annotate: "The entry does not exist or can not be annotated." error_scm_annotate: "The entry does not exist or can not be annotated."
label_planning: Planlægning label_planning: Planlægning
text_subprojects_destroy_warning: 'Its subproject(s): %s will be also deleted.' text_subprojects_destroy_warning: 'Its subproject(s): %s will be also deleted.'
label_and_its_subprojects: %s and its subprojects
...@@ -619,3 +619,4 @@ enumeration_issue_priorities: Ticket-Prioritäten ...@@ -619,3 +619,4 @@ enumeration_issue_priorities: Ticket-Prioritäten
enumeration_doc_categories: Dokumentenkategorien enumeration_doc_categories: Dokumentenkategorien
enumeration_activities: Aktivitäten (Zeiterfassung) enumeration_activities: Aktivitäten (Zeiterfassung)
text_subprojects_destroy_warning: 'Its subproject(s): %s will be also deleted.' text_subprojects_destroy_warning: 'Its subproject(s): %s will be also deleted.'
label_and_its_subprojects: %s and its subprojects
...@@ -291,6 +291,7 @@ label_auth_source: Authentication mode ...@@ -291,6 +291,7 @@ label_auth_source: Authentication mode
label_auth_source_new: New authentication mode label_auth_source_new: New authentication mode
label_auth_source_plural: Authentication modes label_auth_source_plural: Authentication modes
label_subproject_plural: Subprojects label_subproject_plural: Subprojects
label_and_its_subprojects: %s and its subprojects
label_min_max_length: Min - Max length label_min_max_length: Min - Max length
label_list: List label_list: List
label_date: Date label_date: Date
......
...@@ -621,3 +621,4 @@ setting_default_projects_public: Los proyectos nuevos son públicos por defecto ...@@ -621,3 +621,4 @@ setting_default_projects_public: Los proyectos nuevos son públicos por defecto
error_scm_annotate: "No existe la entrada o no ha podido ser anotada" error_scm_annotate: "No existe la entrada o no ha podido ser anotada"
label_planning: Planificación label_planning: Planificación
text_subprojects_destroy_warning: 'Sus subprojectos: %s también se eliminarán' text_subprojects_destroy_warning: 'Sus subprojectos: %s también se eliminarán'
label_and_its_subprojects: %s and its subprojects
...@@ -618,3 +618,4 @@ label_overall_activity: Kokonaishistoria ...@@ -618,3 +618,4 @@ label_overall_activity: Kokonaishistoria
error_scm_annotate: "Merkintää ei ole tai siihen ei voi lisätä selityksiä." error_scm_annotate: "Merkintää ei ole tai siihen ei voi lisätä selityksiä."
label_planning: Suunnittelu label_planning: Suunnittelu
text_subprojects_destroy_warning: 'Tämän alaprojekti(t): %s tullaan myös poistamaan.' text_subprojects_destroy_warning: 'Tämän alaprojekti(t): %s tullaan myös poistamaan.'
label_and_its_subprojects: %s and its subprojects
...@@ -291,6 +291,7 @@ label_auth_source: Mode d'authentification ...@@ -291,6 +291,7 @@ label_auth_source: Mode d'authentification
label_auth_source_new: Nouveau mode d'authentification label_auth_source_new: Nouveau mode d'authentification
label_auth_source_plural: Modes d'authentification label_auth_source_plural: Modes d'authentification
label_subproject_plural: Sous-projets label_subproject_plural: Sous-projets
label_and_its_subprojects: %s et ses sous-projets
label_min_max_length: Longueurs mini - maxi label_min_max_length: Longueurs mini - maxi
label_list: Liste label_list: Liste
label_date: Date label_date: Date
......
...@@ -618,3 +618,4 @@ setting_default_projects_public: פרויקטים חדשים הינם פומבי ...@@ -618,3 +618,4 @@ setting_default_projects_public: פרויקטים חדשים הינם פומבי
error_scm_annotate: "הכניסה לא קיימת או שלא ניתן לתאר אותה." error_scm_annotate: "הכניסה לא קיימת או שלא ניתן לתאר אותה."
label_planning: תכנון label_planning: תכנון
text_subprojects_destroy_warning: 'Its subproject(s): %s will be also deleted.' text_subprojects_destroy_warning: 'Its subproject(s): %s will be also deleted.'
label_and_its_subprojects: %s and its subprojects
...@@ -618,3 +618,4 @@ setting_default_projects_public: New projects are public by default ...@@ -618,3 +618,4 @@ setting_default_projects_public: New projects are public by default
error_scm_annotate: "The entry does not exist or can not be annotated." error_scm_annotate: "The entry does not exist or can not be annotated."
label_planning: Planning label_planning: Planning
text_subprojects_destroy_warning: 'Its subproject(s): %s will be also deleted.' text_subprojects_destroy_warning: 'Its subproject(s): %s will be also deleted.'
label_and_its_subprojects: %s and its subprojects
...@@ -619,3 +619,4 @@ setting_default_projects_public: デフォルトで新しいプロジェクト ...@@ -619,3 +619,4 @@ setting_default_projects_public: デフォルトで新しいプロジェクト
error_scm_annotate: "エントリが存在しない、もしくはアノテートできません。" error_scm_annotate: "エントリが存在しない、もしくはアノテートできません。"
label_planning: 計画 label_planning: 計画
text_subprojects_destroy_warning: 'Its subproject(s): %s will be also deleted.' text_subprojects_destroy_warning: 'Its subproject(s): %s will be also deleted.'
label_and_its_subprojects: %s and its subprojects
...@@ -618,3 +618,4 @@ setting_default_projects_public: New projects are public by default ...@@ -618,3 +618,4 @@ setting_default_projects_public: New projects are public by default
error_scm_annotate: "The entry does not exist or can not be annotated." error_scm_annotate: "The entry does not exist or can not be annotated."
label_planning: Planning label_planning: Planning
text_subprojects_destroy_warning: 'Its subproject(s): %s will be also deleted.' text_subprojects_destroy_warning: 'Its subproject(s): %s will be also deleted.'
label_and_its_subprojects: %s and its subprojects
...@@ -619,3 +619,4 @@ setting_default_projects_public: New projects are public by default ...@@ -619,3 +619,4 @@ setting_default_projects_public: New projects are public by default
error_scm_annotate: "The entry does not exist or can not be annotated." error_scm_annotate: "The entry does not exist or can not be annotated."
label_planning: Planning label_planning: Planning
text_subprojects_destroy_warning: 'Its subproject(s): %s will be also deleted.' text_subprojects_destroy_warning: 'Its subproject(s): %s will be also deleted.'
label_and_its_subprojects: %s and its subprojects
...@@ -619,3 +619,4 @@ setting_default_projects_public: New projects are public by default ...@@ -619,3 +619,4 @@ setting_default_projects_public: New projects are public by default
error_scm_annotate: "The entry does not exist or can not be annotated." error_scm_annotate: "The entry does not exist or can not be annotated."
label_planning: Planning label_planning: Planning
text_subprojects_destroy_warning: 'Its subproject(s): %s will be also deleted.' text_subprojects_destroy_warning: 'Its subproject(s): %s will be also deleted.'
label_and_its_subprojects: %s and its subprojects
...@@ -619,3 +619,4 @@ default_activity_development: Utvikling ...@@ -619,3 +619,4 @@ default_activity_development: Utvikling
enumeration_issue_priorities: Sakssprioriteringer enumeration_issue_priorities: Sakssprioriteringer
enumeration_doc_categories: Dokument-kategorier enumeration_doc_categories: Dokument-kategorier
enumeration_activities: Aktiviteter (tidssporing) enumeration_activities: Aktiviteter (tidssporing)
label_and_its_subprojects: %s and its subprojects
...@@ -618,3 +618,4 @@ setting_default_projects_public: Nowe projekty są domyślnie publiczne ...@@ -618,3 +618,4 @@ setting_default_projects_public: Nowe projekty są domyślnie publiczne
error_scm_annotate: "Wpis nie istnieje lub nie można do niego dodawać adnotacji." error_scm_annotate: "Wpis nie istnieje lub nie można do niego dodawać adnotacji."
label_planning: Planning label_planning: Planning
text_subprojects_destroy_warning: 'Its subproject(s): %s will be also deleted.' text_subprojects_destroy_warning: 'Its subproject(s): %s will be also deleted.'
label_and_its_subprojects: %s and its subprojects
...@@ -618,3 +618,4 @@ setting_default_projects_public: New projects are public by default ...@@ -618,3 +618,4 @@ setting_default_projects_public: New projects are public by default
error_scm_annotate: "The entry does not exist or can not be annotated." error_scm_annotate: "The entry does not exist or can not be annotated."
label_planning: Planning label_planning: Planning
text_subprojects_destroy_warning: 'Its subproject(s): %s will be also deleted.' text_subprojects_destroy_warning: 'Its subproject(s): %s will be also deleted.'
label_and_its_subprojects: %s and its subprojects
...@@ -618,3 +618,4 @@ setting_default_projects_public: New projects are public by default ...@@ -618,3 +618,4 @@ setting_default_projects_public: New projects are public by default
error_scm_annotate: "The entry does not exist or can not be annotated." error_scm_annotate: "The entry does not exist or can not be annotated."
label_planning: Planning label_planning: Planning
text_subprojects_destroy_warning: 'Its subproject(s): %s will be also deleted.' text_subprojects_destroy_warning: 'Its subproject(s): %s will be also deleted.'
label_and_its_subprojects: %s and its subprojects
...@@ -618,3 +618,4 @@ setting_default_projects_public: New projects are public by default ...@@ -618,3 +618,4 @@ setting_default_projects_public: New projects are public by default
error_scm_annotate: "The entry does not exist or can not be annotated." error_scm_annotate: "The entry does not exist or can not be annotated."
label_planning: Planning label_planning: Planning
text_subprojects_destroy_warning: 'Its subproject(s): %s will be also deleted.' text_subprojects_destroy_warning: 'Its subproject(s): %s will be also deleted.'
label_and_its_subprojects: %s and its subprojects
...@@ -622,3 +622,4 @@ setting_default_projects_public: Новые проекты являются пу ...@@ -622,3 +622,4 @@ setting_default_projects_public: Новые проекты являются пу
error_scm_annotate: "Данные отсутствуют или не могут быть подписаны." error_scm_annotate: "Данные отсутствуют или не могут быть подписаны."
label_planning: Планирование label_planning: Планирование
text_subprojects_destroy_warning: 'Its subproject(s): %s will be also deleted.' text_subprojects_destroy_warning: 'Its subproject(s): %s will be also deleted.'
label_and_its_subprojects: %s and its subprojects
...@@ -619,3 +619,4 @@ setting_default_projects_public: New projects are public by default ...@@ -619,3 +619,4 @@ setting_default_projects_public: New projects are public by default
error_scm_annotate: "The entry does not exist or can not be annotated." error_scm_annotate: "The entry does not exist or can not be annotated."
label_planning: Planning label_planning: Planning
text_subprojects_destroy_warning: 'Its subproject(s): %s will be also deleted.' text_subprojects_destroy_warning: 'Its subproject(s): %s will be also deleted.'
label_and_its_subprojects: %s and its subprojects
...@@ -619,3 +619,4 @@ setting_default_projects_public: New projects are public by default ...@@ -619,3 +619,4 @@ setting_default_projects_public: New projects are public by default
error_scm_annotate: "The entry does not exist or can not be annotated." error_scm_annotate: "The entry does not exist or can not be annotated."
label_planning: Planning label_planning: Planning
text_subprojects_destroy_warning: 'Its subproject(s): %s will be also deleted.' text_subprojects_destroy_warning: 'Its subproject(s): %s will be also deleted.'
label_and_its_subprojects: %s and its subprojects
...@@ -621,3 +621,4 @@ default_activity_development: พัฒนา ...@@ -621,3 +621,4 @@ default_activity_development: พัฒนา
enumeration_issue_priorities: ความสำคัญของปัญหา enumeration_issue_priorities: ความสำคัญของปัญหา
enumeration_doc_categories: ประเภทเอกสาร enumeration_doc_categories: ประเภทเอกสาร
enumeration_activities: กิจกรรม (ใช้ในการติดตามเวลา) enumeration_activities: กิจกรรม (ใช้ในการติดตามเวลา)
label_and_its_subprojects: %s and its subprojects
...@@ -620,3 +620,4 @@ setting_default_projects_public: New projects are public by default ...@@ -620,3 +620,4 @@ setting_default_projects_public: New projects are public by default
error_scm_annotate: "The entry does not exist or can not be annotated." error_scm_annotate: "The entry does not exist or can not be annotated."
label_planning: Planning label_planning: Planning
text_subprojects_destroy_warning: 'Its subproject(s): %s will be also deleted.' text_subprojects_destroy_warning: 'Its subproject(s): %s will be also deleted.'
label_and_its_subprojects: %s and its subprojects
...@@ -619,3 +619,4 @@ default_activity_development: 開發 ...@@ -619,3 +619,4 @@ default_activity_development: 開發
enumeration_issue_priorities: 項目優先權 enumeration_issue_priorities: 項目優先權
enumeration_doc_categories: 文件分類 enumeration_doc_categories: 文件分類
enumeration_activities: 活動 (時間追蹤) enumeration_activities: 活動 (時間追蹤)
label_and_its_subprojects: %s and its subprojects
...@@ -619,3 +619,4 @@ default_activity_development: 开发 ...@@ -619,3 +619,4 @@ default_activity_development: 开发
enumeration_issue_priorities: 问题优先级 enumeration_issue_priorities: 问题优先级
enumeration_doc_categories: 文档类别 enumeration_doc_categories: 文档类别
enumeration_activities: 活动(时间跟踪) enumeration_activities: 活动(时间跟踪)
label_and_its_subprojects: %s and its subprojects
...@@ -37,6 +37,14 @@ class SearchControllerTest < Test::Unit::TestCase ...@@ -37,6 +37,14 @@ class SearchControllerTest < Test::Unit::TestCase
assert assigns(:results).include?(Changeset.find(101)) assert assigns(:results).include?(Changeset.find(101))
end end
def test_search_project_and_subprojects
get :index, :id => 1, :q => 'recipe subproject', :scope => 'subprojects', :submit => 'Search'
assert_response :success
assert_template 'index'
assert assigns(:results).include?(Issue.find(1))
assert assigns(:results).include?(Issue.find(5))
end
def test_search_without_searchable_custom_fields def test_search_without_searchable_custom_fields
CustomField.update_all "searchable = #{ActiveRecord::Base.connection.quoted_false}" CustomField.update_all "searchable = #{ActiveRecord::Base.connection.quoted_false}"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment