refactor(contact): form is persisted in db before pushed to HS
This commit is contained in:
parent
4bc0a04106
commit
5af32b46f4
10 changed files with 236 additions and 290 deletions
|
@ -3,23 +3,23 @@
|
|||
|
||||
- if form.require_email?
|
||||
= render Dsfr::InputComponent.new(form: f, attribute: :email, input_type: :email_field, opts: { autocomplete: 'email' }) do |c|
|
||||
- c.with_label { Helpscout::Form.human_attribute_name(form.for_admin? ? :email_pro : :email) }
|
||||
- c.with_label { ContactForm.human_attribute_name(form.for_admin? ? :email_pro : :email) }
|
||||
|
||||
%fieldset.fr-fieldset{ name: "type" }
|
||||
%fieldset.fr-fieldset{ name: "question_type" }
|
||||
%legend.fr-fieldset__legend.fr-fieldset__legend--regular
|
||||
= t('.your_question')
|
||||
= render EditableChamp::AsteriskMandatoryComponent.new
|
||||
.fr-fieldset__content
|
||||
- form.options.each do |(question, question_type, link)|
|
||||
.fr-radio-group
|
||||
= f.radio_button :type, question_type, required: true, data: {"support-target": "inputRadio" }, checked: question_type == form.type
|
||||
= f.label "type_#{question_type}", { 'aria-controls': link ? "card-#{question_type}" : nil, class: 'fr-label' } do
|
||||
= f.radio_button :question_type, question_type, required: true, data: {"support-target": "inputRadio" }, checked: question_type == form.question_type
|
||||
= f.label "question_type_#{question_type}", { 'aria-controls': link ? "card-#{question_type}" : nil, class: 'fr-label' } do
|
||||
= question
|
||||
|
||||
- if link.present?
|
||||
.fr-ml-3w{ id: "card-#{question_type}",
|
||||
class: class_names('hidden' => question_type != form.type),
|
||||
"aria-hidden": question_type != form.type,
|
||||
class: class_names('hidden' => question_type != form.question_type),
|
||||
"aria-hidden": question_type != form.question_type,
|
||||
data: { "support-target": "content" } }
|
||||
= render Dsfr::CalloutComponent.new(title: t('.our_answer')) do |c|
|
||||
- c.with_html_body do
|
||||
|
@ -43,13 +43,15 @@
|
|||
%span.fr-hint-text
|
||||
= t('.notice_upload_group')
|
||||
|
||||
%p.notice.hidden{ data: { 'contact-type-only': Helpscout::Form::TYPE_AMELIORATION } }
|
||||
%p.notice.hidden{ data: { 'contact-type-only': ContactForm::TYPE_AMELIORATION } }
|
||||
= t('.notice_pj_product')
|
||||
%p.notice.hidden{ data: { 'contact-type-only': Helpscout::Form::TYPE_AUTRE } }
|
||||
%p.notice.hidden{ data: { 'contact-type-only': ContactForm::TYPE_AUTRE } }
|
||||
= t('.notice_pj_other')
|
||||
= f.file_field :piece_jointe, class: 'fr-upload', accept: '.jpg, .jpeg, .png, .pdf'
|
||||
|
||||
= f.hidden_field :tags
|
||||
- f.object.tags.each_with_index do |tag, index|
|
||||
= f.hidden_field :tags, name: f.field_name(:tags, multiple: true), id: f.field_id(:tag, index), value: tag
|
||||
|
||||
= f.hidden_field :for_admin
|
||||
|
||||
= invisible_captcha
|
||||
|
|
|
@ -9,69 +9,4 @@
|
|||
|
||||
.fr-highlight= t('.intro_html')
|
||||
|
||||
.description
|
||||
.recommandations
|
||||
= t('.intro_html')
|
||||
%p.mandatory-explanation= t('asterisk_html', scope: [:utils])
|
||||
|
||||
- if !user_signed_in?
|
||||
.fr-input-group
|
||||
= label_tag :email, class: 'fr-label' do
|
||||
Email
|
||||
= render EditableChamp::AsteriskMandatoryComponent.new
|
||||
%span.fr-hint-text
|
||||
= t('.notice_email')
|
||||
= email_field_tag :email, params[:email], required: true, autocomplete: 'email', class: 'fr-input'
|
||||
|
||||
%fieldset.fr-fieldset{ name: "type" }
|
||||
%legend.fr-fieldset__legend
|
||||
= t('.your_question')
|
||||
= render EditableChamp::AsteriskMandatoryComponent.new
|
||||
.fr-fieldset__content
|
||||
- @options.each do |(question, question_type, link)|
|
||||
.fr-radio-group
|
||||
= radio_button_tag :type, question_type, false, required: true, data: {"support-target": "inputRadio" }
|
||||
= label_tag "type_#{question_type}", { 'aria-controls': link ? "card-#{question_type}" : nil, class: 'fr-label' } do
|
||||
= question
|
||||
|
||||
- if link.present?
|
||||
.fr-ml-3w.hidden{ id: "card-#{question_type}", "aria-hidden": true , data: { "support-target": "content" } }
|
||||
= render Dsfr::CalloutComponent.new(title: t('.our_answer')) do |c|
|
||||
- c.with_html_body do
|
||||
-# i18n-tasks-use t("support.index.#{question_type}.answer_html")
|
||||
= t('answer_html', scope: [:support, :index, question_type], base_url: Current.application_base_url, "link_#{question_type}": link)
|
||||
|
||||
.fr-input-group
|
||||
= label_tag :dossier_id, t('file_number', scope: [:utils]), class: 'fr-label'
|
||||
= text_field_tag :dossier_id, @dossier_id, class: 'fr-input'
|
||||
|
||||
.fr-input-group
|
||||
= label_tag :subject, class: 'fr-label' do
|
||||
= t('subject', scope: [:utils])
|
||||
= render EditableChamp::AsteriskMandatoryComponent.new
|
||||
= text_field_tag :subject, params[:subject], required: true, class: 'fr-input'
|
||||
|
||||
.fr-input-group
|
||||
= label_tag :text, class: 'fr-label' do
|
||||
= t('message', scope: [:utils])
|
||||
= render EditableChamp::AsteriskMandatoryComponent.new
|
||||
= text_area_tag :text, params[:text], rows: 6, required: true, class: 'fr-input'
|
||||
|
||||
.fr-upload-group
|
||||
= label_tag :piece_jointe, class: 'fr-label' do
|
||||
= t('pj', scope: [:utils])
|
||||
%span.fr-hint-text
|
||||
= t('.notice_upload_group')
|
||||
|
||||
%p.notice.hidden{ data: { 'contact-type-only': Helpscout::FormAdapter::TYPE_AMELIORATION } }
|
||||
= t('.notice_pj_product')
|
||||
%p.notice.hidden{ data: { 'contact-type-only': Helpscout::FormAdapter::TYPE_AUTRE } }
|
||||
= t('.notice_pj_other')
|
||||
= file_field_tag :piece_jointe, class: 'fr-upload', accept: '.jpg, .jpeg, .png, .pdf'
|
||||
|
||||
= hidden_field_tag :tags, @tags&.join(',')
|
||||
|
||||
= invisible_captcha
|
||||
|
||||
.send-wrapper.fr-my-3w
|
||||
= button_tag t('send_mail', scope: [:utils]), type: :submit, class: 'fr-btn send'
|
||||
= render partial: "form", object: @form
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue