refacto
This commit is contained in:
parent
1541da9d39
commit
e6a4459633
6 changed files with 22 additions and 39 deletions
|
@ -94,7 +94,7 @@ module Instructeurs
|
|||
@not_archived_notifications_dossier_ids = notifications[:en_cours] + notifications[:termines]
|
||||
|
||||
@has_export_notification = notify_exports?
|
||||
@has_last_export = last_export_for(@statut)
|
||||
@last_export = last_export_for(statut)
|
||||
|
||||
@filtered_sorted_ids = procedure_presentation.filtered_sorted_ids(dossiers, statut, count: dossiers_count)
|
||||
|
||||
|
@ -182,7 +182,7 @@ module Instructeurs
|
|||
@statut = export_options[:statut]
|
||||
@dossiers_count = export.count
|
||||
|
||||
@has_last_export = last_export_for(@statut)
|
||||
@last_export = last_export_for(@statut)
|
||||
|
||||
if export.available?
|
||||
respond_to do |format|
|
||||
|
@ -209,28 +209,12 @@ module Instructeurs
|
|||
end
|
||||
|
||||
def polling_last_export
|
||||
@has_last_export = last_export_for(params[:statut])
|
||||
if @has_last_export.available?
|
||||
respond_to do |format|
|
||||
format.turbo_stream do
|
||||
flash.notice = t('instructeurs.procedures.export_available_html', file_format: @has_last_export.format, file_url: @has_last_export.file.url)
|
||||
end
|
||||
|
||||
format.html do
|
||||
redirect_to url_from(@has_last_export.file.url)
|
||||
end
|
||||
end
|
||||
@statut = statut
|
||||
@last_export = last_export_for(@statut)
|
||||
if @last_export.available?
|
||||
flash.notice = t('instructeurs.procedures.export_available_html', file_format: @last_export.format, file_url: @last_export.file.url)
|
||||
else
|
||||
respond_to do |format|
|
||||
format.turbo_stream do
|
||||
if !params[:no_progress_notification]
|
||||
flash.notice = t('instructeurs.procedures.export_pending_html', url: exports_instructeur_procedure_path(procedure))
|
||||
end
|
||||
end
|
||||
format.html do
|
||||
redirect_to exports_instructeur_procedure_path(procedure), notice: t('instructeurs.procedures.export_pending_html', url: exports_instructeur_procedure_path(procedure))
|
||||
end
|
||||
end
|
||||
flash.notice = t('instructeurs.procedures.export_pending_html', url: exports_instructeur_procedure_path(procedure))
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -27,6 +27,5 @@
|
|||
- if @has_export_notification
|
||||
%span.notifications{ 'aria-label': t('instructeurs.dossiers.header.banner.exports_notification_label') }
|
||||
|
||||
|
||||
#last-export-alert
|
||||
= render partial: "last_export_alert"
|
||||
= render partial: "last_export_alert", locals: { export: @last_export, statut: @statut }
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
- if @has_last_export.present?
|
||||
%div{ data: @has_last_export.pending? ? { controller: "turbo-poll", turbo_poll_url_value: polling_last_export_instructeur_procedure_path(export_format: @has_last_export.format, statut: @statut), turbo_poll_interval_value: 5_000, turbo_poll_max_checks_value: 6 } : {} }
|
||||
- if export.present?
|
||||
%div{ data: export.pending? ? { controller: "turbo-poll", turbo_poll_url_value: polling_last_export_instructeur_procedure_path(export_format: export.format, statut: statut), turbo_poll_interval_value: 5_000, turbo_poll_max_checks_value: 6 } : {} }
|
||||
= render Dsfr::AlertComponent.new(state: :info, size: :sm, extra_class_names: 'fr-my-2w') do |c|
|
||||
- c.body do
|
||||
%p
|
||||
- if @has_last_export.pending?
|
||||
- if export.pending?
|
||||
= t('instructeurs.procedures.last_export_pending')
|
||||
- if @has_last_export.generated?
|
||||
= t('instructeurs.procedures.last_export_available_html', file_format: @has_last_export.format, file_url: @has_last_export.file.url)
|
||||
- if @has_last_export.failed?
|
||||
= t('instructeurs.procedures.last_export_failed', file_format: @has_last_export.format)
|
||||
- if export.generated?
|
||||
= t('instructeurs.procedures.last_export_available_html', file_format: export.format, file_url: export.file.url)
|
||||
- if export.failed?
|
||||
= t('instructeurs.procedures.last_export_failed', file_format: export.format)
|
||||
|
|
|
@ -8,4 +8,4 @@
|
|||
= render Dossiers::ExportDropdownComponent.new(procedure: @procedure, statut: @statut, count: @dossiers_count, export_url: method(:download_export_instructeur_procedure_path))
|
||||
|
||||
= turbo_stream.update "last-export-alert" do
|
||||
= render partial: "last_export_alert"
|
||||
= render partial: "last_export_alert", locals: { export: @last_export, statut: @statut }
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
= turbo_stream.update "last-export-alert" do
|
||||
= render partial: "last_export_alert"
|
||||
= render partial: "last_export_alert", locals: { export: @last_export, statut: @statut }
|
||||
|
|
|
@ -518,7 +518,7 @@ describe Instructeurs::ProceduresController, type: :controller do
|
|||
subject
|
||||
end
|
||||
|
||||
it { expect(assigns(:has_last_export)).to eq(export) }
|
||||
it { expect(assigns(:last_export)).to eq(export) }
|
||||
it { expect(response.body).to include("Votre dernier export est en cours de création") }
|
||||
end
|
||||
|
||||
|
@ -530,7 +530,7 @@ describe Instructeurs::ProceduresController, type: :controller do
|
|||
subject
|
||||
end
|
||||
|
||||
it { expect(assigns(:has_last_export)).to eq(export) }
|
||||
it { expect(assigns(:last_export)).to eq(export) }
|
||||
it { expect(response.body).to include("Votre dernier export au format csv est prêt") }
|
||||
end
|
||||
|
||||
|
@ -542,7 +542,7 @@ describe Instructeurs::ProceduresController, type: :controller do
|
|||
subject
|
||||
end
|
||||
|
||||
it { expect(assigns(:has_last_export)).to eq(export) }
|
||||
it { expect(assigns(:last_export)).to eq(export) }
|
||||
it { expect(response.body).to include("Votre dernier export au format csv n'a pas fonctionné") }
|
||||
end
|
||||
|
||||
|
@ -553,7 +553,7 @@ describe Instructeurs::ProceduresController, type: :controller do
|
|||
subject
|
||||
end
|
||||
|
||||
it { expect(assigns(:has_last_export)).to eq(nil) }
|
||||
it { expect(assigns(:last_export)).to eq(nil) }
|
||||
end
|
||||
|
||||
context 'logged in with another instructeur' do
|
||||
|
@ -567,7 +567,7 @@ describe Instructeurs::ProceduresController, type: :controller do
|
|||
subject
|
||||
end
|
||||
|
||||
it { expect(assigns(:has_last_export)).to eq(nil) }
|
||||
it { expect(assigns(:last_export)).to eq(nil) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue