OpenProject is the leading open source project management software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openproject/app/helpers/breadcrumb_helper.rb

52 lines
1.5 KiB

module BreadcrumbHelper
def full_breadcrumb
breadcrumb_list(link_to(l(:label_home), home_path),
link_to_project_ancestors(@project),
*breadcrumb_paths)
end
def breadcrumb(*args)
elements = args.flatten
elements.any? ? content_tag('p', (args.join(' » ') + ' » ').html_safe, :class => 'breadcrumb') : nil
end
def breadcrumb_list(*args)
elements = args.flatten
cutme_elements = []
breadcrumb_elements = [content_tag(:li, elements.shift.to_s, :class => 'first-breadcrumb-element', :style => 'list-style-image:none;')]
breadcrumb_elements += elements.collect do |element|
content_tag(:li, h(element.to_s)) if element
end
content_tag(:ul, breadcrumb_elements.join.html_safe, :class => 'breadcrumb')
end
def breadcrumb_paths(*args)
if args.nil?
nil
elsif args.empty?
@breadcrumb_paths ||= [default_breadcrumb]
else
@breadcrumb_paths ||= []
@breadcrumb_paths += args
end
end
private
def link_to_project_ancestors(project)
if project && !project.new_record?
ancestors = (project.root? ? [] : project.ancestors.visible)
ancestors << project
ancestors.collect do |p|
if p == project
link_to_project(p, {:jump => current_menu_item}, {:title => p, :class => 'breadcrumb-project-title nocut'}).html_safe
else
link_to_project(p, {:jump => current_menu_item}, {:title => p}).html_safe
end
end
end
end
end