poc(batch_operation_alert): simplier wording
This commit is contained in:
parent
3d2f0ebb88
commit
7c65af3be0
8 changed files with 28 additions and 68 deletions
|
@ -4,6 +4,7 @@ class Dossiers::BatchAlertComponent < ApplicationComponent
|
||||||
def initialize(batch:, procedure:)
|
def initialize(batch:, procedure:)
|
||||||
@batch = batch
|
@batch = batch
|
||||||
@procedure = procedure
|
@procedure = procedure
|
||||||
|
set_seen_at! if batch.finished_at.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_seen_at!
|
def set_seen_at!
|
||||||
|
|
|
@ -1,17 +1,13 @@
|
||||||
en:
|
en:
|
||||||
finish:
|
finish:
|
||||||
title: The bulk action is finished
|
title: The bulk action is finished
|
||||||
text_success:
|
text:
|
||||||
one: 1 file has been archived
|
one: 1/1 file has been archived
|
||||||
other: "%{count} files have been archived"
|
other: "%{success_count}/%{count} files have been archived"
|
||||||
text_fail:
|
|
||||||
one: 1 file has not been archived
|
|
||||||
other: "%{count} have not been archived"
|
|
||||||
in_progress:
|
in_progress:
|
||||||
title: A bulk action is processing
|
title: A bulk action is processing
|
||||||
text_beginning: "0/ %{count} file archived"
|
|
||||||
text_success:
|
text_success:
|
||||||
one: 1 file has been archived
|
one: 1/1 is being archived
|
||||||
other: "%{count} files have been archived"
|
other: "%{progress_count}/%{count} files have been archived"
|
||||||
link_text: Refresh this webpage
|
link_text: Refresh this webpage
|
||||||
after_link_text: to check if the process is over.
|
after_link_text: to check if the process is over.
|
||||||
|
|
|
@ -3,15 +3,11 @@ fr:
|
||||||
title: L'action de masse est terminée
|
title: L'action de masse est terminée
|
||||||
text_success:
|
text_success:
|
||||||
one: 1 dossier a été archivé
|
one: 1 dossier a été archivé
|
||||||
other: "%{count} dossiers ont été archivés"
|
other: "%{success_count}/%{count} dossiers ont été archivés"
|
||||||
text_fail:
|
|
||||||
one: 1 dossier n'a pas été archivé
|
|
||||||
other: "%{count} dossiers n'ont pas été archivés"
|
|
||||||
in_progress:
|
in_progress:
|
||||||
title: Une action de masse est en cours
|
title: Une action de masse est en cours
|
||||||
text_beginning: "0/ %{count} dossier archivé"
|
|
||||||
text_success:
|
text_success:
|
||||||
one: 1 dossier a été archivé
|
one: 1 dossier sera archivé
|
||||||
other: "%{count} dossiers ont été archivés"
|
other: "%{progress_count}/%{count} dossiers ont été archivés"
|
||||||
link_text: Recharger la page
|
link_text: Recharger la page
|
||||||
after_link_text: pour voir si l'opération est finie.
|
after_link_text: pour voir si l'opération est finie.
|
||||||
|
|
|
@ -1,34 +1,15 @@
|
||||||
.fr-mb-5v
|
.fr-mb-5v
|
||||||
- if @batch.finished_and_success? && @batch.seen_at.nil?
|
- if @batch.finished_at.present?
|
||||||
= render Dsfr::AlertComponent.new(title: t('.finish.title'), state: :success, heading_level: 'h2') do |c|
|
= render Dsfr::AlertComponent.new(title: t('.finish.title'), state: (@batch.failed_dossier_ids.size.positive? ? :warning : :success), heading_level: 'h2') do |c|
|
||||||
- c.body do
|
- c.body do
|
||||||
%p
|
%p
|
||||||
= t('.finish.text_success', count: @batch.success_dossier_ids.count)
|
= t('.finish.text_success', count: @batch.total_count, success_count: @batch.success_dossier_ids.size)
|
||||||
- set_seen_at!
|
|
||||||
|
|
||||||
- if @batch.finished_and_fails? && @batch.seen_at.nil?
|
|
||||||
= render Dsfr::AlertComponent.new(title: t('.finish.title'), state: :warning, heading_level: 'h2') do |c|
|
- else
|
||||||
- c.body do
|
|
||||||
%p
|
|
||||||
= t('.finish.text_fail', count: @batch.failed_dossier_ids.count)
|
|
||||||
- set_seen_at!
|
|
||||||
- if @batch.beginning?
|
|
||||||
= render Dsfr::AlertComponent.new(title: t('.in_progress.title'), state: :info, heading_level: 'h2') do |c|
|
= render Dsfr::AlertComponent.new(title: t('.in_progress.title'), state: :info, heading_level: 'h2') do |c|
|
||||||
- c.body do
|
- c.body do
|
||||||
%p
|
%p= t('.in_progress.text_success', count: @batch.total_count, progress_count: @batch.progress_count)
|
||||||
= t('.in_progress.text_beginning', count: @batch.dossiers.count)
|
|
||||||
|
|
||||||
%p
|
|
||||||
= link_to t('.link_text'), instructeur_procedure_path(@procedure, statut: params["statut"]), data: { action: 'turbo-poll#refresh' }
|
|
||||||
= t('.after_link_text')
|
|
||||||
|
|
||||||
- if @batch.in_progress?
|
|
||||||
= render Dsfr::AlertComponent.new(title: t('.in_progress.title'), state: :info, heading_level: 'h2') do |c|
|
|
||||||
- c.body do
|
|
||||||
|
|
||||||
- if @batch.success_dossier_ids.present?
|
|
||||||
%p
|
|
||||||
= t('.in_progress.text_success', count: @batch.success_dossier_ids.count)
|
|
||||||
|
|
||||||
%p
|
%p
|
||||||
= link_to t('.link_text'), instructeur_procedure_path(@procedure, statut: params["statut"]), data: { action: 'turbo-poll#refresh' }
|
= link_to t('.link_text'), instructeur_procedure_path(@procedure, statut: params["statut"]), data: { action: 'turbo-poll#refresh' }
|
||||||
|
|
|
@ -93,6 +93,7 @@ module Instructeurs
|
||||||
|
|
||||||
@batch_operations = BatchOperation.joins(:groupe_instructeurs)
|
@batch_operations = BatchOperation.joins(:groupe_instructeurs)
|
||||||
.where(groupe_instructeurs: current_instructeur.groupe_instructeurs.where(procedure_id: @procedure.id))
|
.where(groupe_instructeurs: current_instructeur.groupe_instructeurs.where(procedure_id: @procedure.id))
|
||||||
|
.where(seen_at: nil)
|
||||||
.distinct
|
.distinct
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -108,20 +108,17 @@ class BatchOperation < ApplicationRecord
|
||||||
dossiers.count.zero?
|
dossiers.count.zero?
|
||||||
end
|
end
|
||||||
|
|
||||||
def finished_and_success?
|
def total_count
|
||||||
called_for_last_time? && failed_dossier_ids.empty?
|
total = failed_dossier_ids.size + success_dossier_ids.size
|
||||||
|
|
||||||
|
if finished_at.blank?
|
||||||
|
total += dossiers.count
|
||||||
|
end
|
||||||
|
total
|
||||||
end
|
end
|
||||||
|
|
||||||
def finished_and_fails?
|
def progress_count
|
||||||
called_for_last_time? && failed_dossier_ids.present?
|
failed_dossier_ids.size + success_dossier_ids.size
|
||||||
end
|
|
||||||
|
|
||||||
def in_progress?
|
|
||||||
!called_for_last_time? && (failed_dossier_ids + success_dossier_ids).present?
|
|
||||||
end
|
|
||||||
|
|
||||||
def beginning?
|
|
||||||
!called_for_last_time? && (failed_dossier_ids + success_dossier_ids).empty?
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -13,12 +13,6 @@ RSpec.describe Dossiers::BatchAlertComponent, type: :component do
|
||||||
|
|
||||||
subject { render_inline(component).to_html }
|
subject { render_inline(component).to_html }
|
||||||
|
|
||||||
context 'beginning' do
|
|
||||||
it { is_expected.to have_selector('.fr-alert--info') }
|
|
||||||
it { is_expected.to have_text("Une action de masse est en cours") }
|
|
||||||
it { is_expected.to have_text("0/ 2 dossier archivé") }
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'in_progress' do
|
context 'in_progress' do
|
||||||
before {
|
before {
|
||||||
batch_operation.track_processed_dossier(true, dossier)
|
batch_operation.track_processed_dossier(true, dossier)
|
||||||
|
@ -27,7 +21,7 @@ RSpec.describe Dossiers::BatchAlertComponent, type: :component do
|
||||||
|
|
||||||
it { is_expected.to have_selector('.fr-alert--info') }
|
it { is_expected.to have_selector('.fr-alert--info') }
|
||||||
it { is_expected.to have_text("Une action de masse est en cours") }
|
it { is_expected.to have_text("Une action de masse est en cours") }
|
||||||
it { is_expected.to have_text("1 dossier a été archivé") }
|
it { is_expected.to have_text("1/2 dossiers ont été archivés") }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'finished and success' do
|
context 'finished and success' do
|
||||||
|
@ -41,12 +35,6 @@ RSpec.describe Dossiers::BatchAlertComponent, type: :component do
|
||||||
it { is_expected.to have_text("L'action de masse est terminée") }
|
it { is_expected.to have_text("L'action de masse est terminée") }
|
||||||
it { is_expected.to have_text("2 dossiers ont été archivés") }
|
it { is_expected.to have_text("2 dossiers ont été archivés") }
|
||||||
it { expect(batch_operation.seen_at).to eq(nil) }
|
it { expect(batch_operation.seen_at).to eq(nil) }
|
||||||
|
|
||||||
it 'does not display alert on the next render' do
|
|
||||||
render_inline(component).to_html
|
|
||||||
expect(batch_operation.seen_at).not_to eq(nil)
|
|
||||||
expect(subject).not_to have_text("2 dossiers ont été archivés")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'finished and fail' do
|
context 'finished and fail' do
|
||||||
|
@ -58,7 +46,7 @@ RSpec.describe Dossiers::BatchAlertComponent, type: :component do
|
||||||
|
|
||||||
it { is_expected.to have_selector('.fr-alert--warning') }
|
it { is_expected.to have_selector('.fr-alert--warning') }
|
||||||
it { is_expected.to have_text("L'action de masse est terminée") }
|
it { is_expected.to have_text("L'action de masse est terminée") }
|
||||||
it { is_expected.to have_text("1 dossier n'a pas été archivé") }
|
it { is_expected.to have_text("1/2 dossiers ont été archivés") }
|
||||||
it { expect(batch_operation.seen_at).to eq(nil) }
|
it { expect(batch_operation.seen_at).to eq(nil) }
|
||||||
|
|
||||||
it 'does not display alert on the next render' do
|
it 'does not display alert on the next render' do
|
||||||
|
|
|
@ -36,7 +36,7 @@ describe 'BatchOperation a dossier:', js: true do
|
||||||
|
|
||||||
# ensure alert is present
|
# ensure alert is present
|
||||||
expect(page).to have_content("Information : Une action de masse est en cours")
|
expect(page).to have_content("Information : Une action de masse est en cours")
|
||||||
expect(page).to have_content("0/ 1 dossier archivé")
|
expect(page).to have_content("1 dossier sera archivé")
|
||||||
|
|
||||||
# ensure jobs are queued
|
# ensure jobs are queued
|
||||||
perform_enqueued_jobs(only: [BatchOperationEnqueueAllJob])
|
perform_enqueued_jobs(only: [BatchOperationEnqueueAllJob])
|
||||||
|
|
Loading…
Add table
Reference in a new issue