Add annuaire_education champ
This commit is contained in:
parent
5c9f2e8783
commit
54f2084aef
8 changed files with 55 additions and 1 deletions
|
@ -1256,6 +1256,11 @@ enum TypeDeChamp {
|
||||||
"""
|
"""
|
||||||
address
|
address
|
||||||
|
|
||||||
|
"""
|
||||||
|
Annuaire de l’éducation
|
||||||
|
"""
|
||||||
|
annuaire_education
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Carte
|
Carte
|
||||||
"""
|
"""
|
||||||
|
|
35
app/models/champs/annuaire_education_champ.rb
Normal file
35
app/models/champs/annuaire_education_champ.rb
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
# == Schema Information
|
||||||
|
#
|
||||||
|
# Table name: champs
|
||||||
|
#
|
||||||
|
# id :integer not null, primary key
|
||||||
|
# data :jsonb
|
||||||
|
# private :boolean default(FALSE), not null
|
||||||
|
# row :integer
|
||||||
|
# type :string
|
||||||
|
# value :string
|
||||||
|
# created_at :datetime
|
||||||
|
# updated_at :datetime
|
||||||
|
# dossier_id :integer
|
||||||
|
# etablissement_id :integer
|
||||||
|
# parent_id :bigint
|
||||||
|
# type_de_champ_id :integer
|
||||||
|
#
|
||||||
|
class Champs::AnnuaireEducationChamp < Champs::TextChamp
|
||||||
|
before_save :cleanup_if_empty
|
||||||
|
after_update_commit :fetch_data
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def cleanup_if_empty
|
||||||
|
if value_changed?
|
||||||
|
self.data = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def fetch_data
|
||||||
|
if value.present? && data.nil?
|
||||||
|
AnnuaireEducationUpdateJob.perform_later(self)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -47,7 +47,8 @@ class TypeDeChamp < ApplicationRecord
|
||||||
carte: 'carte',
|
carte: 'carte',
|
||||||
repetition: 'repetition',
|
repetition: 'repetition',
|
||||||
titre_identite: 'titre_identite',
|
titre_identite: 'titre_identite',
|
||||||
iban: 'iban'
|
iban: 'iban',
|
||||||
|
annuaire_education: 'annuaire_education'
|
||||||
}
|
}
|
||||||
|
|
||||||
belongs_to :revision, class_name: 'ProcedureRevision', optional: true
|
belongs_to :revision, class_name: 'ProcedureRevision', optional: true
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
class TypesDeChamp::AnnuaireEducationTypeDeChamp < TypesDeChamp::TextTypeDeChamp
|
||||||
|
end
|
|
@ -35,3 +35,4 @@ fr:
|
||||||
repetition: 'Bloc répétable'
|
repetition: 'Bloc répétable'
|
||||||
titre_identite: 'Titre identité'
|
titre_identite: 'Titre identité'
|
||||||
iban: 'Iban'
|
iban: 'Iban'
|
||||||
|
annuaire_education: 'Annuaire de l’éducation'
|
||||||
|
|
|
@ -159,6 +159,10 @@ FactoryBot.define do
|
||||||
type_de_champ { association :type_de_champ_iban, procedure: dossier.procedure }
|
type_de_champ { association :type_de_champ_iban, procedure: dossier.procedure }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
factory :champ_annuaire_education, class: 'Champs::AnnuaireEducationChamp' do
|
||||||
|
type_de_champ { association :type_de_champ_annuaire_education, procedure: dossier.procedure }
|
||||||
|
end
|
||||||
|
|
||||||
factory :champ_siret, class: 'Champs::SiretChamp' do
|
factory :champ_siret, class: 'Champs::SiretChamp' do
|
||||||
association :type_de_champ, factory: [:type_de_champ_siret]
|
association :type_de_champ, factory: [:type_de_champ_siret]
|
||||||
association :etablissement, factory: [:etablissement]
|
association :etablissement, factory: [:etablissement]
|
||||||
|
|
|
@ -142,6 +142,9 @@ FactoryBot.define do
|
||||||
factory :type_de_champ_iban do
|
factory :type_de_champ_iban do
|
||||||
type_champ { TypeDeChamp.type_champs.fetch(:iban) }
|
type_champ { TypeDeChamp.type_champs.fetch(:iban) }
|
||||||
end
|
end
|
||||||
|
factory :type_de_champ_annuaire_education do
|
||||||
|
type_champ { TypeDeChamp.type_champs.fetch(:annuaire_education) }
|
||||||
|
end
|
||||||
factory :type_de_champ_carte do
|
factory :type_de_champ_carte do
|
||||||
type_champ { TypeDeChamp.type_champs.fetch(:carte) }
|
type_champ { TypeDeChamp.type_champs.fetch(:carte) }
|
||||||
end
|
end
|
||||||
|
|
|
@ -75,6 +75,7 @@ describe ProcedureExportService do
|
||||||
"carte",
|
"carte",
|
||||||
"titre_identite",
|
"titre_identite",
|
||||||
"iban",
|
"iban",
|
||||||
|
"annuaire_education",
|
||||||
"text"
|
"text"
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
@ -160,6 +161,7 @@ describe ProcedureExportService do
|
||||||
"carte",
|
"carte",
|
||||||
"titre_identite",
|
"titre_identite",
|
||||||
"iban",
|
"iban",
|
||||||
|
"annuaire_education",
|
||||||
"text"
|
"text"
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
@ -241,6 +243,7 @@ describe ProcedureExportService do
|
||||||
"carte",
|
"carte",
|
||||||
"titre_identite",
|
"titre_identite",
|
||||||
"iban",
|
"iban",
|
||||||
|
"annuaire_education",
|
||||||
"text"
|
"text"
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue