Remove nav when empty
This commit is contained in:
parent
5c6eb69c43
commit
480c8f493e
2 changed files with 41 additions and 39 deletions
|
@ -24,44 +24,46 @@
|
|||
= render Dossiers::UserProcedureFilterComponent.new(procedures_for_select: @procedures_for_select)
|
||||
|
||||
- if @search_terms.blank?
|
||||
- cache([I18n.locale, current_user.id, @statut, current_user.dossiers, current_user.dossiers_invites], expires_in: 1.hour) do
|
||||
%nav.fr-tabs{ role: 'navigation', 'aria-label': t('views.users.dossiers.secondary_menu') }
|
||||
%ul.fr-tabs__list{ role: 'tablist' }
|
||||
- if @user_dossiers.present?
|
||||
= tab_item(t('pluralize.en_cours', count: @user_dossiers.count),
|
||||
dossiers_path(statut: 'en-cours', procedure_id: params[:procedure_id]),
|
||||
active: @statut == 'en-cours',
|
||||
badge: number_with_html_delimiter(@user_dossiers.count))
|
||||
- if @dossiers_traites.present?
|
||||
// TODO: when renaming this tab in "Terminé", update notify_near_deletion_to_user email wording accordingly.
|
||||
= tab_item(t('pluralize.traites', count: @dossiers_traites.count),
|
||||
dossiers_path(statut: 'traites', procedure_id: params[:procedure_id]),
|
||||
active: @statut == 'traites',
|
||||
badge: number_with_html_delimiter(@dossiers_traites.count))
|
||||
- if [@user_dossiers, @dossiers_traites, @dossiers_invites, @dossiers_close_to_expiration, @dossiers_supprimes, @dossier_transferes].any?(&:present?)
|
||||
- cache([I18n.locale, current_user.id, @statut, current_user.dossiers, current_user.dossiers_invites], expires_in: 1.hour) do
|
||||
%nav.fr-tabs{ role: 'navigation', 'aria-label': t('views.users.dossiers.secondary_menu') }
|
||||
%ul.fr-tabs__list{ role: 'tablist' }
|
||||
- if @user_dossiers.present?
|
||||
= tab_item(t('pluralize.en_cours', count: @user_dossiers.count),
|
||||
dossiers_path(statut: 'en-cours', procedure_id: params[:procedure_id]),
|
||||
active: @statut == 'en-cours',
|
||||
badge: number_with_html_delimiter(@user_dossiers.count))
|
||||
|
||||
- if @dossiers_invites.present?
|
||||
= tab_item(t('pluralize.dossiers_invites', count: @dossiers_invites.count),
|
||||
dossiers_path(statut: 'dossiers-invites', procedure_id: params[:procedure_id]),
|
||||
active: @statut == 'dossiers-invites',
|
||||
badge: number_with_html_delimiter(@dossiers_invites.count))
|
||||
- if @dossiers_traites.present?
|
||||
// TODO: when renaming this tab in "Terminé", update notify_near_deletion_to_user email wording accordingly.
|
||||
= tab_item(t('pluralize.traites', count: @dossiers_traites.count),
|
||||
dossiers_path(statut: 'traites', procedure_id: params[:procedure_id]),
|
||||
active: @statut == 'traites',
|
||||
badge: number_with_html_delimiter(@dossiers_traites.count))
|
||||
|
||||
- if @dossiers_close_to_expiration.count > 0
|
||||
= tab_item(t('pluralize.dossiers_close_to_expiration', count: @dossiers_close_to_expiration.count),
|
||||
dossiers_path(statut: 'dossiers-expirant', procedure_id: params[:procedure_id]),
|
||||
active: @statut == 'dossiers-expirant',
|
||||
badge: number_with_html_delimiter(@dossiers_close_to_expiration.count))
|
||||
- if @dossiers_invites.present?
|
||||
= tab_item(t('pluralize.dossiers_invites', count: @dossiers_invites.count),
|
||||
dossiers_path(statut: 'dossiers-invites', procedure_id: params[:procedure_id]),
|
||||
active: @statut == 'dossiers-invites',
|
||||
badge: number_with_html_delimiter(@dossiers_invites.count))
|
||||
|
||||
- if @dossiers_supprimes.present?
|
||||
= tab_item(t('pluralize.dossiers_supprimes', count: @dossiers_supprimes.count),
|
||||
dossiers_path(statut: 'dossiers-supprimes', procedure_id: params[:procedure_id]),
|
||||
active: @statut == 'dossiers-supprimes',
|
||||
badge: number_with_html_delimiter(@dossiers_supprimes.count))
|
||||
- if @dossiers_close_to_expiration.count > 0
|
||||
= tab_item(t('pluralize.dossiers_close_to_expiration', count: @dossiers_close_to_expiration.count),
|
||||
dossiers_path(statut: 'dossiers-expirant', procedure_id: params[:procedure_id]),
|
||||
active: @statut == 'dossiers-expirant',
|
||||
badge: number_with_html_delimiter(@dossiers_close_to_expiration.count))
|
||||
|
||||
- if @dossier_transferes.present?
|
||||
= tab_item(t('pluralize.dossiers_transferes', count: @dossier_transferes.count),
|
||||
dossiers_path(statut: 'dossiers-transferes', procedure_id: params[:procedure_id]),
|
||||
active: @statut == 'dossiers-transferes',
|
||||
badge: number_with_html_delimiter(@dossier_transferes.count))
|
||||
- if @dossiers_supprimes.present?
|
||||
= tab_item(t('pluralize.dossiers_supprimes', count: @dossiers_supprimes.count),
|
||||
dossiers_path(statut: 'dossiers-supprimes', procedure_id: params[:procedure_id]),
|
||||
active: @statut == 'dossiers-supprimes',
|
||||
badge: number_with_html_delimiter(@dossiers_supprimes.count))
|
||||
|
||||
- if @dossier_transferes.present?
|
||||
= tab_item(t('pluralize.dossiers_transferes', count: @dossier_transferes.count),
|
||||
dossiers_path(statut: 'dossiers-transferes', procedure_id: params[:procedure_id]),
|
||||
active: @statut == 'dossiers-transferes',
|
||||
badge: number_with_html_delimiter(@dossier_transferes.count))
|
||||
|
||||
.fr-container
|
||||
.fr-grid-row.fr-grid-row--center
|
||||
|
|
|
@ -113,12 +113,12 @@ describe 'users/dossiers/index', type: :view do
|
|||
|
||||
context 'caching', caching: true do
|
||||
it "works" do
|
||||
expect(user_dossiers).to receive(:present?).once
|
||||
expect(user_dossiers).to receive(:present?).thrice
|
||||
2.times { render; user.reload }
|
||||
end
|
||||
|
||||
it "cache key depends on statut" do
|
||||
expect(user_dossiers).to receive(:present?).twice
|
||||
expect(user_dossiers).to receive(:present?).exactly(4).times
|
||||
render
|
||||
|
||||
assign(:statut, "termines")
|
||||
|
@ -128,7 +128,7 @@ describe 'users/dossiers/index', type: :view do
|
|||
end
|
||||
|
||||
it "cache key depends on dossier updated_at" do
|
||||
expect(user_dossiers).to receive(:present?).twice
|
||||
expect(user_dossiers).to receive(:present?).exactly(4).times
|
||||
render
|
||||
|
||||
dossier_termine.touch
|
||||
|
@ -149,7 +149,7 @@ describe 'users/dossiers/index', type: :view do
|
|||
end
|
||||
|
||||
it "cache key depends on dossier invites" do
|
||||
expect(user_dossiers).to receive(:present?).twice
|
||||
expect(user_dossiers).to receive(:present?).exactly(4).times
|
||||
render
|
||||
|
||||
create(:invite, user:)
|
||||
|
@ -159,7 +159,7 @@ describe 'users/dossiers/index', type: :view do
|
|||
end
|
||||
|
||||
it "cache key depends on dossier deletion" do
|
||||
expect(user_dossiers).to receive(:present?).twice
|
||||
expect(user_dossiers).to receive(:present?).exactly(4).times
|
||||
render
|
||||
|
||||
dossier_termine.hide_and_keep_track!(:automatic, :expired)
|
||||
|
|
Loading…
Reference in a new issue