diff --git a/app/components/instructeurs/select_procedure_drop_down_list_component.rb b/app/components/instructeurs/select_procedure_drop_down_list_component.rb new file mode 100644 index 00000000000..f7aa3444cad --- /dev/null +++ b/app/components/instructeurs/select_procedure_drop_down_list_component.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +class Instructeurs::SelectProcedureDropDownListComponent < Dsfr::InputComponent + def initialize(procedures:) + @procedures = procedures + end + + def react_props + { + items:, + placeholder: t('.placeholder'), + name: "procedure_id", + id: 'select-procedure-drop-down-list', + 'aria-describedby': 'select-procedure-drop-down-list-label', + form: 'select-procedure-drop-down-list-component', + data: { no_autosubmit: 'input blur', no_autosubmit_on_empty: 'true', autosubmit_target: 'input' } + } + end + + def items + @procedures.map { ["n°#{_1.id} - #{_1.libelle}", _1.id] } + end +end diff --git a/app/components/instructeurs/select_procedure_drop_down_list_component/select_procedure_drop_down_list_component.en.yml b/app/components/instructeurs/select_procedure_drop_down_list_component/select_procedure_drop_down_list_component.en.yml new file mode 100644 index 00000000000..9df164ad297 --- /dev/null +++ b/app/components/instructeurs/select_procedure_drop_down_list_component/select_procedure_drop_down_list_component.en.yml @@ -0,0 +1,4 @@ +--- +en: + label: Direct access + placeholder: Select a procedure diff --git a/app/components/instructeurs/select_procedure_drop_down_list_component/select_procedure_drop_down_list_component.fr.yml b/app/components/instructeurs/select_procedure_drop_down_list_component/select_procedure_drop_down_list_component.fr.yml new file mode 100644 index 00000000000..a9a63cfa078 --- /dev/null +++ b/app/components/instructeurs/select_procedure_drop_down_list_component/select_procedure_drop_down_list_component.fr.yml @@ -0,0 +1,4 @@ +--- +fr: + label: Accès direct + placeholder: Sélectionner une démarche diff --git a/app/components/instructeurs/select_procedure_drop_down_list_component/select_procedure_drop_down_list_component.html.haml b/app/components/instructeurs/select_procedure_drop_down_list_component/select_procedure_drop_down_list_component.html.haml new file mode 100644 index 00000000000..a56baa44440 --- /dev/null +++ b/app/components/instructeurs/select_procedure_drop_down_list_component/select_procedure_drop_down_list_component.html.haml @@ -0,0 +1,17 @@ += form_with url: url_for([:select_procedure, :instructeur, :procedures]), + class: 'ml-auto', + id: 'select-procedure-drop-down-list-component', + data: { turbo: true, controller: 'autosubmit' } do + + .flex.align-center + = label_tag :procedure_id, t('.label'), class: 'fr-label font-weight-bold fr-mr-2w', id: 'select-procedure-drop-down-list-label', for: 'select-procedure-drop-down-list' + %react-fragment + = render ReactComponent.new "ComboBox/SingleComboBox", **react_props + + %input.hidden{ + type: 'submit', + formmethod: 'get', + formaction: url_for([:select_procedure, :instructeur, :procedures]), + formnovalidate: 'true', + data: { autosubmit_target: 'submitter' } + } diff --git a/app/controllers/instructeurs/procedures_controller.rb b/app/controllers/instructeurs/procedures_controller.rb index 2de480b23e6..5275a3e02dd 100644 --- a/app/controllers/instructeurs/procedures_controller.rb +++ b/app/controllers/instructeurs/procedures_controller.rb @@ -74,6 +74,12 @@ def update_order_positions redirect_to instructeur_procedures_path, notice: "L'ordre des démarches a été mis à jour." end + def select_procedure + return redirect_to instructeur_procedure_path(procedure_id: params[:procedure_id]) if params[:procedure_id].present? + + redirect_to instructeur_procedures_path + end + def show @procedure = procedure # Technically, procedure_presentation already sets the attribute. diff --git a/app/javascript/components/ComboBox.tsx b/app/javascript/components/ComboBox.tsx index 6b9d2d81dd3..eae0e2fa473 100644 --- a/app/javascript/components/ComboBox.tsx +++ b/app/javascript/components/ComboBox.tsx @@ -41,8 +41,12 @@ export function ComboBox({ description, className, inputRef, + placeholder, ...props -}: ComboBoxProps & { inputRef?: RefObject }) { +}: ComboBoxProps & { + inputRef?: RefObject; + placeholder?: string; +}) { return ( ) : null}
- +