Skip to content

Commit

Permalink
refactor(dossier): instructeur filter
Browse files Browse the repository at this point in the history
  • Loading branch information
tchak committed May 9, 2024
1 parent f528384 commit ab7d8f8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
14 changes: 13 additions & 1 deletion app/components/dossiers/instructeur_filter_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def initialize(procedure:, procedure_presentation:, statut:, field_id: nil)
attr_reader :procedure, :procedure_presentation, :statut, :field_id

def filterable_fields_for_select
procedure_presentation.filterable_fields_options
procedure_presentation.filterable_fields_options.map { |(label, value)| { label:, value: } }
end

def field_type
Expand All @@ -20,4 +20,16 @@ def field_type
def options_for_select_of_field
procedure_presentation.field_enum(field_id)
end

def filter_react_props
{
default_input_value: @field_id || '',
default_items: filterable_fields_for_select,
name: :field,
id: 'search-filter',
'aria-describedby': 'instructeur-filter-combo-label',
form: 'filter-component',
data: { no_autosubmit: 'input blur', no_autosubmit_on_empty: 'true', autosubmit_target: 'input' }
}
end
end
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
= form_tag add_filter_instructeur_procedure_path(procedure), method: :post, class: 'dropdown-form large', id: 'filter-component', data: { turbo: true, controller: 'autosubmit' } do
.fr-select-group
= label_tag :field, t('.column'), class: 'fr-label fr-m-0', id: 'instructeur-filter-combo-label', for: 'search-filter'
= render Dsfr::ComboboxComponent.new form: nil,
options: filterable_fields_for_select,
selected: field_id,
input_html_options: { name: :field, id: 'search-filter', class: 'fr-select', describedby: 'instructeur-filter-combo-label', allows_custom_value: false, form_id: 'filter-component' },
hidden_html_options: { data: { no_autosubmit: ['input', 'blur'].join(' '), no_autosubmit_on_empty: "true", autosubmit_target: 'input' } }
%react-fragment
= render ReactComponent.new "ComboBox/SingleComboBox", **filter_react_props

%input.hidden{ type: 'submit', formaction: update_filter_instructeur_procedure_path(procedure), data: { autosubmit_target: 'submitter' } }

Expand Down
1 change: 0 additions & 1 deletion app/controllers/instructeurs/procedures_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ def show

@current_filters = current_filters
@displayable_fields_for_select, @displayable_fields_selected = procedure_presentation.displayable_fields_for_select
@filterable_fields_for_select = procedure_presentation.filterable_fields_options
@counts = current_instructeur
.dossiers_count_summary(groupe_instructeur_ids)
.symbolize_keys
Expand Down

0 comments on commit ab7d8f8

Please sign in to comment.