diff --git a/app/components/dossiers/instructeur_filter_component.rb b/app/components/instructeurs/column_filter_component.rb similarity index 95% rename from app/components/dossiers/instructeur_filter_component.rb rename to app/components/instructeurs/column_filter_component.rb index 66796b4da..7a2b40e6c 100644 --- a/app/components/dossiers/instructeur_filter_component.rb +++ b/app/components/instructeurs/column_filter_component.rb @@ -1,4 +1,4 @@ -class Dossiers::InstructeurFilterComponent < ApplicationComponent +class Instructeurs::ColumnFilterComponent < ApplicationComponent attr_reader :procedure, :procedure_presentation, :statut, :facet def initialize(procedure:, procedure_presentation:, statut:, facet: nil) diff --git a/app/components/dossiers/instructeur_filter_component/instructeur_filter_component.en.yml b/app/components/instructeurs/column_filter_component/column_filter_component.en.yml similarity index 100% rename from app/components/dossiers/instructeur_filter_component/instructeur_filter_component.en.yml rename to app/components/instructeurs/column_filter_component/column_filter_component.en.yml diff --git a/app/components/dossiers/instructeur_filter_component/instructeur_filter_component.fr.yml b/app/components/instructeurs/column_filter_component/column_filter_component.fr.yml similarity index 100% rename from app/components/dossiers/instructeur_filter_component/instructeur_filter_component.fr.yml rename to app/components/instructeurs/column_filter_component/column_filter_component.fr.yml diff --git a/app/components/dossiers/instructeur_filter_component/instructeur_filter_component.html.haml b/app/components/instructeurs/column_filter_component/column_filter_component.html.haml similarity index 100% rename from app/components/dossiers/instructeur_filter_component/instructeur_filter_component.html.haml rename to app/components/instructeurs/column_filter_component/column_filter_component.html.haml diff --git a/app/components/dossiers/instructeur_facet_picker_component.rb b/app/components/instructeurs/column_picker_component.rb similarity index 88% rename from app/components/dossiers/instructeur_facet_picker_component.rb rename to app/components/instructeurs/column_picker_component.rb index 0b2b25a0f..b609167db 100644 --- a/app/components/dossiers/instructeur_facet_picker_component.rb +++ b/app/components/instructeurs/column_picker_component.rb @@ -1,4 +1,4 @@ -class Dossiers::InstructeurFacetPickerComponent < ApplicationComponent +class Instructeurs::ColumnPickerComponent < ApplicationComponent attr_reader :procedure, :procedure_presentation def initialize(procedure:, procedure_presentation:) diff --git a/app/components/dossiers/instructeur_facet_picker_component/instructeur_facet_picker_component.en.yml b/app/components/instructeurs/column_picker_component/column_picker_component.en.yml similarity index 100% rename from app/components/dossiers/instructeur_facet_picker_component/instructeur_facet_picker_component.en.yml rename to app/components/instructeurs/column_picker_component/column_picker_component.en.yml diff --git a/app/components/dossiers/instructeur_facet_picker_component/instructeur_facet_picker_component.fr.yml b/app/components/instructeurs/column_picker_component/column_picker_component.fr.yml similarity index 100% rename from app/components/dossiers/instructeur_facet_picker_component/instructeur_facet_picker_component.fr.yml rename to app/components/instructeurs/column_picker_component/column_picker_component.fr.yml diff --git a/app/components/dossiers/instructeur_facet_picker_component/instructeur_facet_picker_component.html.haml b/app/components/instructeurs/column_picker_component/column_picker_component.html.haml similarity index 100% rename from app/components/dossiers/instructeur_facet_picker_component/instructeur_facet_picker_component.html.haml rename to app/components/instructeurs/column_picker_component/column_picker_component.html.haml diff --git a/app/views/instructeurs/procedures/_dossiers_filter_dropdown.html.haml b/app/views/instructeurs/procedures/_dossiers_filter_dropdown.html.haml index 3cd95da34..e301a5c53 100644 --- a/app/views/instructeurs/procedures/_dossiers_filter_dropdown.html.haml +++ b/app/views/instructeurs/procedures/_dossiers_filter_dropdown.html.haml @@ -3,4 +3,4 @@ = t('views.instructeurs.dossiers.filters.title') - menu.with_form do - = render Dossiers::InstructeurFilterComponent.new(procedure:, procedure_presentation: @procedure_presentation, statut:) + = render Instructeurs::ColumnFilterComponent.new(procedure:, procedure_presentation: @procedure_presentation, statut:) diff --git a/app/views/instructeurs/procedures/show.html.haml b/app/views/instructeurs/procedures/show.html.haml index e87989352..69e33b9cf 100644 --- a/app/views/instructeurs/procedures/show.html.haml +++ b/app/views/instructeurs/procedures/show.html.haml @@ -109,7 +109,7 @@ - menu.with_button_inner_html do = t('views.instructeurs.dossiers.personalize') - menu.with_form do - = render Dossiers::InstructeurFacetPickerComponent.new(procedure: @procedure, procedure_presentation: @procedure_presentation) + = render Instructeurs::ColumnPickerComponent.new(procedure: @procedure, procedure_presentation: @procedure_presentation) %tbody = render Dossiers::BatchSelectMoreComponent.new(dossiers_count: @dossiers_count, filtered_sorted_ids: @filtered_sorted_ids) diff --git a/app/views/instructeurs/procedures/update_filter.turbo_stream.haml b/app/views/instructeurs/procedures/update_filter.turbo_stream.haml index 4d88e0852..20127f210 100644 --- a/app/views/instructeurs/procedures/update_filter.turbo_stream.haml +++ b/app/views/instructeurs/procedures/update_filter.turbo_stream.haml @@ -1,2 +1,2 @@ = turbo_stream.replace 'filter-component' do - = render Dossiers::InstructeurFilterComponent.new(procedure: @procedure, procedure_presentation: @procedure_presentation, statut: @statut, facet: @facet) + = render Instructeurs::ColumnFilterComponent.new(procedure: @procedure, procedure_presentation: @procedure_presentation, statut: @statut, facet: @facet) diff --git a/spec/components/dossiers/instructeur_filter_component_spec.rb b/spec/components/instructeurs/column_filter_component_spec.rb similarity index 96% rename from spec/components/dossiers/instructeur_filter_component_spec.rb rename to spec/components/instructeurs/column_filter_component_spec.rb index f7e9aee3f..98f3f5035 100644 --- a/spec/components/dossiers/instructeur_filter_component_spec.rb +++ b/spec/components/instructeurs/column_filter_component_spec.rb @@ -1,4 +1,4 @@ -describe Dossiers::InstructeurFilterComponent, type: :component do +describe Instructeurs::ColumnFilterComponent, type: :component do let(:component) { described_class.new(procedure:, procedure_presentation:, statut:, facet:) } let(:instructeur) { create(:instructeur) } diff --git a/spec/components/instructeurs/column_picker_component_spec.rb b/spec/components/instructeurs/column_picker_component_spec.rb new file mode 100644 index 000000000..55e5983b1 --- /dev/null +++ b/spec/components/instructeurs/column_picker_component_spec.rb @@ -0,0 +1,24 @@ +describe Instructeurs::ColumnPickerComponent, type: :component do + let(:component) { described_class.new(procedure:, procedure_presentation:) } + + let(:procedure) { create(:procedure) } + let(:instructeur) { create(:instructeur) } + let(:assign_to) { create(:assign_to, procedure: procedure, instructeur: instructeur) } + let(:procedure_presentation) { create(:procedure_presentation, assign_to: assign_to) } + + describe "#displayable_fields_for_select" do + let(:default_user_email) { Facet.new(label: 'email', table: 'user', column: 'email') } + let(:excluded_displayable_field) { Facet.new(label: "label1", table: "table1", column: "column1", virtual: true) } + + subject { component.displayable_fields_for_select } + + before do + allow(Facet).to receive(:facets).and_return([ + default_user_email, + excluded_displayable_field + ]) + end + + it { is_expected.to eq([[["email", "user/email"]], ["user/email"]]) } + end +end