Class: DecisionsOverview
- Inherits:
-
BaseDocument
- Object
- BaseDocument
- DecisionsOverview
- Includes:
- PlanningDates
- Defined in:
- lib/almirah/doc_types/decisions_overview.rb
Instance Attribute Summary collapse
-
#project ⇒ Object
Returns the value of attribute project.
Attributes inherited from BaseDocument
#dom, #headings, #id, #output_rel_path, #title
Instance Method Summary collapse
-
#initialize(project) ⇒ DecisionsOverview
constructor
A new instance of DecisionsOverview.
- #needs_chartjs? ⇒ Boolean
- #to_console ⇒ Object
- #to_html(output_file_path) ⇒ Object
Methods included from PlanningDates
Methods inherited from BaseDocument
#decisions_link, #home_link, #index_link, #rel_to, #risks_link, #save_html_to_file
Constructor Details
#initialize(project) ⇒ DecisionsOverview
Returns a new instance of DecisionsOverview.
13 14 15 16 17 18 |
# File 'lib/almirah/doc_types/decisions_overview.rb', line 13 def initialize(project) super() @project = project @title = 'Decision Records Overview' @id = 'overview' end |
Instance Attribute Details
#project ⇒ Object
Returns the value of attribute project.
11 12 13 |
# File 'lib/almirah/doc_types/decisions_overview.rb', line 11 def project @project end |
Instance Method Details
#needs_chartjs? ⇒ Boolean
20 21 22 |
# File 'lib/almirah/doc_types/decisions_overview.rb', line 20 def needs_chartjs? true end |
#to_console ⇒ Object
24 25 26 |
# File 'lib/almirah/doc_types/decisions_overview.rb', line 24 def to_console puts "\e[36mDecisions Overview: #{@id}\e[0m" end |
#to_html(output_file_path) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/almirah/doc_types/decisions_overview.rb', line 28 def to_html(output_file_path) html_rows = [] html_rows.append('') html_rows.append "<h1>#{@title}</h1>\n" html_rows.append render_charts_grid html_rows.append "<table class=\"controlled decisions_overview\">\n" html_rows.append "\t<thead>\n" html_rows.append "\t\t<th>#</th>\n" html_rows.append "\t\t<th>Type</th>\n" html_rows.append "\t\t<th>Status</th>\n" html_rows.append "\t\t<th>Title</th>\n" html_rows.append "\t\t<th>Start Date</th>\n" html_rows.append "\t\t<th>Target Date</th>\n" html_rows.append "\t\t<th title=\"Target Release Version\">Release</th>\n" html_rows.append "\t\t<th>Owner</th>\n" html_rows.append "</thead>\n" sorted_items = @project.project_data.decisions.sort_by do |d| [d.sequence_number ? 0 : 1, d.sequence_number.to_i, d.id] end sorted_items.each do |doc| s = "\t<tr>\n" s += "\t\t<td class=\"item_id\">\n" label = doc.sequence_number || doc.id href = doc.html_rel_path ? "./#{doc.html_rel_path}" : "##{doc.id}" anchor_attrs = %(name="#{doc.id}" id="#{doc.id}" href="#{href}" title="Decision Record ID") s += "\t\t\t<a #{anchor_attrs}>#{label}</a>" s += "\t\t</td>\n" s += "\t\t<td class=\"item_type\">#{doc.record_type}</td>\n" s += "\t\t<td class=\"item_status\">#{doc.current_status}</td>\n" title_html = doc.html_rel_path ? %(<a href="./#{doc.html_rel_path}" class="external">#{doc.title}</a>) : doc.title s += "\t\t<td class=\"item_text\" style='padding: 5px;'>#{title_html}</td>\n" start_date_html = doc.start_date ? doc.start_date.strftime('%d-%m-%Y') : '' s += "\t\t<td class=\"item_meta\">#{start_date_html}</td>\n" target_date_html = doc.target_date ? doc.target_date.strftime('%d-%m-%Y') : '' s += "\t\t<td class=\"item_meta\">#{target_date_html}</td>\n" s += "\t\t<td class=\"item_meta\">#{doc.target_release_version}</td>\n" s += "\t\t<td class=\"item_meta\">#{doc.owners.join(', ')}</td>\n" s += "</tr>\n" html_rows.append s end html_rows.append "</table>\n" save_html_to_file(html_rows, nil, output_file_path) end |