Class: TaskJuggler::TableReport
- Inherits:
-
ReportBase
- Object
- ReportBase
- TaskJuggler::TableReport
- Defined in:
- lib/taskjuggler/reports/TableReport.rb
Overview
This is base class for all types of tabular reports. All tabular reports are converted to an abstract (output independent) intermediate form first, before the are turned into the requested output format.
Direct Known Subclasses
Constant Summary collapse
- @@propertiesById =
{ # ID Header Indent Align Scen Spec. 'activetasks' => [ 'Active Tasks', true, :right, true ], 'annualleave' => [ 'Annual Leave', true, :right, true ], 'annualleavebalance'=> [ 'Annual Leave Balance', false, :right, true ], 'annualleavelist' => [ 'Annual Leave List', false, :left, true ], 'alert' => [ 'Alert', true, :left, false ], 'alertmessages' => [ 'Alert Messages', false, :left, false ], 'alertsummaries' => [ 'Alert Summaries', false, :left, false ], 'alerttrend' => [ 'Alert Trend', false, :left, false ], 'balance' => [ 'Balance', true, :right, true ], 'bsi' => [ 'BSI', false, :left, false ], 'children' => [ 'Children' , false, :left, false ], 'closedtasks' => [ 'Closed Tasks', true, :right, true ], 'competitorcount' => [ 'Competitor count', true, :right, true ], 'competitors' => [ 'Competitors', true, :left, true ], 'complete' => [ 'Completion', false, :right, true ], 'cost' => [ 'Cost', true, :right, true ], 'duration' => [ 'Duration', true, :right, true ], 'effort' => [ 'Effort', true, :right, true ], 'effortdone' => [ 'Effort Done', true, :right, true ], 'effortleft' => [ 'Effort Left', true, :right, true ], 'freetime' => [ 'Free Time', true, :right, true ], 'freework' => [ 'Free Work', true, :right, true ], 'followers' => [ 'Followers', false, :left, true ], 'fte' => [ 'FTE', true, :right, true ], 'headcount' => [ 'Headcount', true, :right, true ], 'id' => [ 'Id', false, :left, false ], 'inputs' => [ 'Inputs', false, :left, true ], 'journal' => [ 'Journal', false, :left, false ], 'journal_sub' => [ 'Journal', false, :left, false ], 'journalmessages' => [ 'Journal Messages', false, :left, false ], 'journalsummaries' => [ 'Journal Summaries', false, :left, false ], 'line' => [ 'Line No.', false, :right, false ], 'name' => [ 'Name', true, :left, false ], 'no' => [ 'No.', false, :right, false ], 'opentasks' => [ 'Open Tasks', true, :right, true ], 'precursors' => [ 'Precursors', false, :left, true ], 'rate' => [ 'Rate', true, :right, true ], 'resources' => [ 'Resources', false, :left, true ], 'responsible' => [ 'Responsible', false, :left, true ], 'revenue' => [ 'Revenue', true, :right, true ], 'scenario' => [ 'Scenario', false, :left, true ], 'scheduling' => [ 'Scheduling Mode', true, :left, true ], 'sickleave' => [ 'Sick Leave', true, :right, true ], 'specialleave' => [ 'Special Leave', true, :right, true ], 'status' => [ 'Status', false, :left, true ], 'targets' => [ 'Targets', false, :left, true ], 'unpaidleave' => [ 'Unpaid Leave', true, :right, true ] }
- @@propertiesByType =
{ # Type Indent Align DateAttribute => [ false, :left ], IntegerAttribute => [ false, :right ], FloatAttribute => [ false, :right ], ResourceListAttribute => [ false, :left ], RichTextAttribute => [ false, :left ], StringAttribute => [ false, :left ] }
Instance Attribute Summary collapse
-
#legend ⇒ Object
readonly
Returns the value of attribute legend.
Class Method Summary collapse
-
.alignment(colId, attributeType) ⇒ Object
Return the alignment of the column based on the colId or the attributeType.
-
.calculated?(colId) ⇒ Boolean
This function returns true if the values for the colId column need to be calculated.
-
.defaultColumnTitle(id) ⇒ Object
Returns the default column title for the columns id.
-
.indent(colId, propertyType) ⇒ Object
Return if the column values should be indented based on the colId or the propertyType.
-
.scenarioSpecific?(colId) ⇒ Boolean
This functions returns true if the values for the col_id column are scenario specific.
Instance Method Summary collapse
- #generateIntermediateFormat ⇒ Object
-
#initialize(report) ⇒ TableReport
constructor
Generate a new TableReport object.
-
#to_csv ⇒ Object
Convert the table into an Array of Arrays.
-
#to_html ⇒ Object
Turn the TableReport into an equivalent HTML element tree.
Methods inherited from ReportBase
#a, #filterAccountList, #filterResourceList, #filterTaskList
Constructor Details
#initialize(report) ⇒ TableReport
Generate a new TableReport object.
90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/taskjuggler/reports/TableReport.rb', line 90 def initialize(report) super @report.content = self # Reference to the intermediate representation. @table = nil # The table is generated row after row. We need to hold some computed # values that are specific to certain columns. For that we use a Hash of # ReportTableColumn objects. @columns = { } @legend = ReportTableLegend.new end |
Instance Attribute Details
#legend ⇒ Object (readonly)
Returns the value of attribute legend.
28 29 30 |
# File 'lib/taskjuggler/reports/TableReport.rb', line 28 def legend @legend end |
Class Method Details
.alignment(colId, attributeType) ⇒ Object
Return the alignment of the column based on the colId or the attributeType.
179 180 181 182 183 184 185 186 187 |
# File 'lib/taskjuggler/reports/TableReport.rb', line 179 def TableReport::alignment(colId, attributeType) if @@propertiesById.has_key?(colId) return @@propertiesById[colId][2] elsif @@propertiesByType.has_key?(attributeType) return @@propertiesByType[attributeType][1] else :center end end |
.calculated?(colId) ⇒ Boolean
This function returns true if the values for the colId column need to be calculated.
191 192 193 |
# File 'lib/taskjuggler/reports/TableReport.rb', line 191 def TableReport::calculated?(colId) return @@propertiesById.has_key?(colId) end |
.defaultColumnTitle(id) ⇒ Object
Returns the default column title for the columns id.
155 156 157 158 159 160 161 162 163 |
# File 'lib/taskjuggler/reports/TableReport.rb', line 155 def TableReport::defaultColumnTitle(id) # Return an empty string for some special columns that don't have a fixed # title. specials = %w( chart hourly daily weekly monthly quarterly yearly) return '' if specials.include?(id) # Return the title for build-in hardwired columns. @@propertiesById.include?(id) ? @@propertiesById[id][0] : nil end |
.indent(colId, propertyType) ⇒ Object
Return if the column values should be indented based on the colId or the propertyType.
167 168 169 170 171 172 173 174 175 |
# File 'lib/taskjuggler/reports/TableReport.rb', line 167 def TableReport::indent(colId, propertyType) if @@propertiesById.has_key?(colId) return @@propertiesById[colId][1] elsif @@propertiesByType.has_key?(propertyType) return @@propertiesByType[propertyType][0] else false end end |
.scenarioSpecific?(colId) ⇒ Boolean
This functions returns true if the values for the col_id column are scenario specific.
197 198 199 200 201 202 |
# File 'lib/taskjuggler/reports/TableReport.rb', line 197 def TableReport::scenarioSpecific?(colId) if @@propertiesById.has_key?(colId) return @@propertiesById[colId][3] end return false end |
Instance Method Details
#generateIntermediateFormat ⇒ Object
105 106 107 |
# File 'lib/taskjuggler/reports/TableReport.rb', line 105 def generateIntermediateFormat super end |
#to_csv ⇒ Object
Convert the table into an Array of Arrays. It has one Array for each line. The nested Arrays have one String for each column.
150 151 152 |
# File 'lib/taskjuggler/reports/TableReport.rb', line 150 def to_csv @table.to_csv end |
#to_html ⇒ Object
Turn the TableReport into an equivalent HTML element tree.
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/taskjuggler/reports/TableReport.rb', line 110 def to_html html = [] html << XMLComment.new("Dynamic Report ID: " + "#{@report.project.reportContexts.last. dynamicReportId}") html << rt_to_html('header') html << (tableFrame = generateHtmlTableFrame) # Now generate the actual table with the data. tableFrame << generateHtmlTableRow do td = XMLElement.new('td') td << @table.to_html td end # Embedd the caption as RichText into the table footer. if a('caption') tableFrame << generateHtmlTableRow do td = XMLElement.new('td') td << (div = XMLElement.new('div', 'class' => 'tj_table_caption')) a('caption').sectionNumbers = false div << a('caption').to_html td end end # The legend. tableFrame << generateHtmlTableRow do td = XMLElement.new('td') td << @legend.to_html td end html << rt_to_html('footer') html end |