diff --git a/app/assets/stylesheets/avis.scss b/app/assets/stylesheets/avis.scss index 95374b85f..d53b7e3d5 100644 --- a/app/assets/stylesheets/avis.scss +++ b/app/assets/stylesheets/avis.scss @@ -65,13 +65,6 @@ .lock { margin-right: $default-spacer; } - - .confidentiel-explanation { - font-size: 14px; - color: $dark-grey; - margin-top: - $default-padding; - margin-bottom: 2 * $default-padding; - } } .list-avis { diff --git a/app/controllers/concerns/create_avis_concern.rb b/app/controllers/concerns/create_avis_concern.rb index 44d7249ef..adc7ef4b9 100644 --- a/app/controllers/concerns/create_avis_concern.rb +++ b/app/controllers/concerns/create_avis_concern.rb @@ -33,7 +33,8 @@ module CreateAvisConcern claimant: instructeur_or_expert, dossier: dossier, confidentiel: confidentiel, - experts_procedure: experts_procedure + experts_procedure: experts_procedure, + question_label: create_avis_params[:question_label] } end end @@ -71,6 +72,6 @@ module CreateAvisConcern end def create_avis_params - params.require(:avis).permit(:introduction_file, :introduction, :confidentiel, :invite_linked_dossiers, :emails) + params.require(:avis).permit(:introduction_file, :introduction, :confidentiel, :invite_linked_dossiers, :emails, :question_label) end end diff --git a/app/controllers/experts/avis_controller.rb b/app/controllers/experts/avis_controller.rb index 2801c3343..13bc62d3f 100644 --- a/app/controllers/experts/avis_controller.rb +++ b/app/controllers/experts/avis_controller.rb @@ -179,7 +179,7 @@ module Experts end def avis_params - params.require(:avis).permit(:answer, :piece_justificative_file) + params.require(:avis).permit(:answer, :piece_justificative_file, :question_answer) end def commentaire_params diff --git a/app/javascript/entrypoints/main.css b/app/javascript/entrypoints/main.css index aa42a6ab0..2e4478c31 100644 --- a/app/javascript/entrypoints/main.css +++ b/app/javascript/entrypoints/main.css @@ -9,6 +9,7 @@ /* Verify README of each component to insert them in the expected order. */ @import '@gouvfr/dsfr/dist/component/alert/alert.css'; @import '@gouvfr/dsfr/dist/component/radio/radio.css'; +@import '@gouvfr/dsfr/dist/component/select/select.css'; @import '@gouvfr/dsfr/dist/component/toggle/toggle.css'; @import '@gouvfr/dsfr/dist/component/badge/badge.css'; @import '@gouvfr/dsfr/dist/component/breadcrumb/breadcrumb.css'; diff --git a/app/models/avis.rb b/app/models/avis.rb index 724b904bc..255d5fbe0 100644 --- a/app/models/avis.rb +++ b/app/models/avis.rb @@ -8,6 +8,8 @@ # confidentiel :boolean default(FALSE), not null # email :string # introduction :text +# question_answer :boolean +# question_label :string # reminded_at :datetime # revoked_at :datetime # created_at :datetime not null diff --git a/app/views/experts/avis/instruction.html.haml b/app/views/experts/avis/instruction.html.haml index 0772abd9d..e41869024 100644 --- a/app/views/experts/avis/instruction.html.haml +++ b/app/views/experts/avis/instruction.html.haml @@ -15,8 +15,27 @@ = render Attachment::ShowComponent.new(attachment: @avis.introduction_file.attachment) %br/ = render Attachment::DeleteFormComponent.new - = form_for @avis, url: expert_avis_path(@avis.procedure, @avis), html: { class: 'form', data: { controller: 'persisted-form', persisted_form_key_value: dom_id(@avis) }, multipart: true } do |f| - = f.text_area :answer, rows: 3, placeholder: 'Votre avis', required: true + = form_for @avis, url: expert_avis_path(@avis.procedure, @avis), html: { data: { controller: 'persisted-form', persisted_form_key_value: dom_id(@avis) }, multipart: true } do |f| + + - if @avis.question_label + .fr-form-group + %fieldset.fr-fieldset.fr-fieldset--inline + %legend#radio-inline-legend.fr-fieldset__legend.fr-text--regular + = @avis.question_label + .fr-fieldset__content + .fr-radio-group + = f.radio_button :question_answer, true + = f.label :question_answer, 'oui', value: true, class: 'fr-label' + + .fr-radio-group + = f.radio_button :question_answer, false + = f.label :question_answer, 'non', value: false, class: 'fr-label' + + .fr-select-group + = f.text_area :answer, rows: 3, class: 'fr-input', placeholder: 'Votre avis', required: true + + + = render Attachment::EditComponent.new(attached_file: @avis.piece_justificative_file, view_as: :download) .flex.justify-between.align-baseline diff --git a/app/views/experts/avis/shared/avis/_form.html.haml b/app/views/experts/avis/shared/avis/_form.html.haml index e8685241c..1bd3633dd 100644 --- a/app/views/experts/avis/shared/avis/_form.html.haml +++ b/app/views/experts/avis/shared/avis/_form.html.haml @@ -2,9 +2,9 @@ %h1.tab-title Inviter des personnes à donner leur avis %p.avis-notice Les invités pourront consulter le dossier, donner un avis et contribuer au fil de messagerie. Ils ne pourront pas modifier le dossier. - = form_for avis, url: url, html: { class: 'form' } do |f| + = form_for avis, url: url do |f| = f.email_field :emails, placeholder: 'Adresses email, séparées par des virgules', required: true, multiple: true, data: { controller: 'format', format: 'list' } - = f.text_area :introduction, rows: 3, value: avis.introduction || 'Bonjour, merci de me donner votre avis sur ce dossier.', required: true + = f.text_area :introduction, rows: 3, class: 'fr-input', value: avis.introduction || 'Bonjour, merci de me donner votre avis sur ce dossier.', required: true %p.tab-title Ajouter une pièce jointe .form-group = render Attachment::EditComponent.new(attached_file: avis.introduction_file) @@ -22,8 +22,8 @@ - else .confidentiel-wrapper - = f.label :confidentiel, 'Cet avis sera ' - = f.select :confidentiel, [['partagé avec les autres experts', false], ['confidentiel', true]], {}, onchange: "javascript:DS.toggleCondidentielExplanation(event);" + = f.label :confidentiel, 'Cet avis sera ', class: 'fr-label' + = f.select :confidentiel, [['partagé avec les autres experts', false], ['confidentiel', true]], {}, onchange: "javascript:DS.toggleCondidentielExplanation(event);", class: 'fr-select' .confidentiel-explanation.hidden Il ne sera pas affiché aux autres experts consultés, mais sera visible par les instructeurs. diff --git a/app/views/experts/shared/avis/_form.html.haml b/app/views/experts/shared/avis/_form.html.haml index f0bec0090..b8ad8197e 100644 --- a/app/views/experts/shared/avis/_form.html.haml +++ b/app/views/experts/shared/avis/_form.html.haml @@ -3,15 +3,17 @@ %h1.tab-title Inviter des personnes à donner leur avis %p.avis-notice Les invités pourront consulter le dossier, donner un avis et contribuer au fil de messagerie. Ils ne pourront pas modifier le dossier. = render Attachment::DeleteFormComponent.new - = form_for avis, url: url, html: { class: 'form', multipart: true, data: { controller: 'persisted-form', persisted_form_key_value: dom_id(@avis.dossier, :avis_by_expert) } } do |f| + = form_for avis, url: url, html: { multipart: true, data: { controller: 'persisted-form', persisted_form_key_value: dom_id(@avis.dossier, :avis_by_expert) } } do |f| = hidden_field_tag 'avis[emails]', nil - = react_component("ComboMultiple", - options: [], selected: [], disabled: [], - group: '.ask-avis', - name: 'emails', - label: 'Emails', - acceptNewValues: true) - = f.text_area :introduction, rows: 3, value: avis.introduction || 'Bonjour, merci de me donner votre avis sur ce dossier.', required: true + .fr-input-group + = react_component("ComboMultiple", + options: [], selected: [], disabled: [], + group: '.ask-avis', + name: 'emails', + label: 'Emails', + acceptNewValues: true) + .fr-input-group + = f.text_area :introduction, rows: 3, class: 'fr-input', value: avis.introduction || 'Bonjour, merci de me donner votre avis sur ce dossier.', required: true %p.tab-title Ajouter une pièce jointe .form-group = render Attachment::EditComponent.new(attached_file: avis.introduction_file) @@ -29,9 +31,9 @@ - else .confidentiel-wrapper - = f.label :confidentiel, 'Cet avis sera ' - = f.select :confidentiel, [['partagé avec les autres experts', false], ['confidentiel', true]], {}, onchange: "javascript:DS.toggleCondidentielExplanation(event);" + = f.label :confidentiel, 'Cet avis sera ', class: 'fr-label' + = f.select :confidentiel, [['partagé avec les autres experts', false], ['confidentiel', true]], {}, onchange: "javascript:DS.toggleCondidentielExplanation(event);", class: 'fr-input' .confidentiel-explanation.hidden Il ne sera pas affiché aux autres experts consultés, mais sera visible par les instructeurs. - = f.submit 'Demander un avis', class: 'button primary send' + = f.submit 'Demander un avis', class: 'fr-btn fr-mt-2w' diff --git a/app/views/experts/shared/avis/_list.html.haml b/app/views/experts/shared/avis/_list.html.haml index a2436d926..56c4ae720 100644 --- a/app/views/experts/shared/avis/_list.html.haml +++ b/app/views/experts/shared/avis/_list.html.haml @@ -35,4 +35,6 @@ - if avis.piece_justificative_file.attached? = render Attachment::ShowComponent.new(attachment: avis.piece_justificative_file.attachment) .answer-body + - if avis.question_answer + %p= t("question_answer.#{avis.question_answer}", scope: 'helpers.label') = render SimpleFormatComponent.new(avis.answer, allow_a: false) diff --git a/app/views/instructeurs/shared/avis/_form.html.haml b/app/views/instructeurs/shared/avis/_form.html.haml index 99f99c666..670252ab0 100644 --- a/app/views/instructeurs/shared/avis/_form.html.haml +++ b/app/views/instructeurs/shared/avis/_form.html.haml @@ -9,17 +9,25 @@ Entrez les adresses email des experts à qui vous souhaitez demander un avis = render Attachment::DeleteFormComponent.new - = form_for avis, url: url, html: { class: 'form', multipart: true, data: { controller: 'persisted-form', persisted_form_key_value: dom_id(@dossier, :avis_by_instructeur) } } do |f| + = form_for avis, url: url, html: { multipart: true, data: { controller: 'persisted-form', persisted_form_key_value: dom_id(@dossier, :avis_by_instructeur) } } do |f| = hidden_field_tag 'avis[emails]', nil - = react_component("ComboMultiple", - options: @dossier.procedure.experts_require_administrateur_invitation ? @experts_emails : [], - selected: [], disabled: [], - label: 'Emails', - group: '.ask-avis', - name: 'emails', - describedby: 'avis-emails-description', - acceptNewValues: !@dossier.procedure.experts_require_administrateur_invitation) - = f.text_area :introduction, rows: 3, value: avis.introduction || 'Bonjour, merci de me donner votre avis sur ce dossier.', required: true + .fr-input-group + = react_component("ComboMultiple", + options: @dossier.procedure.experts_require_administrateur_invitation ? @experts_emails : [], + selected: [], disabled: [], + label: 'Emails', + group: '.ask-avis', + name: 'emails', + describedby: 'avis-emails-description', + acceptNewValues: !@dossier.procedure.experts_require_administrateur_invitation) + + .fr-input-group + = f.label :introduction, t('helpers.label.introduction'), class: 'fr-label' + = f.text_area :introduction, rows: 3, class: 'fr-input', value: avis.introduction || 'Bonjour, merci de me donner votre avis sur ce dossier.', required: true + + .fr-input-group + = f.label :question_label, t('helpers.label.question_label'), class: 'fr-label' + = f.text_area :question_label, label: "question", class: 'fr-input' %p.tab-title Ajouter une pièce jointe .form-group = render Attachment::EditComponent.new(attached_file: avis.introduction_file) @@ -37,9 +45,10 @@ - else .confidentiel-wrapper - = f.label :confidentiel, 'Cet avis sera ' - = f.select :confidentiel, [['partagé avec les autres experts', false], ['confidentiel', true]], {}, onchange: "javascript:DS.toggleCondidentielExplanation(event);" + = f.label :confidentiel, 'Cet avis sera ', class: 'fr-label' + = f.select :confidentiel, [['partagé avec les autres experts', false], ['confidentiel', true]], {}, onchange: "javascript:DS.toggleCondidentielExplanation(event);", class: 'fr-select' .confidentiel-explanation.hidden - Il ne sera pas affiché aux autres experts consultés, mais sera visible par les instructeurs. + %small + Il ne sera pas affiché aux autres experts consultés, mais sera visible par les instructeurs. - = f.submit 'Demander un avis', class: 'fr-btn' + = f.submit 'Demander un avis', class: 'fr-btn fr-mt-2w' diff --git a/app/views/instructeurs/shared/avis/_list.html.haml b/app/views/instructeurs/shared/avis/_list.html.haml index 9d66b8d2d..91577ddbf 100644 --- a/app/views/instructeurs/shared/avis/_list.html.haml +++ b/app/views/instructeurs/shared/avis/_list.html.haml @@ -17,6 +17,8 @@ %span.date.fr-text--xs.fr-text-mention--grey{ class: highlight_if_unseen_class(avis_seen_at, avis.created_at) } = t('demande_envoyee_le', scope: 'views.shared.avis', date: l(avis.created_at, format: '%d/%m/%y à %H:%M')) %p= avis.introduction + - if avis.question_label + %p= avis.question_label .answer.flex.align-start %span.icon.bubble.avis-icon @@ -51,4 +53,7 @@ - if avis.piece_justificative_file.attached? = render Attachment::ShowComponent.new(attachment: avis.piece_justificative_file.attachment) .answer-body + - if avis.question_answer + %p= t("question_answer.#{avis.question_answer}", scope: 'helpers.label') + = render SimpleFormatComponent.new(avis.answer, allow_a: false) diff --git a/config/locales/models/avis/en.yml b/config/locales/models/avis/en.yml new file mode 100644 index 000000000..a8f646f9a --- /dev/null +++ b/config/locales/models/avis/en.yml @@ -0,0 +1,26 @@ +en: + activerecord: + models: + avis: 'opinion' + attributes: + avis: + answer: "Answer" + claimant: Claimant + confidentiel: Confidential + helpers: + label: + invite_linked_dossiers: + one: Invite also the expert on this linked file n° %{ids} + other: Invite also the expert on theses linked files n° %{ids} + revoke: Revoke opinion request + remind: Remind the expert + question_label: Ask a question to the expert + introduction: Introduction message + question_answer: + true: 'yes' + false: 'no' + hint: + confidentiel: "This advice is not displayed to the others consulted experts" + confirmation: + revoke: "Would you like to revoke the opinion request to %{email} ?" + remind: "Would you like to remind %{email} ?" diff --git a/config/locales/models/avis/fr.yml b/config/locales/models/avis/fr.yml index 1428849ce..9dd09a4c9 100644 --- a/config/locales/models/avis/fr.yml +++ b/config/locales/models/avis/fr.yml @@ -14,6 +14,11 @@ fr: other: Inviter aussi l’expert sur les dossiers liés n° %{ids} revoke: Révoquer la demande d’avis remind: Relancer l’expert + question_label: Posez une question à l'expert + introduction: Message d'introduction + question_answer: + true: oui + false: non hint: confidentiel: "Cet avis n’est pas affiché avec les autres experts consultés" confirmation: diff --git a/db/migrate/20230303094613_add_question_columns_to_avis.rb b/db/migrate/20230303094613_add_question_columns_to_avis.rb new file mode 100644 index 000000000..310e66cfc --- /dev/null +++ b/db/migrate/20230303094613_add_question_columns_to_avis.rb @@ -0,0 +1,6 @@ +class AddQuestionColumnsToAvis < ActiveRecord::Migration[6.1] + def change + add_column :avis, :question_label, :string + add_column :avis, :question_answer, :boolean + end +end diff --git a/db/schema.rb b/db/schema.rb index c8cb05fb3..f01212cd2 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2023_02_18_094119) do +ActiveRecord::Schema.define(version: 2023_03_03_094613) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" @@ -164,6 +164,8 @@ ActiveRecord::Schema.define(version: 2023_02_18_094119) do t.string "email" t.bigint "experts_procedure_id" t.text "introduction" + t.boolean "question_answer" + t.string "question_label" t.datetime "reminded_at" t.datetime "revoked_at" t.datetime "updated_at", null: false