Merge pull request #10875 from demarches-simplifiees/add_id_to_column_third_part
Utilisation des colonnes dans l'affichage et le filtrage
This commit is contained in:
commit
6862f6c6bd
47 changed files with 1512 additions and 1499 deletions
|
@ -30,7 +30,7 @@ class Dossiers::ExportLinkComponent < ApplicationComponent
|
|||
end
|
||||
|
||||
def export_title(export)
|
||||
if export.procedure_presentation_id.nil?
|
||||
if !export.built_from_procedure_presentation?
|
||||
t(".export_title_everything", export_format: export.format)
|
||||
elsif export.tous?
|
||||
t(".export_title", export_format: export.format, count: export.count)
|
||||
|
|
|
@ -30,7 +30,7 @@ class Instructeurs::ColumnFilterComponent < ApplicationComponent
|
|||
{
|
||||
selected_key: column.present? ? column.id : '',
|
||||
items: filterable_columns_options,
|
||||
name: :column,
|
||||
name: "#{prefix}[id]",
|
||||
id: 'search-filter',
|
||||
'aria-describedby': 'instructeur-filter-combo-label',
|
||||
form: 'filter-component',
|
||||
|
@ -39,13 +39,20 @@ class Instructeurs::ColumnFilterComponent < ApplicationComponent
|
|||
end
|
||||
|
||||
def filterable_columns_options
|
||||
procedure.columns.filter_map do |column|
|
||||
next if column.filterable == false
|
||||
|
||||
[column.label, column.id]
|
||||
end
|
||||
@procedure.columns.filter(&:filterable).map { [_1.label, _1.id] }
|
||||
end
|
||||
|
||||
def current_filter_tags
|
||||
@procedure_presentation.filters_for(@statut).flat_map do
|
||||
[
|
||||
hidden_field_tag("#{prefix}[id]", _1.column.id, id: nil),
|
||||
hidden_field_tag("#{prefix}[filter]", _1.filter, id: nil)
|
||||
]
|
||||
end.reduce(&:concat)
|
||||
end
|
||||
|
||||
def prefix = "#{procedure_presentation.filters_name_for(@statut)}[]"
|
||||
|
||||
private
|
||||
|
||||
def find_type_de_champ(column)
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
= form_tag add_filter_instructeur_procedure_path(procedure), method: :post, class: 'dropdown-form large', id: 'filter-component', data: { turbo: true, controller: 'autosubmit' } do
|
||||
= current_filter_tags
|
||||
|
||||
.fr-select-group
|
||||
= label_tag :column, t('.column'), class: 'fr-label fr-m-0', id: 'instructeur-filter-combo-label', for: 'search-filter'
|
||||
%react-fragment
|
||||
|
@ -8,9 +10,9 @@
|
|||
|
||||
= label_tag :value, t('.value'), for: 'value', class: 'fr-label'
|
||||
- if column_type == :enum
|
||||
= select_tag :value, options_for_select(options_for_select_of_column), id: 'value', name: 'value', class: 'fr-select', data: { no_autosubmit: true }
|
||||
= select_tag :filter, options_for_select(options_for_select_of_column), id: 'value', name: "#{prefix}[filter]", class: 'fr-select', data: { no_autosubmit: true }
|
||||
- else
|
||||
%input#value.fr-input{ type: column_type, name: :value, maxlength: ProcedurePresentation::FILTERS_VALUE_MAX_LENGTH, disabled: column.nil? ? true : false, data: { no_autosubmit: true } }
|
||||
%input#value.fr-input{ type: column_type, name: "#{prefix}[filter]", maxlength: FilteredColumn::FILTERS_VALUE_MAX_LENGTH, disabled: column.nil? ? true : false, data: { no_autosubmit: true } }
|
||||
|
||||
= hidden_field_tag :statut, statut
|
||||
= submit_tag t('.add_filter'), class: 'fr-btn fr-btn--secondary fr-mt-2w'
|
||||
|
|
|
@ -12,7 +12,7 @@ class Instructeurs::ColumnPickerComponent < ApplicationComponent
|
|||
def displayable_columns_for_select
|
||||
[
|
||||
procedure.columns.filter(&:displayable).map { |column| [column.label, column.id] },
|
||||
procedure_presentation.displayed_fields.map { Column.new(**_1.deep_symbolize_keys.merge(procedure_id: procedure.id)).id }
|
||||
procedure_presentation.displayed_columns.map(&:id)
|
||||
]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,6 +9,12 @@ class Instructeurs::ColumnTableHeaderComponent < ApplicationComponent
|
|||
|
||||
private
|
||||
|
||||
def classname(column)
|
||||
return 'status-col' if column.dossier_state?
|
||||
return 'number-col' if column.type == :number
|
||||
return 'sva-col' if column.column == 'sva_svr_decision_on'
|
||||
end
|
||||
|
||||
def update_sort_path(column)
|
||||
id = column.id
|
||||
order = opposite_order_for(column)
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
- @columns.each do |column|
|
||||
%th{ aria_sort(column), scope: "col", class: column.classname }
|
||||
%th{ aria_sort(column), scope: "col", class: classname(column) }
|
||||
= link_to label_and_arrow(column), update_sort_path(column)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue