@@ -36,6 +36,11 class ProjectsController < ApplicationController | |||||
36 |
|
36 | |||
37 | # Lists visible projects |
|
37 | # Lists visible projects | |
38 | def index |
|
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 | scope = Project.visible.sorted |
|
44 | scope = Project.visible.sorted | |
40 |
|
45 | |||
41 | respond_to do |format| |
|
46 | respond_to do |format| |
@@ -362,9 +362,11 module ApplicationHelper | |||||
362 | text = @project.try(:name) || l(:label_jump_to_a_project) |
|
362 | text = @project.try(:name) || l(:label_jump_to_a_project) | |
363 | trigger = content_tag('span', text, :class => 'drdn-trigger') |
|
363 | trigger = content_tag('span', text, :class => 'drdn-trigger') | |
364 | q = text_field_tag('q', '', :id => 'projects-quick-search', :class => 'autocomplete', :data => {:automcomplete_url => projects_path(:format => 'js')}) |
|
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 | content = content_tag('div', |
|
366 | content = content_tag('div', | |
366 | content_tag('div', q, :class => 'quick-search') + |
|
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 | :class => 'drdn-content' |
|
370 | :class => 'drdn-content' | |
369 | ) |
|
371 | ) | |
370 |
|
372 |
@@ -1,2 +1,2 | |||||
1 | <% s = @projects.any? ? render_projects_for_jump_box(@projects) : content_tag('span', l(:label_no_data)) %> |
|
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 | menu_items[controller_name.to_sym][:default] |
|
68 | menu_items[controller_name.to_sym][:default] | |
69 | end |
|
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 | # Redirects user to the menu item of the given project |
|
77 | # Redirects user to the menu item of the given project | |
72 | # Returns false if user is not authorized |
|
78 | # Returns false if user is not authorized | |
73 | def redirect_to_project_menu_item(project, name) |
|
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 | if item && item.allowed?(User.current, project) |
|
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 | return true |
|
86 | return true | |
78 | end |
|
87 | end | |
79 | false |
|
88 | false |
@@ -177,7 +177,7 a.toggle-checkboxes { margin-left: 5px; padding-left: 12px; background: url(../i | |||||
177 | .drdn-content .autocomplete {box-sizing: border-box; width:100% !important; height:28px;} |
|
177 | .drdn-content .autocomplete {box-sizing: border-box; width:100% !important; height:28px;} | |
178 | .drdn-content .autocomplete:focus {border-color:#5ad;} |
|
178 | .drdn-content .autocomplete:focus {border-color:#5ad;} | |
179 | .drdn-items {max-height:400px; overflow:auto;} |
|
179 | .drdn-items {max-height:400px; overflow:auto;} | |
180 |
|
|
180 | div + .drdn-items {border-top:1px solid #ccc;} | |
181 | .drdn-items>* { |
|
181 | .drdn-items>* { | |
182 | display:block; |
|
182 | display:block; | |
183 | border:1px solid #fff; |
|
183 | border:1px solid #fff; |
@@ -745,6 +745,16 class ProjectsControllerTest < Redmine::ControllerTest | |||||
745 | assert_select_error /Identifier cannot be blank/ |
|
745 | assert_select_error /Identifier cannot be blank/ | |
746 | end |
|
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 | def test_jump_should_redirect_to_active_tab |
|
758 | def test_jump_should_redirect_to_active_tab | |
749 | get :show, :id => 1, :jump => 'issues' |
|
759 | get :show, :id => 1, :jump => 'issues' | |
750 | assert_redirected_to '/projects/ecookbook/issues' |
|
760 | assert_redirected_to '/projects/ecookbook/issues' |
General Comments 0
You need to be logged in to leave comments.
Login now