diff --git a/app/components/dossiers/batch_notice_select_all_component.rb b/app/components/dossiers/batch_notice_select_all_component.rb new file mode 100644 index 000000000..8fae76f5a --- /dev/null +++ b/app/components/dossiers/batch_notice_select_all_component.rb @@ -0,0 +1,6 @@ +class Dossiers::BatchNoticeSelectAllComponent < ApplicationComponent + def initialize(dossiers_count:, filtered_sorted_ids:) + @dossiers_count = dossiers_count + @filtered_sorted_ids = filtered_sorted_ids + end +end diff --git a/app/components/dossiers/batch_notice_select_all_component/batch_notice_select_all_component.en.yml b/app/components/dossiers/batch_notice_select_all_component/batch_notice_select_all_component.en.yml new file mode 100644 index 000000000..177851f57 --- /dev/null +++ b/app/components/dossiers/batch_notice_select_all_component/batch_notice_select_all_component.en.yml @@ -0,0 +1,7 @@ +en: + selected_html: All n files from this page are selected. + select_all: "Select all %{dossiers_count} files." + select_all_limit: "Select first %{limit} files on %{dossiers_count}" + selected_all: "%{dossiers_count} files are selected." + selected_all_limit: "%{limit} files are selected." + delete_selection: "Delete selection" diff --git a/app/components/dossiers/batch_notice_select_all_component/batch_notice_select_all_component.fr.yml b/app/components/dossiers/batch_notice_select_all_component/batch_notice_select_all_component.fr.yml new file mode 100644 index 000000000..6a9b999f6 --- /dev/null +++ b/app/components/dossiers/batch_notice_select_all_component/batch_notice_select_all_component.fr.yml @@ -0,0 +1,7 @@ +fr: + selected_html: Les n dossiers de cette page sont sélectionnés. + select_all: "Sélectionner les %{dossiers_count} dossiers." + select_all_limit: "Sélectionner les %{limit} premiers dossiers sur les %{dossiers_count}" + selected_all: "%{dossiers_count} dossiers sont sélectionnés." + selected_all_limit: "%{limit} dossiers sont sélectionnés." + delete_selection: "Effacer la sélection" diff --git a/app/views/instructeurs/procedures/_notice_dossier_select_all.html.haml b/app/components/dossiers/batch_notice_select_all_component/batch_notice_select_all_component.html.haml similarity index 61% rename from app/views/instructeurs/procedures/_notice_dossier_select_all.html.haml rename to app/components/dossiers/batch_notice_select_all_component/batch_notice_select_all_component.html.haml index 2716ddbb1..2d4c11324 100644 --- a/app/views/instructeurs/procedures/_notice_dossier_select_all.html.haml +++ b/app/components/dossiers/batch_notice_select_all_component/batch_notice_select_all_component.html.haml @@ -3,21 +3,19 @@ .fr-notice__body #not_selected %p.fr-notice__title - Les - %span#dynamic_number n - dossiers de cette page sont sélectionnés. + = t('.selected_html') %a{ :href => "#", data: { action: "batch-operation#onSelectMore", dossiers: @filtered_sorted_ids.first(Instructeurs::ProceduresController::BATCH_SELECTION_LIMIT).join(',') } } - if @dossiers_count <= Instructeurs::ProceduresController::BATCH_SELECTION_LIMIT - = "Sélectionner les #{@dossiers_count} dossiers." + = t(".select_all", dossiers_count: @dossiers_count) - else - = "Sélectionner les #{Instructeurs::ProceduresController::BATCH_SELECTION_LIMIT} premiers dossiers sur les #{@dossiers_count}" + = t(".select_all_limit", dossiers_count: @dossiers_count, limit: Instructeurs::ProceduresController::BATCH_SELECTION_LIMIT) #selected.hidden %p.fr-notice__title - if @dossiers_count <= Instructeurs::ProceduresController::BATCH_SELECTION_LIMIT - = "#{@dossiers_count} dossiers sont sélectionnés." + = t(".selected_all", dossiers_count: @dossiers_count) - else - = "#{Instructeurs::ProceduresController::BATCH_SELECTION_LIMIT} dossiers sont sélectionnés." + = t(".selected_all_limit", limit: Instructeurs::ProceduresController::BATCH_SELECTION_LIMIT) %a{ :href => "#", data: { action: "batch-operation#onDeleteSelection" } } - = "Effacer la sélection" + = t(".delete_selection") = hidden_field_tag :"batch_operation[dossier_ids][]", "", form: dom_id(BatchOperation.new), id: dom_id(BatchOperation.new, "checkbox_multiple") diff --git a/app/views/instructeurs/procedures/show.html.haml b/app/views/instructeurs/procedures/show.html.haml index a5f5c0f50..a69ccc0ee 100644 --- a/app/views/instructeurs/procedures/show.html.haml +++ b/app/views/instructeurs/procedures/show.html.haml @@ -103,7 +103,7 @@ = render batch_operation_component - = render partial: "notice_dossier_select_all", local: {dossiers_count: @dossiers_count, filtered_sorted_ids: @filtered_sorted_ids} + = render Dossiers::BatchNoticeSelectAllComponent.new(dossiers_count: @dossiers_count, filtered_sorted_ids: @filtered_sorted_ids) .fr-table.fr-table--bordered %table.table.dossiers-table.hoverable diff --git a/config/locales/kaminari.en.yml b/config/locales/kaminari.en.yml index daad9c708..3ec3a7902 100644 --- a/config/locales/kaminari.en.yml +++ b/config/locales/kaminari.en.yml @@ -7,7 +7,6 @@ en: display_entries: one: Displaying %{count} %{entry_name} other: Displaying all %{count} %{entry_name} - zero: No %{entry_name} found views: pagination: first: "« First" diff --git a/spec/system/instructeurs/batch_operation_spec.rb b/spec/system/instructeurs/batch_operation_spec.rb index 0f3938753..6b5ba7ab9 100644 --- a/spec/system/instructeurs/batch_operation_spec.rb +++ b/spec/system/instructeurs/batch_operation_spec.rb @@ -99,8 +99,6 @@ describe 'BatchOperation a dossier:', js: true do expect(page).to have_content('3 dossiers sont sélectionnés. Effacer la sélection ') expect(find_field("batch_operation[dossier_ids][]", type: :hidden).value).to eq "#{dossier_3.id},#{dossier_2.id},#{dossier_1.id}" - - # click on delete link empty checkbox value and hide notice click_on("Effacer la sélection") expect(page).to have_selector('.fr-notice', visible: false)