Merge pull request #2526 from betagouv/tabs

Tabs
This commit is contained in:
Paul Chavard 2018-09-07 10:58:37 +01:00 committed by GitHub
commit 3f113fd170
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 20 additions and 16 deletions

View file

@ -9,7 +9,11 @@ module TabsHelper
}
end
def active_tab_item(label, url, badge: nil, notification: false)
tab_item(label, url, active: current_page?(url), badge: badge, notification: notification)
def dynamic_tab_item(label, url_or_urls, badge: nil, notification: false)
urls = [url_or_urls].flatten
url = urls.first
active = urls.any? { |u| current_page?(u) }
tab_item(label, url, active: active, badge: badge, notification: notification)
end
end

View file

@ -5,6 +5,6 @@
%li= "#{dossier.procedure.libelle}, dossier nº #{dossier.id}"
%ul.tabs
= active_tab_item('Demande', gestionnaire_avis_path(avis))
= active_tab_item('Avis', instruction_gestionnaire_avis_path(avis), notification: avis.answer.blank?)
= active_tab_item('Messagerie', messagerie_gestionnaire_avis_path(avis))
= dynamic_tab_item('Demande', gestionnaire_avis_path(avis))
= dynamic_tab_item('Avis', instruction_gestionnaire_avis_path(avis), notification: avis.answer.blank?)
= dynamic_tab_item('Messagerie', messagerie_gestionnaire_avis_path(avis))

View file

@ -21,23 +21,23 @@
%ul.tabs
- notifications_summary = current_gestionnaire.notifications_for_dossier(dossier)
= active_tab_item('Demande',
= dynamic_tab_item('Demande',
gestionnaire_dossier_path(dossier.procedure, dossier),
notification: notifications_summary[:demande])
= active_tab_item('Annotations privées',
= dynamic_tab_item('Annotations privées',
annotations_privees_gestionnaire_dossier_path(dossier.procedure, dossier),
notification: notifications_summary[:annotations_privees])
= active_tab_item('Avis externes',
= dynamic_tab_item('Avis externes',
avis_gestionnaire_dossier_path(dossier.procedure, dossier),
notification: notifications_summary[:avis])
= active_tab_item('Messagerie',
= dynamic_tab_item('Messagerie',
messagerie_gestionnaire_dossier_path(dossier.procedure, dossier),
notification: notifications_summary[:messagerie])
= active_tab_item('Personnes impliquées',
= dynamic_tab_item('Personnes impliquées',
personnes_impliquees_gestionnaire_dossier_path(dossier.procedure, dossier))
.container

View file

@ -8,6 +8,6 @@
%h2 Dossier nº #{dossier.id}
%ul.tabs
= active_tab_item('Résumé', dossier_path(dossier))
= active_tab_item('Demande', demande_dossier_path(dossier))
= active_tab_item('Messagerie', messagerie_dossier_path(dossier))
= dynamic_tab_item('Résumé', dossier_path(dossier))
= dynamic_tab_item('Demande', [demande_dossier_path(dossier), modifier_dossier_path(dossier)])
= dynamic_tab_item('Messagerie', messagerie_dossier_path(dossier))

View file

@ -6,7 +6,7 @@
- elsif dossier.brouillon?
- form_options = { url: brouillon_dossier_url(dossier), method: :patch, html: { class: 'form', multipart: true } }
- else
- form_options = { url: dossier_url(dossier), method: :patch, html: { class: 'form', multipart: true } }
- form_options = { url: modifier_dossier_url(dossier), method: :patch, html: { class: 'form', multipart: true } }
= form_for dossier, form_options do |f|

View file

@ -271,14 +271,14 @@ Rails.application.routes.draw do
#
scope module: 'new_user' do
resources :dossiers, only: [:index, :show, :update] do
resources :dossiers, only: [:index, :show] do
member do
get 'identite'
patch 'update_identite'
get 'brouillon'
patch 'brouillon', to: 'dossiers#update_brouillon'
get 'modifier', to: 'dossiers#modifier'
patch ':id', to: 'dossiers#update'
patch 'modifier', to: 'dossiers#update'
get 'merci'
get 'demande'
get 'messagerie'