102 lines
3.3 KiB
Ruby
102 lines
3.3 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
module PdfDocuments
|
|
class CustomerReport < Base
|
|
private
|
|
|
|
def generate
|
|
@prawn_document.repeat(:all) do
|
|
# @prawn_document.bounding_box([ 0, 790 ], width: 200) do
|
|
# logo
|
|
# end
|
|
# @prawn_document.formatted_text_box([ {
|
|
# text: "Dieses Dokument wurd am #{Time.current.strftime('%d %B %Y')} um #{Time.current.strftime('%H:%M:%S')} erstellt.",
|
|
# size: 8,
|
|
# align: :right
|
|
# } ],
|
|
# at: [ 0, -15 ],
|
|
# width: 200
|
|
# )
|
|
@prawn_document.draw_text "#{I18n.l params.report.updated_at.to_date} #{params.report.name}", at: [ 0, 770 ]
|
|
@prawn_document.font_size(8) do
|
|
@prawn_document.draw_text("Dieses Dokument wurd am #{Time.current.strftime('%d %B %Y')} um #{Time.current.strftime('%H:%M:%S')} erstellt.", at: [ 0, -15 ])
|
|
end
|
|
end
|
|
logo
|
|
move_down 20
|
|
heading1 params.report.name
|
|
rich_text params.report.comment
|
|
@pages = {}
|
|
|
|
params.report.export[:elements].each.with_index(1) do |(element, success_criteria), element_index|
|
|
new_page(required_space: 200) if element_index > 1
|
|
without_page_break do
|
|
heading2 "#{element_index} #{element.title}"
|
|
bold("#{element.page.path}")
|
|
safe_display(element.screenshot) { image(_1.variant(:thumbnail), height: 160) && move_down(5) }
|
|
end
|
|
rich_text element.description
|
|
move_down(10)
|
|
|
|
success_criteria.each.with_index(1) do |success_criterion, sc_index|
|
|
@pages[success_criterion.id] = @prawn_document.page_number
|
|
success_criterion_row(success_criterion, [ element_index, sc_index ])
|
|
end
|
|
end
|
|
string = "Seite <page> / <total>"
|
|
# Green page numbers 1 to 7
|
|
options = {
|
|
at: [ @prawn_document.bounds.right - 150, -10 ],
|
|
width: 150,
|
|
align: :right,
|
|
start_count_at: 1
|
|
}
|
|
@prawn_document.number_pages string, options
|
|
|
|
x = params
|
|
p = @pages
|
|
@prawn_document.outline.define do
|
|
x.report.export[:elements].each.with_index(1) do |(element, success_criteria), element_index|
|
|
section("#{element_index} #{element.title}") do
|
|
success_criteria.each.with_index(1) do |sc, sc_index|
|
|
page(title: "#{element_index}.#{sc_index} itle}", destination: p[sc.id])
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
private
|
|
|
|
def success_criterion_row(success_criterion, index)
|
|
heading3 "#{index.join(".")} #{success_criterion.title}"
|
|
safe_display(success_criterion.test_comment) do
|
|
without_page_break do
|
|
heading4 "Kommentar"
|
|
rich_text success_criterion.test_comment
|
|
end
|
|
end
|
|
safe_display(success_criterion.quick_criterion) do
|
|
without_page_break do
|
|
heading4 "Kriterium"
|
|
rich_text success_criterion.quick_criterion
|
|
end
|
|
end
|
|
safe_display(success_criterion.quick_fail) do
|
|
without_page_break do
|
|
heading4 "Fail"
|
|
rich_text success_criterion.quick_fail
|
|
end
|
|
end
|
|
safe_display(success_criterion.quick_fix) do
|
|
without_page_break do
|
|
heading4 "Fix"
|
|
rich_text success_criterion.quick_fix
|
|
end
|
|
end
|
|
heading4("Protokollnummer")
|
|
text(success_criterion.number)
|
|
move_down(10)
|
|
end
|
|
end
|
|
end
|