edit comment and pdf export
Some checks failed
/ Run tests (push) Successful in 2m6s
/ Run system tests (push) Failing after 2m29s
/ Build, push and deploy image (push) Successful in 1m46s

This commit is contained in:
david 2024-11-23 21:11:01 +01:00
parent 110d75f2b7
commit c36230b8ba
10 changed files with 90 additions and 19 deletions

View file

@ -3,7 +3,20 @@
class Report < ApplicationRecord
has_many :pages, -> { order(:position) }, dependent: :destroy
has_many :elements, through: :pages, dependent: :destroy
has_many :success_criteria, through: :elements, dependent: :destroy
has_rich_text :comment
validates :name, presence: true
def export
export_success_criteria = success_criteria.failed
export_elements = export_success_criteria.group_by(&:element)
export_pages = export_elements.group_by { |k, v| k }
{
pages: export_pages,
elements: export_elements,
success_criteria: export_success_criteria
}
end
end