Basic feature implemented, very basic poc

This commit is contained in:
David Schärer 2024-07-16 20:22:59 +02:00
parent 216089a3e7
commit 48c0067076
118 changed files with 2113 additions and 20 deletions

5
app/models/check.rb Normal file
View file

@ -0,0 +1,5 @@
class Check < ApplicationRecord
enum :level, %i[A AA AAA]
validates :position, :name, :success_criterion, :level, presence: true
validates :position, numericality: { less_than: 200 }
end

6
app/models/checklist.rb Normal file
View file

@ -0,0 +1,6 @@
class Checklist < ApplicationRecord
has_many :checklist_entries, -> { order(position: :asc) }, dependent: :destroy, inverse_of: :checklist
has_many :checks, through: :checklist_entries
accepts_nested_attributes_for :checklist_entries
end

View file

@ -0,0 +1,4 @@
class ChecklistEntry < ApplicationRecord
belongs_to :checklist
belongs_to :check
end

6
app/models/element.rb Normal file
View file

@ -0,0 +1,6 @@
class Element < ApplicationRecord
attr_accessor :checklist_id
belongs_to :report
has_many :success_criteria, dependent: :destroy
end

3
app/models/report.rb Normal file
View file

@ -0,0 +1,3 @@
class Report < ApplicationRecord
has_many :elements, dependent: :destroy
end

View file

@ -0,0 +1,4 @@
class SuccessCriterion < ApplicationRecord
enum :result, %i[passed failed not_applicable]
belongs_to :element
end