Skip to content

Commit

Permalink
♻️ Factorisation des inputs SVG
Browse files Browse the repository at this point in the history
  • Loading branch information
etienneCharignon committed Jan 2, 2025
1 parent c69b03b commit 7f4c29e
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 40 deletions.
2 changes: 1 addition & 1 deletion app/views/admin/questions/_input_illustration.html.arb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ f.input :illustration, as: :file,
hint: t('.illustration.hint')
if resource.illustration.attached?
f.input :supprimer_illustration, as: :boolean,
label: t('.label.supprimer_illustration'),
label: t('.supprimer_illustration'),
hint: image_tag(cdn_for(resource.illustration),
alt: resource.illustration.filename)
end
13 changes: 13 additions & 0 deletions app/views/admin/questions/_input_illustration_svg.html.arb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

f.input nom,
as: :file,
hint: hint,
label: label,
input_html: { accept: 'image/svg+xml' }

if image.attached? && f.object.errors[nom].blank?
f.input nom_suppression, as: :boolean,
label: t('.supprimer_illustration'),
hint: svg_attachment_base64(image, alt: image.filename)
end
40 changes: 17 additions & 23 deletions app/views/admin/questions_clic_dans_image/_form.html.arb
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,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 }
f.input :zone_cliquable,
as: :file,
hint: "L'un des éléments cliquables doit contenir la classe css `bonne-reponse`",
input_html: { accept: 'image/svg+xml' }
if f.object.zone_cliquable.attached? && f.object.errors[:zone_cliquable].blank?
f.input :supprimer_zone_cliquable,
as: :boolean,
label: t('.label.supprimer_zone_cliquable'),
hint: svg_attachment_base64(resource.zone_cliquable,
class: 'image-preview',
alt: resource.zone_cliquable.filename)
end
f.input :image_au_clic,
label: t('.label.image_au_clic'),
as: :file,
input_html: { accept: 'image/svg+xml' }
if f.object.image_au_clic.attached?
f.input :supprimer_image_au_clic,
as: :boolean,
hint: svg_attachment_base64(resource.image_au_clic,
class: 'image-preview',
alt: resource.image_au_clic.filename)
end
render partial: 'admin/questions/input_illustration_svg',
locals: {
f: f,
nom: :zone_cliquable,
nom_suppression: :supprimer_zone_cliquable,
image: resource.zone_cliquable,
hint: t('.format_fichier_zone_cliquable')
}
render partial: 'admin/questions/input_illustration_svg',
locals: {
f: f,
nom: :image_au_clic,
label: t('.label.image_au_clic'),
nom_suppression: :supprimer_image_au_clic,
image: resource.image_au_clic,
hint: ''
}
end

render partial: 'admin/questions/inputs_avec_transcriptions_audios',
Expand Down
22 changes: 8 additions & 14 deletions app/views/admin/questions_glisser_deposer/_form.html.arb
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,14 @@ active_admin_form_for [:admin, resource] do |f|
f.input :nom_technique
f.input :description
render partial: 'admin/questions/input_illustration', locals: { f: 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`',
input_html: { accept: 'image/svg+xml' }

if f.object.zone_depot.attached? && f.object.errors[:zone_depot].blank?
f.input :supprimer_zone_depot,
as: :boolean,
label: t('.label.supprimer_zone_depot'),
hint: svg_attachment_base64(resource.zone_depot,
class: 'image-preview',
alt: resource.zone_depot.filename)
end
render partial: 'admin/questions/input_illustration_svg',
locals: {
f: f,
nom: :zone_depot,
nom_suppression: :supprimer_zone_depot,
image: resource.zone_depot,
hint: t('.format_fichier_zone_depot')
}
end
render partial: 'admin/questions/inputs_avec_transcriptions_audios',
locals: { f: f }
Expand Down
5 changes: 3 additions & 2 deletions config/locales/views/questions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ fr:
input_illustration:
illustration:
hint: 'La taille de l’image rendue est de 1008x566.'
label:
supprimer_illustration: Supprimer l'illustration actuelle
supprimer_illustration: Supprimer l'illustration actuelle
input_illustration_svg:
supprimer_illustration: Supprimer l'illustration actuelle
inputs_avec_transcriptions_audios:
label:
intitule: |
Expand Down
1 change: 1 addition & 0 deletions config/locales/views/questions_clic_dans_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ fr:
admin:
questions_clic_dans_image:
form:
format_fichier_zone_cliquable: L'un des éléments cliquables doit contenir la classe css `bonne-reponse`
label:
image_au_clic: Image à positionner au clic
1 change: 1 addition & 0 deletions config/locales/views/questions_glisser_deposer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ fr:
reponses: Réponses
label_illustration: 'Illustration (la taille rendue est de 100x60)'
hint: La taille de l'image rendue est de 100x60
format_fichier_zone_depot: Les éléments doivent contenir la classe css `zone-depot` et la classe css `zone-depot--reponse.nom_technique`

0 comments on commit 7f4c29e

Please sign in to comment.