Merge pull request #973 from sgmap/hide_export_if_no_dossier

Hide export if no dossier
This commit is contained in:
Mathieu Magnin 2017-11-28 10:47:32 +01:00 committed by GitHub
commit cc26eb6e87
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 10 deletions

View file

@ -0,0 +1,11 @@
- if procedure.dossiers.state_not_brouillon.any?
%span.button.dropdown
Télécharger tous les dossiers
.dropdown-content.fade-in-down
%ul.dropdown-items
%li
= link_to "Au format .csv", download_dossiers_procedure_path(format: :csv, procedure_id: procedure.id), target: "_blank"
%li
= link_to "Au format .xlsx", download_dossiers_procedure_path(format: :xlsx, procedure_id: procedure.id), target: "_blank"
%li
= link_to "Au format .ods", download_dossiers_procedure_path(format: :ods, procedure_id: procedure.id), target: "_blank"

View file

@ -41,16 +41,7 @@
%span.badge= @archived_dossiers.count
.procedure-actions
%span.button.dropdown
Télécharger tous les dossiers
.dropdown-content.fade-in-down
%ul.dropdown-items
%li
= link_to "Au format .csv", download_dossiers_procedure_path(format: :csv, procedure_id: @procedure.id), target: "_blank"
%li
= link_to "Au format .xlsx", download_dossiers_procedure_path(format: :xlsx, procedure_id: @procedure.id), target: "_blank"
%li
= link_to "Au format .ods", download_dossiers_procedure_path(format: :ods, procedure_id: @procedure.id), target: "_blank"
= render partial: "download_dossiers", locals: { procedure: @procedure }
.container
- if @dossiers.present? || @current_filters.count > 0

View file

@ -0,0 +1,20 @@
describe 'new_gestionnaire/procedures/_download_dossiers.html.haml', type: :view do
let(:current_gestionnaire) { create(:gestionnaire) }
let(:procedure) { create(:procedure) }
subject { render 'new_gestionnaire/procedures/download_dossiers.html.haml', procedure: procedure }
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, :initiated, procedure: procedure) }
it { is_expected.to include("Télécharger tous les dossiers") }
end
end