Class: DecisionsOverview

Inherits:
BaseDocument show all
Includes:
DecisionGrouping, HtmlSafe, PlanningDates
Defined in:
lib/almirah/doc_types/decisions_overview.rb

Constant Summary

Constants included from HtmlSafe

HtmlSafe::ALLOWED_URL_SCHEMES

Instance Attribute Summary collapse

Attributes inherited from BaseDocument

#dom, #headings, #id, #output_rel_path, #title

Instance Method Summary collapse

Methods included from PlanningDates

#recent_fridays

Methods included from DecisionGrouping

#grouped_work_items

Methods included from HtmlSafe

#escape_attr, #escape_text, #safe_url

Methods inherited from BaseDocument

#critical_chain_link, #decisions_link, #home_link, #index_link, #rel_to, #save_html_to_file

Constructor Details

#initialize(project) ⇒ DecisionsOverview

Returns a new instance of DecisionsOverview.



20
21
22
23
24
25
# File 'lib/almirah/doc_types/decisions_overview.rb', line 20

def initialize(project)
  super()
  @project = project
  @title = 'Decision Records Overview'
  @id = 'overview'
end

Instance Attribute Details

#projectObject

Returns the value of attribute project.



18
19
20
# File 'lib/almirah/doc_types/decisions_overview.rb', line 18

def project
  @project
end

Instance Method Details

#needs_chartjs?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/almirah/doc_types/decisions_overview.rb', line 27

def needs_chartjs?
  true
end

#to_consoleObject



31
32
33
# File 'lib/almirah/doc_types/decisions_overview.rb', line 31

def to_console
  puts "\e[36mDecisions Overview: #{@id}\e[0m"
end

#to_html(output_file_path) ⇒ Object



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
75
76
77
78
79
80
81
82
83
84
# File 'lib/almirah/doc_types/decisions_overview.rb', line 35

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 render_workitem_gantt

  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 "\t\t<th title=\"Cross-record full-kit readiness\">Kit</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 += kit_overview_cell(doc)
    s += "</tr>\n"
    html_rows.append s
  end
  html_rows.append "</table>\n"

  save_html_to_file(html_rows, nil, output_file_path)
end