create component for sidemenu and add locales for raw text

This commit is contained in:
Lisa Durand 2023-03-20 17:50:05 +01:00
parent 4a2982dc37
commit a01564adcd
13 changed files with 126 additions and 76 deletions

View file

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

View file

@ -0,0 +1,3 @@
---
fr:
btn_collapse_text: In this section

View file

@ -0,0 +1,3 @@
---
fr:
btn_collapse_text: Dans cette rubrique

View file

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

View file

@ -1,21 +1,2 @@
%nav.fr-sidemenu{ "aria-labelledby" => "fr-sidemenu-title" } = render(Dsfr::SidemenuComponent.new) do |component|
.fr-sidemenu__inner - 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) }])
%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

View file

@ -9,3 +9,9 @@
.fr-col .fr-col
- if @dossier.avis_for_expert(current_expert).present? - 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 } = 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')

View file

@ -9,3 +9,8 @@
.fr-col .fr-col
- if !@dossier.termine? - 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 } = 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')

View file

@ -7,6 +7,7 @@
.fr-col.fr-col-12.fr-col-md-3 .fr-col.fr-col-12.fr-col-md-3
= render partial: 'sidemenu' = render partial: 'sidemenu'
.fr-col .fr-col
- if !@dossier.termine?
%section.give-avis %section.give-avis
%h1.tab-title Donner votre avis %h1.tab-title Donner votre avis
%h2.claimant %h2.claimant
@ -53,3 +54,8 @@
Cet avis est partagé avec les autres experts Cet avis est partagé avec les autres experts
.send-wrapper .send-wrapper
= f.submit 'Envoyer votre avis', class: 'fr-btn' = 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')

View file

@ -1,14 +1,2 @@
%nav.fr-sidemenu{ "aria-labelledby" => "fr-sidemenu-title" } = render(Dsfr::SidemenuComponent.new) do |component|
.fr-sidemenu__inner - 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) }])
%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

View file

@ -11,5 +11,7 @@
= render partial: 'instructeurs/avis/list', locals: { avis: @dossier.avis, avis_seen_at: @avis_seen_at } = render partial: 'instructeurs/avis/list', locals: { avis: @dossier.avis, avis_seen_at: @avis_seen_at }
- else - else
%h2.empty-text Aucun avis. %h2.empty-text
%p.empty-text-details Aucun avis na été demandé sur ce dossier. = t('helpers.information_text.empty_text')
%p.empty-text-details
= t('helpers.information_text.empty_text_detail')

View file

@ -11,4 +11,12 @@
- if @dossier.procedure.allow_expert_review - 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 } = 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 - else
%p Cette démarche nautorise pas la demande davis à 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')

View file

@ -26,3 +26,15 @@ en:
confirmation: confirmation:
revoke: "Would you like to revoke the opinion request to %{email} ?" revoke: "Would you like to revoke the opinion request to %{email} ?"
remind: "Would you like to remind %{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

View file

@ -26,3 +26,15 @@ fr:
confirmation: confirmation:
revoke: "Souhaitez-vous révoquer la demande davis à %{email} ?" revoke: "Souhaitez-vous révoquer la demande davis à %{email} ?"
remind: "Souhaitez-vous relancer %{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 nautorise pas la demande davis à un expert.
unauthorized_avis_text_detail: Veuillez contacter votre administrateur
empty_text: Aucun avis.
empty_text_detail: Aucun avis nest disponible sur ce dossier.