one less count

This commit is contained in:
simon lehericey 2021-04-22 08:38:34 +02:00
parent 8b73d8804c
commit 20fb756097
5 changed files with 12 additions and 11 deletions

View file

@ -156,6 +156,11 @@ module Instructeurs
.groupe_instructeurs
.where(procedure: procedure)
@dossier_count = current_instructeur
.dossiers_count_summary(groupe_instructeur_ids)
.fetch_values('tous', 'archives')
.sum
export = Export.find_or_create_export(export_format, groupe_instructeurs)
if export.ready? && export.old? && params[:force_export]

View file

@ -1,4 +1,4 @@
- if procedure.dossiers.state_not_brouillon.any?
- if dossier_count > 0
%span.dropdown
%button.button.dropdown-button{ 'aria-expanded' => 'false', 'aria-controls' => 'download-menu' }
Télécharger tous les dossiers

View file

@ -1,5 +1,5 @@
<%= render_to_element('.procedure-actions', partial: "download_dossiers",
locals: { procedure: @procedure, xlsx_export: @xlsx_export, csv_export: @csv_export, ods_export: @ods_export }) %>
locals: { procedure: @procedure, xlsx_export: @xlsx_export, csv_export: @csv_export, ods_export: @ods_export, dossier_count: @dossier_count }) %>
<% [[@xlsx_export, :xlsx], [@csv_export, :csv], [@ods_export, :ods]].each do |(export, format)| %>
<% if export && !export.ready? %>

View file

@ -50,7 +50,7 @@
.procedure-actions
= render partial: "download_dossiers",
locals: { procedure: @procedure, xlsx_export: @xlsx_export, csv_export: @csv_export, ods_export: @ods_export }
locals: { procedure: @procedure, xlsx_export: @xlsx_export, csv_export: @csv_export, ods_export: @ods_export, dossier_count: @tous_count + @archives_count }
.container
- if @statut == 'a-suivre'

View file

@ -1,20 +1,16 @@
describe 'instructeurs/procedures/_download_dossiers.html.haml', type: :view do
let(:current_instructeur) { create(:instructeur) }
let(:procedure) { create(:procedure) }
let(:dossier_count) { 0 }
subject { render 'instructeurs/procedures/download_dossiers.html.haml', procedure: procedure, xlsx_export: nil, csv_export: nil, ods_export: nil }
subject { render 'instructeurs/procedures/download_dossiers.html.haml', procedure: procedure, dossier_count: dossier_count, xlsx_export: nil, csv_export: nil, ods_export: nil }
context "when procedure has 0 dossier" do
it { is_expected.not_to include("Télécharger tous les dossiers") }
end
context "when procedure has 1 dossier brouillon" do
let!(:dossier) { create(:dossier, procedure: procedure) }
it { is_expected.not_to include("Télécharger tous les dossiers") }
end
context "when procedure has at least 1 dossier en construction" do
let!(:dossier) { create(:dossier, :en_construction, procedure: procedure) }
context "when procedure has at least 1 dossier" do
let(:dossier_count) { 1 }
it { is_expected.to include("Télécharger tous les dossiers") }
context "With zip archive enabled" do