demarches-normaliennes/app/views/layouts/_header.haml
2022-10-11 09:50:21 +02:00

105 lines
5.9 KiB
Text

-# We can't use &. because the controller may not implement #nav_bar_profile
- nav_bar_profile = controller.try(:nav_bar_profile) || :guest
- dossier = controller.try(:dossier_for_help)
- procedure = controller.try(:procedure_for_help)
- is_instructeur_context = nav_bar_profile == :instructeur && instructeur_signed_in?
- is_expert_context = nav_bar_profile == :expert && expert_signed_in?
- is_user_context = nav_bar_profile == :user
- is_search_enabled = [params[:controller] == 'recherche', is_instructeur_context, is_expert_context, is_user_context && current_user.dossiers.count].any?
%header{ class: ["fr-header", content_for?(:notice_info) && "fr-header__with-notice-info"], role: "banner", "data-controller": "dsfr-header" }
.fr-header__body
.fr-container
.fr-header__body-row
.fr-header__brand.fr-enlarge-link
.fr-header__brand-top
.fr-header__logo
%p.fr-logo
République
= succeed "Française" do
%br/
.fr-header__navbar
- if is_search_enabled
%button.fr-btn--search.fr-btn{ "aria-controls" => "search-modal", "data-fr-opened" => "false", :title => t('views.users.dossiers.search.search_file') }= t('views.users.dossiers.search.search_file')
%button.fr-btn--menu.fr-btn{ "aria-controls" => "burger-menu", "aria-haspopup" => "menu", "data-fr-opened" => "false", :title => "Menu" } Menu
.fr-header__service
- root_profile_link, root_profile_libelle = root_path_info_for_profile(nav_bar_profile)
= link_to root_profile_link, :title => root_profile_libelle do
%p.fr-header__service-title= APPLICATION_NAME
.fr-header__tools
.fr-header__tools-links.relative
%ul.fr-btns-group
- if instructeur_signed_in? || user_signed_in?
%li
= render partial: 'layouts/account_dropdown', locals: { nav_bar_profile: nav_bar_profile }
- elsif (request.path != new_user_session_path && request.path !=agent_connect_path)
- if request.path == new_user_registration_path
%li
.fr-hidden-sm.fr-unhidden-lg.fr-link--sm= t('views.shared.account.already_user_question')
%li= link_to t('views.shared.account.signin'), new_user_session_path, class: "fr-btn fr-btn--tertiary fr-icon-account-circle-fill fr-btn--icon-left"
%li
- if dossier.present? && nav_bar_profile == :user
= render partial: 'shared/help/help_dropdown_dossier', locals: { dossier: dossier }
- elsif procedure.present? && (nav_bar_profile == :user || nav_bar_profile == :guest)
= render partial: 'shared/help/help_dropdown_procedure', locals: { procedure: procedure }
- elsif nav_bar_profile == :instructeur
= render partial: 'shared/help/help_dropdown_instructeur'
- else
%li= render partial: 'shared/help/help_button'
- if localization_enabled?
%li= render partial: 'layouts/locale_dropdown'
- if params[:controller] == 'recherche'
= render partial: 'layouts/search_dossiers_form', locals: { search_endpoint: recherche_index_path }
- if is_instructeur_context
= render partial: 'layouts/search_dossiers_form', locals: { search_endpoint: recherche_index_path }
- if is_expert_context
= render partial: 'layouts/search_dossiers_form', locals: { search_endpoint: recherche_index_path }
- if is_user_context && current_user.dossiers.count > 2
= render partial: 'layouts/search_dossiers_form', locals: { search_endpoint: recherche_dossiers_path }
- has_header = [is_instructeur_context, is_expert_context, is_user_context]
#burger-menu.fr-header__menu.fr-modal{ "aria-labelledby" => "burger_button" }
.fr-container
%button#burger_button.fr-btn--close.fr-btn{ "aria-controls" => "burger-menu", :title => t('close_modal', scope: [:layouts, :header]) }= t('close_modal', scope: [:layouts, :header])
.fr-header__menu-links
%nav#navigation-478.fr-nav{ "aria-label" => t('main_menu', scope: [:layouts, :header]) , :role => "navigation" }
%ul.fr-nav__list
-# Questionner UX pour un back JS
- if params[:controller] == 'users/commencer'
%li.fr-nav__item
= link_to t('back', scope: [:layouts, :header]), url_for(:back), title: t('back_title', scope: [:layouts, :header]), class: 'fr-nav__link'
- if is_instructeur_context
- if current_instructeur.procedures.any?
- current_url = request.path_info
%li.fr-nav__item
= active_link_to t('utils.procedure'), instructeur_procedures_path, active: ['dossiers','procedures'].include?(controller_name), class: 'fr-nav__link'
- if current_instructeur.user.expert && current_expert.avis_summary[:total] > 0
= render partial: 'layouts/header/avis_tab', locals: { current_expert: current_expert }
- if is_expert_context
- if current_expert.user.instructeur && current_instructeur.procedures.any?
%li.fr-nav__item= active_link_to t('utils.procedure'), instructeur_procedures_path, active: ['dossiers','procedures'].include?(controller_name), class: 'fr-nav__link'
- if current_expert.avis_summary[:total] > 0
= render partial: 'layouts/header/avis_tab', locals: { current_expert: current_expert }
- if is_user_context
%li.fr-nav__item= active_link_to t('.files'), dossiers_path, active: :inclusive, class: 'fr-nav__link'
- if current_user.expert && current_expert.avis_summary[:total] > 0
= render partial: 'layouts/header/avis_tab', locals: { current_expert: current_expert }
= yield(:notice_info)