Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Fix la mise en page des formulaires #1689

Merged
merged 1 commit into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
14 changes: 12 additions & 2 deletions app/assets/stylesheets/admin/pages/_question.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ form.question_glisser_deposer {
}
}
.inline-hints img {
width: 300px;
max-width: 300px;
max-height: 200px;
}
.inline-hints {
margin-left: 0;
}
}
form.question_saisie .choix {
Expand All @@ -29,11 +33,17 @@ form.question_saisie .choix {
}
.show .image-preview {
width: 100px;
max-height: 100px;
}
.show.admin_questions_clic_dans_image {
svg {
.row-zone_cliquable svg {
stroke: $eva_bluegrey;
stroke-width: 3px;
opacity: 0.3;
}
}
#question_clic_dans_image_supprimer_image_au_clic_input {
img {
padding: 40px;
}
}
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
32 changes: 15 additions & 17 deletions app/views/admin/questions_glisser_deposer/_form.html.arb
Original file line number Diff line number Diff line change
Expand Up @@ -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