From 3fc7b57b8c3436d745763cec36515ef9c887d34f Mon Sep 17 00:00:00 2001 From: Christophe Robillard Date: Thu, 11 Feb 2021 15:32:00 +0100 Subject: [PATCH] rend accessible la personnalisation des filtres instructeurs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit en remplaçant select2 par ComboMultipleDropdownList --- app/controllers/instructeurs/procedures_controller.rb | 2 +- app/views/instructeurs/procedures/show.html.haml | 8 ++++---- spec/features/instructeurs/procedure_filters_spec.rb | 6 ++---- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/app/controllers/instructeurs/procedures_controller.rb b/app/controllers/instructeurs/procedures_controller.rb index e389ab07d..8e780b5e3 100644 --- a/app/controllers/instructeurs/procedures_controller.rb +++ b/app/controllers/instructeurs/procedures_controller.rb @@ -138,7 +138,7 @@ module Instructeurs end def update_displayed_fields - procedure_presentation.update_displayed_fields(params[:values]) + procedure_presentation.update_displayed_fields(JSON.parse(params[:values])) redirect_back(fallback_location: instructeur_procedure_url(procedure)) end diff --git a/app/views/instructeurs/procedures/show.html.haml b/app/views/instructeurs/procedures/show.html.haml index 6f59875bf..bae011e94 100644 --- a/app/views/instructeurs/procedures/show.html.haml +++ b/app/views/instructeurs/procedures/show.html.haml @@ -122,10 +122,10 @@ Personnaliser #custom-menu.dropdown-content.fade-in-down = form_tag update_displayed_fields_instructeur_procedure_path(@procedure), method: :patch, class: 'dropdown-form columns-form' do - = select_tag :values, - options_for_select(@displayed_fields_options, selected: @displayed_fields_selected), - multiple: true, - class: 'select2-limited' + - hidden_field_id = SecureRandom.uuid + = hidden_field_tag :values, nil, data: { uuid: hidden_field_id } + = react_component("ComboMultipleDropdownList", options: @displayed_fields_options, selected: @displayed_fields_selected, disabled: [], hiddenFieldId: hidden_field_id, label: 'colonne') + = submit_tag "Enregistrer", class: 'button' %tbody diff --git a/spec/features/instructeurs/procedure_filters_spec.rb b/spec/features/instructeurs/procedure_filters_spec.rb index faaa5f9b4..2e3ab6519 100644 --- a/spec/features/instructeurs/procedure_filters_spec.rb +++ b/spec/features/instructeurs/procedure_filters_spec.rb @@ -125,15 +125,13 @@ feature "procedure filters" do def add_column(column_name) click_on 'Personnaliser' - find("span.select2-container").click - find(:xpath, "//li[text()='#{column_name}']").click + select_multi('colonne', column_name) click_button "Enregistrer" end def remove_column(column_name) click_on 'Personnaliser' - find(:xpath, "//li[contains(@title, '#{column_name}')]/span[contains(text(), '×')]").click - find(:xpath, "//form[contains(@class, 'columns-form')]//span[contains(@class, 'select2-container')]").click + find(:xpath, "//li[contains(text(), '#{column_name}')]/span[contains(text(), 'x')]").click click_button "Enregistrer" end end