##// END OF EJS Templates
Adds a link to all projects in the jump drop down (#23310)....
Jean-Philippe Lang -
r15790:2734eaffd823
parent child
Show More
@@ -36,6 +36,11 class ProjectsController < ApplicationController
36 36
37 37 # Lists visible projects
38 38 def index
39 # try to redirect to the requested menu item
40 if params[:jump] && redirect_to_menu_item(params[:jump])
41 return
42 end
43
39 44 scope = Project.visible.sorted
40 45
41 46 respond_to do |format|
@@ -362,9 +362,11 module ApplicationHelper
362 362 text = @project.try(:name) || l(:label_jump_to_a_project)
363 363 trigger = content_tag('span', text, :class => 'drdn-trigger')
364 364 q = text_field_tag('q', '', :id => 'projects-quick-search', :class => 'autocomplete', :data => {:automcomplete_url => projects_path(:format => 'js')})
365 all = link_to(l(:label_project_all), projects_path(:jump => current_menu_item), :class => (@project.nil? && controller.class.main_menu ? 'selected' : nil))
365 366 content = content_tag('div',
366 367 content_tag('div', q, :class => 'quick-search') +
367 content_tag('div', render_projects_for_jump_box(projects, @project), :class => 'drdn-items selection'),
368 content_tag('div', render_projects_for_jump_box(projects, @project), :class => 'drdn-items projects selection') +
369 content_tag('div', all, :class => 'drdn-items all-projects selection'),
368 370 :class => 'drdn-content'
369 371 )
370 372
@@ -1,2 +1,2
1 1 <% s = @projects.any? ? render_projects_for_jump_box(@projects) : content_tag('span', l(:label_no_data)) %>
2 $('#project-jump .drdn-items').html('<%= escape_javascript s %>');
2 $('#project-jump .drdn-items.projects').html('<%= escape_javascript s %>');
@@ -68,12 +68,21 module Redmine
68 68 menu_items[controller_name.to_sym][:default]
69 69 end
70 70
71 # Redirects user to the menu item
72 # Returns false if user is not authorized
73 def redirect_to_menu_item(name)
74 redirect_to_project_menu_item(nil, name)
75 end
76
71 77 # Redirects user to the menu item of the given project
72 78 # Returns false if user is not authorized
73 79 def redirect_to_project_menu_item(project, name)
74 item = Redmine::MenuManager.items(:project_menu).detect {|i| i.name.to_s == name.to_s}
80 menu = project.nil? ? :application_menu : :project_menu
81 item = Redmine::MenuManager.items(menu).detect {|i| i.name.to_s == name.to_s}
75 82 if item && item.allowed?(User.current, project)
76 redirect_to({item.param => project}.merge(item.url))
83 url = item.url
84 url = {item.param => project}.merge(url) if project
85 redirect_to url
77 86 return true
78 87 end
79 88 false
@@ -177,7 +177,7 a.toggle-checkboxes { margin-left: 5px; padding-left: 12px; background: url(../i
177 177 .drdn-content .autocomplete {box-sizing: border-box; width:100% !important; height:28px;}
178 178 .drdn-content .autocomplete:focus {border-color:#5ad;}
179 179 .drdn-items {max-height:400px; overflow:auto;}
180 .quick-search + .drdn-items {border-top:1px solid #ccc;}
180 div + .drdn-items {border-top:1px solid #ccc;}
181 181 .drdn-items>* {
182 182 display:block;
183 183 border:1px solid #fff;
@@ -745,6 +745,16 class ProjectsControllerTest < Redmine::ControllerTest
745 745 assert_select_error /Identifier cannot be blank/
746 746 end
747 747
748 def test_jump_without_project_id_should_redirect_to_active_tab
749 get :index, :jump => 'issues'
750 assert_redirected_to '/issues'
751 end
752
753 def test_jump_should_not_redirect_to_unknown_tab
754 get :index, :jump => 'foobar'
755 assert_response :success
756 end
757
748 758 def test_jump_should_redirect_to_active_tab
749 759 get :show, :id => 1, :jump => 'issues'
750 760 assert_redirected_to '/projects/ecookbook/issues'
General Comments 0
You need to be logged in to leave comments. Login now