replace partial by component

This commit is contained in:
Lisa Durand 2023-01-25 11:01:44 +01:00
parent 1a79eb9717
commit 9aa6c55d1f
7 changed files with 27 additions and 12 deletions

View file

@ -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

View file

@ -0,0 +1,7 @@
en:
selected_html: All <span id='dynamic_number'>n</span> 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"

View file

@ -0,0 +1,7 @@
fr:
selected_html: Les <span id='dynamic_number'>n</span> 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"

View file

@ -3,21 +3,19 @@
.fr-notice__body .fr-notice__body
#not_selected #not_selected
%p.fr-notice__title %p.fr-notice__title
Les = t('.selected_html')
%span#dynamic_number n
dossiers de cette page sont sélectionnés.
%a{ :href => "#", data: { action: "batch-operation#onSelectMore", dossiers: @filtered_sorted_ids.first(Instructeurs::ProceduresController::BATCH_SELECTION_LIMIT).join(',') } } %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 - if @dossiers_count <= Instructeurs::ProceduresController::BATCH_SELECTION_LIMIT
= "Sélectionner les #{@dossiers_count} dossiers." = t(".select_all", dossiers_count: @dossiers_count)
- else - 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 #selected.hidden
%p.fr-notice__title %p.fr-notice__title
- if @dossiers_count <= Instructeurs::ProceduresController::BATCH_SELECTION_LIMIT - if @dossiers_count <= Instructeurs::ProceduresController::BATCH_SELECTION_LIMIT
= "#{@dossiers_count} dossiers sont sélectionnés." = t(".selected_all", dossiers_count: @dossiers_count)
- else - 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" } } %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") = hidden_field_tag :"batch_operation[dossier_ids][]", "", form: dom_id(BatchOperation.new), id: dom_id(BatchOperation.new, "checkbox_multiple")

View file

@ -103,7 +103,7 @@
= render batch_operation_component = 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 .fr-table.fr-table--bordered
%table.table.dossiers-table.hoverable %table.table.dossiers-table.hoverable

View file

@ -7,7 +7,6 @@ en:
display_entries: display_entries:
one: Displaying <b>%{count}</b> %{entry_name} one: Displaying <b>%{count}</b> %{entry_name}
other: Displaying <b>all %{count}</b> %{entry_name} other: Displaying <b>all %{count}</b> %{entry_name}
zero: No %{entry_name} found
views: views:
pagination: pagination:
first: "&laquo; First" first: "&laquo; First"

View file

@ -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(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}" 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 delete link empty checkbox value and hide notice
click_on("Effacer la sélection") click_on("Effacer la sélection")
expect(page).to have_selector('.fr-notice', visible: false) expect(page).to have_selector('.fr-notice', visible: false)