2018-12-18 11:17:52 +01:00
|
|
|
|
class Champs::RepetitionChamp < Champ
|
2018-12-20 15:04:13 +01:00
|
|
|
|
before_save :setup_dossier
|
|
|
|
|
|
2018-12-18 11:17:52 +01:00
|
|
|
|
has_many :champs, -> { ordered }, foreign_key: :parent_id, dependent: :destroy
|
|
|
|
|
|
|
|
|
|
accepts_nested_attributes_for :champs, allow_destroy: true
|
|
|
|
|
|
|
|
|
|
def rows
|
|
|
|
|
champs.group_by(&:row).values
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def search_terms
|
|
|
|
|
# The user cannot enter any information here so it doesn’t make much sense to search
|
|
|
|
|
end
|
2018-12-20 15:04:13 +01:00
|
|
|
|
|
|
|
|
|
def setup_dossier
|
|
|
|
|
champs.each do |champ|
|
|
|
|
|
champ.dossier = dossier
|
|
|
|
|
end
|
|
|
|
|
end
|
2018-12-18 11:17:52 +01:00
|
|
|
|
end
|