mirror of
https://github.com/meineerde/redmine.git
synced 2025-12-20 15:31:12 +00:00
Adds a link to all projects in the jump drop down (#23310).
git-svn-id: http://svn.redmine.org/redmine/trunk@16172 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
f1a42f21a6
commit
2734eaffd8
@ -36,6 +36,11 @@ class ProjectsController < ApplicationController
|
|||||||
|
|
||||||
# Lists visible projects
|
# Lists visible projects
|
||||||
def index
|
def index
|
||||||
|
# try to redirect to the requested menu item
|
||||||
|
if params[:jump] && redirect_to_menu_item(params[:jump])
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
scope = Project.visible.sorted
|
scope = Project.visible.sorted
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
|
|||||||
@ -362,9 +362,11 @@ module ApplicationHelper
|
|||||||
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')})
|
q = text_field_tag('q', '', :id => 'projects-quick-search', :class => 'autocomplete', :data => {:automcomplete_url => projects_path(:format => 'js')})
|
||||||
|
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') +
|
||||||
content_tag('div', render_projects_for_jump_box(projects, @project), :class => 'drdn-items selection'),
|
content_tag('div', render_projects_for_jump_box(projects, @project), :class => 'drdn-items projects selection') +
|
||||||
|
content_tag('div', all, :class => 'drdn-items all-projects selection'),
|
||||||
:class => 'drdn-content'
|
:class => 'drdn-content'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -1,2 +1,2 @@
|
|||||||
<% s = @projects.any? ? render_projects_for_jump_box(@projects) : content_tag('span', l(:label_no_data)) %>
|
<% s = @projects.any? ? render_projects_for_jump_box(@projects) : content_tag('span', l(:label_no_data)) %>
|
||||||
$('#project-jump .drdn-items').html('<%= escape_javascript s %>');
|
$('#project-jump .drdn-items.projects').html('<%= escape_javascript s %>');
|
||||||
|
|||||||
@ -68,12 +68,21 @@ module Redmine
|
|||||||
menu_items[controller_name.to_sym][:default]
|
menu_items[controller_name.to_sym][:default]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Redirects user to the menu item
|
||||||
|
# Returns false if user is not authorized
|
||||||
|
def redirect_to_menu_item(name)
|
||||||
|
redirect_to_project_menu_item(nil, name)
|
||||||
|
end
|
||||||
|
|
||||||
# Redirects user to the menu item of the given project
|
# Redirects user to the menu item of the given project
|
||||||
# Returns false if user is not authorized
|
# Returns false if user is not authorized
|
||||||
def redirect_to_project_menu_item(project, name)
|
def redirect_to_project_menu_item(project, name)
|
||||||
item = Redmine::MenuManager.items(:project_menu).detect {|i| i.name.to_s == name.to_s}
|
menu = project.nil? ? :application_menu : :project_menu
|
||||||
|
item = Redmine::MenuManager.items(menu).detect {|i| i.name.to_s == name.to_s}
|
||||||
if item && item.allowed?(User.current, project)
|
if item && item.allowed?(User.current, project)
|
||||||
redirect_to({item.param => project}.merge(item.url))
|
url = item.url
|
||||||
|
url = {item.param => project}.merge(url) if project
|
||||||
|
redirect_to url
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
false
|
false
|
||||||
|
|||||||
@ -177,7 +177,7 @@ a.toggle-checkboxes { margin-left: 5px; padding-left: 12px; background: url(../i
|
|||||||
.drdn-content .autocomplete {box-sizing: border-box; width:100% !important; height:28px;}
|
.drdn-content .autocomplete {box-sizing: border-box; width:100% !important; height:28px;}
|
||||||
.drdn-content .autocomplete:focus {border-color:#5ad;}
|
.drdn-content .autocomplete:focus {border-color:#5ad;}
|
||||||
.drdn-items {max-height:400px; overflow:auto;}
|
.drdn-items {max-height:400px; overflow:auto;}
|
||||||
.quick-search + .drdn-items {border-top:1px solid #ccc;}
|
div + .drdn-items {border-top:1px solid #ccc;}
|
||||||
.drdn-items>* {
|
.drdn-items>* {
|
||||||
display:block;
|
display:block;
|
||||||
border:1px solid #fff;
|
border:1px solid #fff;
|
||||||
|
|||||||
@ -745,6 +745,16 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||||||
assert_select_error /Identifier cannot be blank/
|
assert_select_error /Identifier cannot be blank/
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_jump_without_project_id_should_redirect_to_active_tab
|
||||||
|
get :index, :jump => 'issues'
|
||||||
|
assert_redirected_to '/issues'
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_jump_should_not_redirect_to_unknown_tab
|
||||||
|
get :index, :jump => 'foobar'
|
||||||
|
assert_response :success
|
||||||
|
end
|
||||||
|
|
||||||
def test_jump_should_redirect_to_active_tab
|
def test_jump_should_redirect_to_active_tab
|
||||||
get :show, :id => 1, :jump => 'issues'
|
get :show, :id => 1, :jump => 'issues'
|
||||||
assert_redirected_to '/projects/ecookbook/issues'
|
assert_redirected_to '/projects/ecookbook/issues'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user