Parent

Class Index [+]

Quicksearch

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.

Attributes

id[R]
hideReport[RW]
reportRoot[RW]

Public Class Methods

new(id, project) click to toggle source
     # File lib/taskjuggler/reports/Navigator.rb, line 120
120:     def initialize(id, project)
121:       @id = id
122:       @project = project
123:       @hideReport = LogicalExpression.new(LogicalOperation.new(0))
124:       @reportRoot = nil
125:       @elements = []
126:     end

Public Instance Methods

generate(reports, reportRoot, 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 130
130:     def generate(reports, reportRoot, parentElement)
131:       reportDef = @project.reportContexts.last.report
132:       raise "Report context missing" unless reportDef
133: 
134:       interactive = false
135:       reports.each do |report|
136:         # The outermost (top-level) report determines whether the report
137:         # should be rendered interactive or not.
138:         interactive = report.interactive?  unless interactive
139: 
140:         hasURL = report.get('formats').include?(:html)
141:         # Only generate menu entries for reports that are not the reportRoot,
142:         # that are leaf reports and have an HTML output format.
143:         next if (report.parent != reportRoot) ||
144:                 (report.leaf? && !hasURL)
145: 
146:         label = report.get('title') || report.name
147:         # Determine the URL for this element.
148:         if hasURL
149:           if interactive
150:             url = "/taskjuggler?project=#{report.project['projectid']};" +
151:                   "report=#{report.fullId}"
152:           else
153:             url = report.name + '.html'
154:             url = normalizeURL(url, reportDef.name)
155:           end
156:         end
157:         parentElement.elements <<
158:           (element =  NavigatorElement.new(parentElement, label, url))
159: 
160:         if report == reportDef
161:           element.currentUrl = url
162:           # Mark this element and all its parents as current.
163:           nEl = element
164:           while nEl
165:             nEl.current = true
166:             nEl = nEl.parent
167:           end
168:         end
169: 
170:         generate(reports, report, element)
171:       end
172:     end
to_html() click to toggle source
     # File lib/taskjuggler/reports/Navigator.rb, line 174
174:     def to_html
175:       reports = filterReports
176:       return nil if reports.empty?
177: 
178:       generate(reports, nil, content = NavigatorElement.new(nil))
179:       content.to_html
180:     end

Private Instance Methods

filterReports() click to toggle source
     # File lib/taskjuggler/reports/Navigator.rb, line 184
184:     def filterReports
185:       list = PropertyList.new(@project.reports)
186:       list.setSorting([[ 'seqno', true, 1 ]])
187:       list.sort!
188:       # Remove all reports that the user doesn't want to have include.
189:       query = @project.reportContexts.last.query.dup
190:       query.scopeProperty = nil
191:       query.scenarioIdx = query.scenario = nil
192:       list.delete_if do |property|
193:         query.property = property
194:         @hideReport.eval(query)
195:       end
196:       list
197:     end
normalizeURL(url1, url2) click to toggle source

Remove the URL or directory path from url1 that is identical to url2.

     # File lib/taskjuggler/reports/Navigator.rb, line 201
201:     def normalizeURL(url1, url2)
202:       cut = 0
203:       url1.length.times do |i|
204:         return url1[cut, url1.length - cut] if url1[i] != url2[i]
205:         cut = i + 1 if url1[i] == //
206:       end
207: 
208:       url1
209:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.