summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2020-07-06 14:06:52 +0000
committerGo MAEDA <maeda@farend.jp>2020-07-06 14:06:52 +0000
commitb15d6fc544033c580e28036d217c97edf75218a9 (patch)
tree6c940da3b6cfbe388ac16fb209d8d15388f51485 /app
parentd050d515448607798f20bb91284654ea78d26c6a (diff)
downloadredmine-b15d6fc544033c580e28036d217c97edf75218a9.tar.gz
redmine-b15d6fc544033c580e28036d217c97edf75218a9.zip
Always preserve the tree structure in the project jump box (#32944).
Patch by Jens Krämer. git-svn-id: http://svn.redmine.org/redmine/trunk@19861 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r--app/helpers/application_helper.rb18
-rw-r--r--app/views/projects/autocomplete.js.erb2
-rw-r--r--app/views/projects/bookmark.js.erb2
3 files changed, 12 insertions, 10 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 28186124a..c9869d3d8 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -499,13 +499,15 @@ module ApplicationHelper
end
end
- def render_projects_for_jump_box(projects, selected=nil)
- jump_box = Redmine::ProjectJumpBox.new User.current
- query = params[:q] if request.format.js?
- bookmarked = jump_box.bookmarked_projects(query)
- recents = jump_box.recently_used_projects(query)
- projects = projects - (recents + bookmarked)
- projects_label = (bookmarked.any? || recents.any?) ? :label_optgroup_others : :label_project_plural
+ def render_projects_for_jump_box(projects, selected: nil, query: nil)
+ if query.blank?
+ jump_box = Redmine::ProjectJumpBox.new User.current
+ bookmarked = jump_box.bookmarked_projects
+ recents = jump_box.recently_used_projects
+ projects_label = :label_project_all
+ else
+ projects_label = :label_result_plural
+ end
jump = params[:jump].presence || current_menu_item
s = (+'').html_safe
build_project_link = ->(project, level = 0){
@@ -551,7 +553,7 @@ module ApplicationHelper
content =
content_tag('div',
content_tag('div', q, :class => 'quick-search') +
- content_tag('div', render_projects_for_jump_box(projects, @project),
+ content_tag('div', render_projects_for_jump_box(projects, selected: @project),
:class => 'drdn-items projects selection') +
content_tag('div', all, :class => 'drdn-items all-projects selection'),
:class => 'drdn-content')
diff --git a/app/views/projects/autocomplete.js.erb b/app/views/projects/autocomplete.js.erb
index 03f7fa640..02c8952d4 100644
--- a/app/views/projects/autocomplete.js.erb
+++ b/app/views/projects/autocomplete.js.erb
@@ -1,7 +1,7 @@
<%
s = ''
if @projects.any?
- s = render_projects_for_jump_box(@projects)
+ s = render_projects_for_jump_box(@projects, query: params[:q])
elsif params[:q].present?
s = content_tag('span', l(:label_no_data))
end
diff --git a/app/views/projects/bookmark.js.erb b/app/views/projects/bookmark.js.erb
index 559585c16..f2d515604 100644
--- a/app/views/projects/bookmark.js.erb
+++ b/app/views/projects/bookmark.js.erb
@@ -1,2 +1,2 @@
-$('#project-jump div.drdn-items.projects').html('<%= j render_projects_for_jump_box(projects_for_jump_box(User.current), @project) %>');
+$('#project-jump div.drdn-items.projects').html('<%= j render_projects_for_jump_box(projects_for_jump_box(User.current), selected: @project) %>');
$('.contextual a.icon.bookmark').replaceWith('<%= j bookmark_link @project %>');