project_jump_dropdown.patch

3.0-stable @14155 - Sebastian Paluch, 2015-04-13 10:08

Download (1.26 KB)

View differences:

app/helpers/application_helper.rb (working copy)
327 327
  # Renders the project quick-jump box
328 328
  def render_project_jump_box
329 329
    return unless User.current.logged?
330
    projects = User.current.projects.active.select(:id, :name, :identifier, :lft, :rgt).to_a
330
    projects = []
331
    user_projects = User.current.projects.active.to_a
332
    user_projects.each { |p|  projects.concat(p.self_and_ancestors.select(:id, :name, :identifier, :lft, :rgt).visible.to_a) }
333
    projects.uniq!
331 334
    if projects.any?
332 335
      options =
333 336
        ("<option value=''>#{ l(:label_jump_to_a_project) }</option>" +
334 337
         '<option value="" disabled="disabled">---</option>').html_safe
335 338

  
336 339
      options << project_tree_options_for_select(projects, :selected => @project) do |p|
337
        { :value => project_path(:id => p, :jump => current_menu_item) }
340
        { :value => project_path(:id => p, :jump => current_menu_item), :disabled => user_projects.include?(p) ? nil : 'disabled' }
338 341
      end
339 342

  
340 343
      select_tag('project_quick_jump_box', options, :onchange => 'if (this.value != \'\') { window.location = this.value; }')