From 30fcb75da4248b58558f9764dbfc573dd308d3fd Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Wed, 9 Oct 2024 15:16:13 +0200 Subject: [PATCH] extract dossier_state_column --- app/models/column.rb | 6 +++--- app/models/concerns/columns_concern.rb | 6 +++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/models/column.rb b/app/models/column.rb index b6c6a43d6..c50cb9183 100644 --- a/app/models/column.rb +++ b/app/models/column.rb @@ -33,9 +33,9 @@ class Column } end - def notifications? - table == 'notifications' && column == 'notifications' - end + def notifications? = [table, column] == ['notifications', 'notifications'] + + def dossier_state? = [table, column] == ['self', 'state'] def self.find(h_id) begin diff --git a/app/models/concerns/columns_concern.rb b/app/models/concerns/columns_concern.rb index 2757e7e49..887484ff5 100644 --- a/app/models/concerns/columns_concern.rb +++ b/app/models/concerns/columns_concern.rb @@ -33,6 +33,10 @@ module ColumnsConcern Column.new(procedure_id: id, table: 'self', column: 'id', classname: 'number-col', type: :number) end + def dossier_state_column + Column.new(procedure_id: id, table: 'self', column: 'state', type: :enum, scope: 'instructeurs.dossiers.filterable_state', displayable: false) + end + def notifications_column Column.new(procedure_id: id, table: 'notifications', column: 'notifications', label: "notifications", filterable: false) end @@ -46,7 +50,7 @@ module ColumnsConcern 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) } - states = [Column.new(procedure_id: id, table: 'self', column: 'state', type: :enum, scope: 'instructeurs.dossiers.filterable_state', displayable: false)] + states = [dossier_state_column] [common, dates, sva_svr_columns(for_filters: true), non_displayable_dates, states].flatten.compact end