diff --git a/app/components/dsfr/sidemenu_component.rb b/app/components/dsfr/sidemenu_component.rb new file mode 100644 index 000000000..d448f7852 --- /dev/null +++ b/app/components/dsfr/sidemenu_component.rb @@ -0,0 +1,15 @@ +class Dsfr::SidemenuComponent < ApplicationComponent + renders_many :links, "LinkComponent" + + class LinkComponent < ApplicationComponent + attr_reader :name, :url + def initialize(name:, url:) + @name = name + @url = url + end + end + + def active?(url) + current_page?(url) + end +end diff --git a/app/components/dsfr/sidemenu_component/sidemenu_component.en.yml b/app/components/dsfr/sidemenu_component/sidemenu_component.en.yml new file mode 100644 index 000000000..54dac542d --- /dev/null +++ b/app/components/dsfr/sidemenu_component/sidemenu_component.en.yml @@ -0,0 +1,3 @@ +--- +fr: + btn_collapse_text: In this section diff --git a/app/components/dsfr/sidemenu_component/sidemenu_component.fr.yml b/app/components/dsfr/sidemenu_component/sidemenu_component.fr.yml new file mode 100644 index 000000000..7c8926b7d --- /dev/null +++ b/app/components/dsfr/sidemenu_component/sidemenu_component.fr.yml @@ -0,0 +1,3 @@ +--- +fr: + btn_collapse_text: Dans cette rubrique diff --git a/app/components/dsfr/sidemenu_component/sidemenu_component.html.haml b/app/components/dsfr/sidemenu_component/sidemenu_component.html.haml new file mode 100644 index 000000000..2e2a70014 --- /dev/null +++ b/app/components/dsfr/sidemenu_component/sidemenu_component.html.haml @@ -0,0 +1,9 @@ + +%nav.fr-sidemenu{ "aria-labelledby" => "fr-sidemenu-title" } + .fr-sidemenu__inner + %button.fr-sidemenu__btn{ "aria-controls" => "fr-sidemenu-wrapper", "aria-expanded" => "false", hidden: "" }= t('.btn_collapse_text') + #fr-sidemenu-wrapper.fr-collapse + %ul.fr-sidemenu__list + - links.each do |link| + %li{ class: "fr-sidemenu__item fr-sidemenu__item#{active?(link.url) ? '--active' : ''}" } + = link_to link.name, link.url, class: 'fr-sidemenu__link', 'aria-current': active?(link.url) ? 'page' : nil, target: "_self" diff --git a/app/views/experts/avis/_sidemenu.html.haml b/app/views/experts/avis/_sidemenu.html.haml index ce20e1f58..65ed8293e 100644 --- a/app/views/experts/avis/_sidemenu.html.haml +++ b/app/views/experts/avis/_sidemenu.html.haml @@ -1,21 +1,2 @@ -%nav.fr-sidemenu{ "aria-labelledby" => "fr-sidemenu-title" } - .fr-sidemenu__inner - %button.fr-sidemenu__btn{ "aria-controls" => "fr-sidemenu-wrapper", "aria-expanded" => "false", hidden: "" } Dans cette rubrique - #fr-sidemenu-wrapper.fr-collapse - %ul.fr-sidemenu__list - - url = instruction_expert_avis_path(@avis.procedure, @avis) - - current_page = current_page?(url) - %li{ class: "fr-sidemenu__item fr-sidemenu__item#{current_page ? '--active' : ''}" } - %a.fr-sidemenu__link{ 'aria-current': current_page ? 'page' : nil, href: url, target: "_self" } Donner votre avis - - - if @dossier.avis_for_expert(current_expert).present? - - url = avis_list_expert_avis_path(@avis.procedure, @avis) - - current_page = current_page?(url) - %li{ class: "fr-sidemenu__item fr-sidemenu__item#{current_page ? '--active' : ''}" } - %a.fr-sidemenu__link{ 'aria-current': current_page ? 'page' : nil,href: url, target: "_self" } Voir les avis - - - if !@dossier.termine? - - url = avis_new_expert_avis_path(@avis.procedure, @avis) - - current_page = current_page?(url) - %li{ class: "fr-sidemenu__item fr-sidemenu__item#{current_page ? '--active' : ''}" } - %a.fr-sidemenu__link{ 'aria-current': current_page ? 'page' : nil,href: url, target: "_self" } Demander un nouvel avis += render(Dsfr::SidemenuComponent.new) do |component| + - component.with_links([{ name: t('helpers.sidemenu.give_avis'), url: instruction_expert_avis_path(@avis.procedure, @avis) }, { name: t('helpers.sidemenu.see_avis'), url: avis_list_expert_avis_path(@avis.procedure, @avis) }, { name: t('helpers.sidemenu.ask_new_avis'), url: avis_new_expert_avis_path(@avis.procedure, @avis) }]) diff --git a/app/views/experts/avis/avis_list.html.haml b/app/views/experts/avis/avis_list.html.haml index 0479010fe..52a1df0f1 100644 --- a/app/views/experts/avis/avis_list.html.haml +++ b/app/views/experts/avis/avis_list.html.haml @@ -9,3 +9,9 @@ .fr-col - if @dossier.avis_for_expert(current_expert).present? = render partial: 'experts/avis/shared/list', locals: { avis: @dossier.avis_for_expert(current_expert), avis_seen_at: nil } + + - else + %h2.empty-text + = t('helpers.information_text.empty_text') + %p.empty-text-details + = t('helpers.information_text.empty_text_detail') diff --git a/app/views/experts/avis/avis_new.html.haml b/app/views/experts/avis/avis_new.html.haml index d5e29041c..a42af6b72 100644 --- a/app/views/experts/avis/avis_new.html.haml +++ b/app/views/experts/avis/avis_new.html.haml @@ -9,3 +9,8 @@ .fr-col - if !@dossier.termine? = render partial: "experts/avis/shared/form", locals: { url: avis_expert_avis_path(@avis.procedure, @avis), linked_dossiers: @dossier.linked_dossiers_for(current_expert), must_be_confidentiel: @avis.confidentiel?, avis: @new_avis } + - else + %h2.empty-text + = t('helpers.information_text.no_new_avis_text') + %p.empty-text-details + = t('helpers.information_text.no_new_avis_text_detail') diff --git a/app/views/experts/avis/instruction.html.haml b/app/views/experts/avis/instruction.html.haml index 465d8441b..5d8ce4e88 100644 --- a/app/views/experts/avis/instruction.html.haml +++ b/app/views/experts/avis/instruction.html.haml @@ -7,49 +7,55 @@ .fr-col.fr-col-12.fr-col-md-3 = render partial: 'sidemenu' .fr-col - %section.give-avis - %h1.tab-title Donner votre avis - %h2.claimant - Demandeur : - %span.email.font-weight-normal= safe_claimant_email(@avis.claimant) - %span.date.font-weight-normal Demande d’avis envoyée le #{l(@avis.created_at, format: '%d/%m/%y')} - %p.introduction= @avis.introduction + - if !@dossier.termine? + %section.give-avis + %h1.tab-title Donner votre avis + %h2.claimant + Demandeur : + %span.email.font-weight-normal= safe_claimant_email(@avis.claimant) + %span.date.font-weight-normal Demande d’avis envoyée le #{l(@avis.created_at, format: '%d/%m/%y')} + %p.introduction= @avis.introduction - - if @avis.introduction_file.attached? - = 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: { data: { controller: 'persisted-form', persisted_form_key_value: dom_id(@avis) }, multipart: true } do |f| + - if @avis.introduction_file.attached? + = 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: { 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' + - 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-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 + .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) + = render Attachment::EditComponent.new(attached_file: @avis.piece_justificative_file, view_as: :download) - .flex.justify-between.align-baseline - %p.confidentiel.flex - - if @avis.confidentiel? - %span.icon.lock - %span - Cet avis est confidentiel et n’est pas affiché aux autres experts consultés - - else - %span - Cet avis est partagé avec les autres experts - .send-wrapper - = f.submit 'Envoyer votre avis', class: 'fr-btn' + .flex.justify-between.align-baseline + %p.confidentiel.flex + - if @avis.confidentiel? + %span.icon.lock + %span + Cet avis est confidentiel et n’est pas affiché aux autres experts consultés + - else + %span + Cet avis est partagé avec les autres experts + .send-wrapper + = f.submit 'Envoyer votre avis', class: 'fr-btn' + - else + %h2.empty-text + = t('helpers.information_text.no_new_avis_text') + %p.empty-text-details + = t('helpers.information_text.no_new_avis_text_detail') diff --git a/app/views/instructeurs/avis/_sidemenu.html.haml b/app/views/instructeurs/avis/_sidemenu.html.haml index 341c90cdd..4446b240d 100644 --- a/app/views/instructeurs/avis/_sidemenu.html.haml +++ b/app/views/instructeurs/avis/_sidemenu.html.haml @@ -1,14 +1,2 @@ -%nav.fr-sidemenu{ "aria-labelledby" => "fr-sidemenu-title" } - .fr-sidemenu__inner - %button.fr-sidemenu__btn{ "aria-controls" => "fr-sidemenu-wrapper", "aria-expanded" => "false", hidden: "" } Dans cette rubrique - #fr-sidemenu-wrapper.fr-collapse - %ul.fr-sidemenu__list - - url = avis_instructeur_dossier_path(@dossier.procedure, @dossier) - - current_page = current_page?(url) - %li{ class: "fr-sidemenu__item fr-sidemenu__item#{current_page ? '--active' : ''}" } - %a.fr-sidemenu__link{ 'aria-current': current_page ? 'page' : nil,href: url, target: "_self" } Voir les avis - - - url = avis_new_instructeur_dossier_path(@dossier.procedure, @dossier) - - current_page = current_page?(url) - %li{ class: "fr-sidemenu__item fr-sidemenu__item#{current_page ? '--active' : ''}" } - %a.fr-sidemenu__link{ 'aria-current': current_page ? 'page' : nil, href: url, target: "_self" } Demander un avis += render(Dsfr::SidemenuComponent.new) do |component| + - component.with_links([{ name: t('helpers.sidemenu.see_avis'), url: avis_instructeur_dossier_path(@dossier.procedure, @dossier) }, { name: t('helpers.sidemenu.ask_avis'), url: avis_new_instructeur_dossier_path(@dossier.procedure, @dossier) }]) diff --git a/app/views/instructeurs/dossiers/avis.html.haml b/app/views/instructeurs/dossiers/avis.html.haml index 666788e9b..d7a589ac2 100644 --- a/app/views/instructeurs/dossiers/avis.html.haml +++ b/app/views/instructeurs/dossiers/avis.html.haml @@ -11,5 +11,7 @@ = render partial: 'instructeurs/avis/list', locals: { avis: @dossier.avis, avis_seen_at: @avis_seen_at } - else - %h2.empty-text Aucun avis. - %p.empty-text-details Aucun avis n’a été demandé sur ce dossier. + %h2.empty-text + = t('helpers.information_text.empty_text') + %p.empty-text-details + = t('helpers.information_text.empty_text_detail') diff --git a/app/views/instructeurs/dossiers/avis_new.html.haml b/app/views/instructeurs/dossiers/avis_new.html.haml index 31fa08472..3d9c19ee6 100644 --- a/app/views/instructeurs/dossiers/avis_new.html.haml +++ b/app/views/instructeurs/dossiers/avis_new.html.haml @@ -11,4 +11,12 @@ - if @dossier.procedure.allow_expert_review = render partial: "instructeurs/avis/form", locals: { url: avis_instructeur_dossier_path(@dossier.procedure, @dossier), linked_dossiers: @dossier.linked_dossiers_for(current_instructeur), must_be_confidentiel: false, avis: @avis } - else - %p Cette démarche n’autorise pas la demande d’avis à un expert. Veuillez contacter votre administrateur + %h2.empty-text + = t('helpers.information_text.unauthorized_avis_text') + %p.empty-text-details + = t('helpers.information_text.unauthorized_avis_text_detail') + - else + %h2.empty-text + = t('helpers.information_text.no_new_avis_text') + %p.empty-text-details + = t('helpers.information_text.no_new_avis_text_detail') diff --git a/config/locales/models/avis/en.yml b/config/locales/models/avis/en.yml index bcc51ae19..5947165cb 100644 --- a/config/locales/models/avis/en.yml +++ b/config/locales/models/avis/en.yml @@ -26,3 +26,15 @@ en: confirmation: revoke: "Would you like to revoke the opinion request to %{email} ?" remind: "Would you like to remind %{email} ?" + sidemenu: + give_avis: Give your opinion + see_avis: Read opinions + ask_avis: Ask for an opinion + ask_new_avis: Ask for a new opinion + information_text: + no_new_avis_text: The file has been proceed + no_new_avis_text_detail: Opinion requests are closed + unauthorized_avis_text: This procedure does not allowed expert opinions + unauthorized_avis_text_detail: Would you please contact your administrator + empty_text: No opinion. + empty_text_detail: No opinion available on this file diff --git a/config/locales/models/avis/fr.yml b/config/locales/models/avis/fr.yml index 1a3c8b6d4..2ebf2c2d1 100644 --- a/config/locales/models/avis/fr.yml +++ b/config/locales/models/avis/fr.yml @@ -26,3 +26,15 @@ fr: confirmation: revoke: "Souhaitez-vous révoquer la demande d’avis à %{email} ?" remind: "Souhaitez-vous relancer %{email} ?" + sidemenu: + give_avis: Donner votre avis + see_avis: Voir les avis + ask_avis: Demander un avis + ask_new_avis: Demander un nouvel avis + information_text: + no_new_avis_text: Le dossier a été traité + no_new_avis_text_detail: Les demandes d'avis ne sont plus autorisées + unauthorized_avis_text: Cette démarche n’autorise pas la demande d’avis à un expert. + unauthorized_avis_text_detail: Veuillez contacter votre administrateur + empty_text: Aucun avis. + empty_text_detail: Aucun avis n’est disponible sur ce dossier.