Skip to content

Commit

Permalink
🐛 Fix la mise en page des formulaires
Browse files Browse the repository at this point in the history
  • Loading branch information
marouria committed Oct 14, 2024
1 parent fcc1d5e commit b29fba7
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 57 deletions.
18 changes: 13 additions & 5 deletions app/admin/questions_sous_consigne.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,25 @@
f.input :libelle
f.input :nom_technique
render partial: 'admin/questions/input_illustration', locals: { f: f }
end
f.object.transcriptions.build(categorie: :intitule) if f.object.transcription_intitule.nil?

f.has_many :transcriptions, allow_destroy: false, new_record: false,
heading: false do |t|
t.input :id, as: :hidden
t.input :ecrit, label: t('.label.intitule'), input_html: { rows: 4 }
t.input :audio, as: :file, label: t('.label.intitule_audio'),
input_html: { accept: Transcription::AUDIOS_CONTENT_TYPES.join(',') }
t.input :categorie, as: :hidden, input_html: { value: :intitule }
end

f.object.transcriptions.build(categorie: :intitule) if f.object.transcription_intitule.nil?

render partial: 'admin/transcriptions/input_ecrit_audio',
locals: { f: f, transcription_categorie: :intitule }

f.inputs do
if f.object.transcription_intitule&.audio&.attached?
f.input :supprimer_audio_intitule, as: :boolean,
hint: tag_audio(f.object.transcription_intitule)
end
end

