first step to add question in experts avis

This commit is contained in:
Lisa Durand 2023-03-06 11:05:14 +01:00
parent bb442ccfe3
commit a4a99a72ec
15 changed files with 115 additions and 42 deletions

View file

@ -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 {

View file

@ -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

View file

@ -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

View file

@ -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';

View file

@ -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

View file

@ -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

View file

@ -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.

View file

@ -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'

View file

@ -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)

View file

@ -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'

View file

@ -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)

View file

@ -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} ?"

View file

@ -14,6 +14,11 @@ fr:
other: Inviter aussi lexpert sur les dossiers liés n° %{ids}
revoke: Révoquer la demande davis
remind: Relancer lexpert
question_label: Posez une question à l'expert
introduction: Message d'introduction
question_answer:
true: oui
false: non
hint:
confidentiel: "Cet avis nest pas affiché avec les autres experts consultés"
confirmation:

View file

@ -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

View file

@ -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