review(pull/10591#discussion_r1818916426): extract groupe_instructeurs_column and followers_instructeurs_email_column

This commit is contained in:
mfo 2024-10-28 17:38:48 +01:00 committed by simon lehericey
parent 3bed049a29
commit cbb9854f4c
No known key found for this signature in database
GPG key ID: CDE670D827C7B3C5
2 changed files with 30 additions and 28 deletions

View file

@ -40,21 +40,30 @@ module ColumnsConcern
end end
def all_dossier_columns_for_export def all_dossier_columns_for_export
states = [dossier_state_column] columns = [dossier_state_column]
columns.concat([dossier_archived_column])
routing = columns.concat(dossier_dates_columns)
if self.routing_enabled? columns.concat([dossier_motivation_column])
[Column.new(procedure_id: id, table: 'groupe_instructeur', column: 'id')] columns.concat(sva_svr_columns(for_export: true)) if sva_svr_enabled?
else columns.concat([groupe_instructeurs_id_column])
[] columns.concat([followers_instructeurs_email_column])
columns.flatten.compact
end end
instructeurs = [Column.new(procedure_id: id, table: 'followers_instructeurs', column: 'email')] def dossier_columns
dossier_columns = [dossier_id_column, notifications_column]
[states, dossier_archived_column, dossier_dates_columns, dossier_motivation_column, sva_svr_columns(for_export: true), routing, instructeurs].flatten.compact dossier_columns.concat([dossier_state_column])
dossier_columns.concat([dossier_archived_column])
dossier_columns.concat(dossier_dates_columns)
dossier_columns.concat([dossier_motivation_column])
dossier_columns.concat(sva_svr_columns(for_export: false)) if sva_svr_enabled?
dossier_columns.concat(dossier_non_displayable_dates_columns)
dossier_columns.flatten.compact
end end
#### def groupe_instructeurs_id_column = Column.new(procedure_id: id, table: 'groupe_instructeur', column: 'id', type: :enum)
def followers_instructeurs_email_column = Column.new(procedure_id: id, table: 'followers_instructeurs', column: 'email')
def dossier_archived_column = Column.new(procedure_id: id, table: 'self', column: 'archived', type: :text, displayable: false, filterable: false); def dossier_archived_column = Column.new(procedure_id: id, table: 'self', column: 'archived', type: :text, displayable: false, filterable: false);
@ -75,15 +84,9 @@ module ColumnsConcern
.map { |column| Column.new(procedure_id: id, table: 'procedure', column:, displayable: false, filterable: false) } .map { |column| Column.new(procedure_id: id, table: 'procedure', column:, displayable: false, filterable: false) }
end end
def dossier_columns def dossier_non_displayable_dates_columns
common = [dossier_id_column, notifications_column] ['updated_since', 'depose_since', 'en_construction_since', 'en_instruction_since', 'processed_since']
states = [dossier_state_column]
non_displayable_dates = ['updated_since', 'depose_since', 'en_construction_since', 'en_instruction_since', 'processed_since']
.map { |column| Column.new(procedure_id: id, table: 'self', column:, type: :date, displayable: false) } .map { |column| Column.new(procedure_id: id, table: 'self', column:, type: :date, displayable: false) }
[common, states, dossier_archived_column, dossier_dates_columns, dossier_motivation_column, sva_svr_columns(for_export: false), non_displayable_dates].flatten.compact
end end
def dossier_dates_columns def dossier_dates_columns
@ -92,8 +95,6 @@ module ColumnsConcern
end end
def sva_svr_columns(for_export: false) def sva_svr_columns(for_export: false)
return if !sva_svr_enabled?
scope = [:activerecord, :attributes, :procedure_presentation, :fields, :self] scope = [:activerecord, :attributes, :procedure_presentation, :fields, :self]
columns = [ columns = [
@ -123,8 +124,8 @@ module ColumnsConcern
[ [
email_column, email_column,
user_email_for_display_column, user_email_for_display_column,
Column.new(procedure_id: id, table: 'followers_instructeurs', column: 'email'), followers_instructeurs_email_column,
Column.new(procedure_id: id, table: 'groupe_instructeur', column: 'id', type: :enum), groupe_instructeurs_id_column,
Column.new(procedure_id: id, table: 'avis', column: 'question_answer', filterable: false), Column.new(procedure_id: id, table: 'avis', column: 'question_answer', filterable: false),
Column.new(procedure_id: id, table: 'user', column: 'id', filterable: false, displayable: false), Column.new(procedure_id: id, table: 'user', column: 'id', filterable: false, displayable: false),
user_france_connected_column user_france_connected_column

View file

@ -34,12 +34,13 @@ class ProcedurePresentation < ApplicationRecord
def filters_name_for(statut) = statut.tr('-', '_').then { "#{_1}_filters" } def filters_name_for(statut) = statut.tr('-', '_').then { "#{_1}_filters" }
def displayed_fields_for_headers def displayed_fields_for_headers
[ columns = [
procedure.dossier_id_column, procedure.dossier_id_column,
*displayed_columns, *displayed_columns,
procedure.dossier_state_column, procedure.dossier_state_column
*procedure.sva_svr_columns
] ]
columns.concat(procedure.sva_svr_columns) if procedure.sva_svr_enabled?
columns
end end
def human_value_for_filter(filtered_column) def human_value_for_filter(filtered_column)