class TaskJuggler::Navigator

A Navigator is an automatically generated menu to navigate a list of reports. The hierarchical structure of the reports will be reused to group them. The actual structure of the Navigator depends on the output format.



Public Class Methods

new(id, project) click to toggle source
# File lib/taskjuggler/reports/Navigator.rb, line 105
def initialize(id, project)
  @id = id
  @project = project
  @hideReport =
  @elements = []

Public Instance Methods

generate(allReports, currentReports, reportDef, parentElement) click to toggle source

Generate an output format independant version of the navigator. This is a tree of NavigatorElement objects.

# File lib/taskjuggler/reports/Navigator.rb, line 114
def generate(allReports, currentReports, reportDef, parentElement)
  element = nextParentElement = nextParentReport = nil
  currentReports.each do |report|
    hasURL = report.get('formats').include?(:html)
    # Only generate menu entries for container reports or leaf reports
    # have a HTML output format.
    next if (report.leaf? && !hasURL) || !allReports.include?(report)

    # What label should be used for the menu entry? It's either the name
    # of the report or the user specified title.
    label = report.get('title') ||

    url = findReportURL(report, allReports, reportDef)

    # Now we have all data so we can create the actual menu entry.
    parentElement.elements <<
      (element =, label, url))

    # Check if 'report' matches the 'reportDef' report or is a child of
    # it.
    if reportDef == report || reportDef.isChildOf?(report)
      nextParentReport = report
      nextParentElement = element
      element.current = true

  if nextParentReport && nextParentReport.container?
    generate(allReports,, reportDef,
to_html() click to toggle source
# File lib/taskjuggler/reports/Navigator.rb, line 147
def to_html
  # The the Report object that contains this Navigator.
  reportDef ||=
  raise "Report context missing" unless reportDef

  # Compile a list of all reports that the user wants to include in the
  # menu.
  reports = filterReports
  return nil if reports.empty?

  # Make sure the report is actually in the filtered list.
  unless reports.include?(reportDef)
                     "Navigator requested for a report that is not " +
                     "included in the navigator list.",
    return nil

  # Find the list of reports that become the top-level menu entries.
  topLevelReports = [ reportDef ]
  report = reportDef
  while report.parent
    report = report.parent
    topLevelReports =

  generate(reports, topLevelReports, reportDef,
           content =