f.actions do
f.action :submit
annulation_formulaire(f)
Expand Down
4 changes: 4 additions & 0 deletions app/assets/stylesheets/admin/pages/_question.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ form.question_glisser_deposer {
.inline-hints img {
width: 300px;
}
.inline-hints {
margin-left: 0;
}
}
form.question_saisie .choix {
.has_one ~ .has_many_add {
Expand All @@ -29,6 +32,7 @@ form.question_saisie .choix {
}
.show .image-preview {
width: 100px;
max-height: 100px;
}
.show.admin_questions_clic_dans_image {
svg {
Expand Down
21 changes: 10 additions & 11 deletions app/views/admin/question_qcms/_form.html.arb
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,18 @@ active_admin_form_for [:admin, resource] do |f|
render partial: 'admin/questions/input_illustration', locals: { f: f }
end

f.inputs do
render partial: 'admin/questions/inputs_avec_transcriptions_audios',
locals: { f: f }
render partial: 'admin/questions/inputs_avec_transcriptions_audios',
locals: { f: f }

f.has_many :choix, allow_destroy: ->(choix) { can? :destroy, choix } do |c|
c.input :id, as: :hidden
c.input :intitule, label: t('.label.intitule_reponse')
c.input :audio, as: :file, label: t('.label.intitule_reponse_audio'),
input_html: { accept: Transcription::AUDIOS_CONTENT_TYPES.join(',') }
c.input :nom_technique
c.input :type_choix
end
f.has_many :choix, allow_destroy: ->(choix) { can? :destroy, choix } do |c|
c.input :id, as: :hidden
c.input :intitule, label: t('.label.intitule_reponse')
c.input :audio, as: :file, label: t('.label.intitule_reponse_audio'),
input_html: { accept: Transcription::AUDIOS_CONTENT_TYPES.join(',') }
c.input :nom_technique
c.input :type_choix
end

f.actions do
f.action :submit
annulation_formulaire(f)
Expand Down
18 changes: 11 additions & 7 deletions app/views/admin/questions/_inputs_avec_transcriptions_audios.arb
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ else
end
end
if f.object.transcription_intitule&.audio&.attached?
f.input :supprimer_audio_intitule, as: :boolean,
label: t('.label.supprimer_audio_intitule'),
hint: tag_audio(f.object.transcription_intitule)
f.inputs do
f.input :supprimer_audio_intitule, as: :boolean,
label: t('.label.supprimer_audio_intitule'),
hint: tag_audio(f.object.transcription_intitule)
end
end
if f.object.transcription_modalite_reponse.nil?
f.object.transcriptions.build(categorie: :modalite_reponse)
Expand All @@ -36,9 +38,11 @@ else
end
end
if f.object.transcription_modalite_reponse&.audio&.attached?
f.input :supprimer_audio_modalite_reponse,
as: :boolean,
label: t('.label.supprimer_audio_modalite'),
hint: tag_audio(f.object.transcription_modalite_reponse)
f.inputs do
f.input :supprimer_audio_modalite_reponse,
as: :boolean,
label: t('.label.supprimer_audio_modalite'),
hint: tag_audio(f.object.transcription_modalite_reponse)
end
end
end
7 changes: 3 additions & 4 deletions app/views/admin/questions_clic_dans_image/_form.html.arb
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@ active_admin_form_for [:admin, resource] do |f|
end
end

f.inputs do
render partial: 'admin/questions/inputs_avec_transcriptions_audios',
locals: { f: f }
end
render partial: 'admin/questions/inputs_avec_transcriptions_audios',
locals: { f: f }

f.actions do
f.action :submit
annulation_formulaire(f)
Expand Down
34 changes: 16 additions & 18 deletions app/views/admin/questions_glisser_deposer/_form.html.arb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ active_admin_form_for [:admin, resource] do |f|
f.input :zone_depot,
as: :file,
hint: 'Les éléments doivent contenir la classe css `zone-depot` ' \
'et la classe css `zone-depot--reponse.nom_technique`',
'et la classe css `zone-depot--reponse-nom-technique`',
input_html: { accept: 'image/svg+xml' }

if f.object.zone_depot.attached? && f.object.errors[:zone_depot].blank?
Expand All @@ -20,23 +20,21 @@ active_admin_form_for [:admin, resource] do |f|
hint: svg_attachment_base64(resource.zone_depot, class: 'image-preview')
end
end
f.inputs do
render partial: 'admin/questions/inputs_avec_transcriptions_audios',
locals: { f: f }
f.has_many :reponses, allow_destroy: true, new_record: t('.ajout_reponse'),
heading: t('.reponses') do |r|
r.input :id, as: :hidden
r.input :nom_technique
r.input :position_client
r.input :type_choix, as: :hidden, input_html: { value: :bon }
label = r.object.illustration.attached? ? t('.label_illustration') : true
hint =
r.object.illustration.attached? ? image_tag(cdn_for(r.object.illustration)) : t('.hint')
r.input :illustration, as: :file,
label: label,
input_html: { accept: illustration_content_types.join(',') },
hint: hint
end
render partial: 'admin/questions/inputs_avec_transcriptions_audios',
locals: { f: f }
f.has_many :reponses, allow_destroy: true, new_record: t('.ajout_reponse'),
heading: t('.reponses') do |r|
r.input :id, as: :hidden
r.input :nom_technique
r.input :position_client
r.input :type_choix, as: :hidden, input_html: { value: :bon }
label = r.object.illustration.attached? ? t('.label_illustration') : true
hint =
r.object.illustration.attached? ? image_tag(cdn_for(r.object.illustration)) : t('.hint')
r.input :illustration, as: :file,
label: label,
input_html: { accept: illustration_content_types.join(',') },
hint: hint
end
f.actions do
f.action :submit
Expand Down
24 changes: 12 additions & 12 deletions app/views/admin/questions_saisies/_form.html.arb
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@ active_admin_form_for [:admin, resource] do |f|
f.input :nom_technique
f.input :description
render partial: 'admin/questions/input_illustration', locals: { f: f }
end

f.inputs do
render partial: 'admin/questions/inputs_avec_transcriptions_audios',
locals: { f: f }

f.input :suffix_reponse
f.input :reponse_placeholder
f.input :type_saisie
f.has_many :bonne_reponse, allow_destroy: false, new_record: t('.ajout_reponse'),
heading: false, class: 'has_one' do |c|
c.input :id, as: :hidden
c.input :intitule, label: t('.label.reponse')
c.input :nom_technique, label: t('.label.reponse_nom_technique')
c.input :type_choix, as: :hidden, input_html: { value: :bon }
end
end

render partial: 'admin/questions/inputs_avec_transcriptions_audios',
locals: { f: f }

f.has_many :bonne_reponse, allow_destroy: false, new_record: t('.ajout_reponse'),
heading: false, class: 'has_one' do |c|
c.input :id, as: :hidden
c.input :intitule, label: t('.label.reponse')
c.input :nom_technique, label: t('.label.reponse_nom_technique')
c.input :type_choix, as: :hidden, input_html: { value: :bon }
end

f.actions do
f.action :submit
annulation_formulaire(f)
Expand Down

0 comments on commit b29fba7

Please sign in to comment.