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