From b910705353bdb1c9526a05f69c77f6e02d5fe678 Mon Sep 17 00:00:00 2001 From: mfo Date: Mon, 22 Jul 2024 14:47:27 +0200 Subject: [PATCH] move tdc facets builder to tdc --- app/models/concerns/facets_concern.rb | 11 +---------- app/models/types_de_champ/type_de_champ_base.rb | 14 +++++++++++++- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/app/models/concerns/facets_concern.rb b/app/models/concerns/facets_concern.rb index 417ab1d64..44cdfb035 100644 --- a/app/models/concerns/facets_concern.rb +++ b/app/models/concerns/facets_concern.rb @@ -78,16 +78,7 @@ module FacetsConcern .reject { |(type_champ)| type_champ == TypeDeChamp.type_champs.fetch(:repetition) } .flat_map do |(type_champ, libelle, stable_id)| tdc = TypeDeChamp.new(type_champ:, libelle:, stable_id:) - - tdc.dynamic_type.search_paths.map do |path_struct| - Facet.new( - table: TYPE_DE_CHAMP, - column: tdc.stable_id.to_s, - label: path_struct[:libelle], - type: TypeDeChamp.filter_hash_type(tdc.type_champ), - value_column: TypeDeChamp.filter_hash_value_column(type_champ) - ) - end + tdc.dynamic_type.facets(table: TYPE_DE_CHAMP) end end end diff --git a/app/models/types_de_champ/type_de_champ_base.rb b/app/models/types_de_champ/type_de_champ_base.rb index 02570c8d1..cb79b8707 100644 --- a/app/models/types_de_champ/type_de_champ_base.rb +++ b/app/models/types_de_champ/type_de_champ_base.rb @@ -1,7 +1,7 @@ class TypesDeChamp::TypeDeChampBase include ActiveModel::Validations - delegate :description, :libelle, :mandatory, :mandatory?, :stable_id, :fillable?, :public?, to: :@type_de_champ + delegate :description, :libelle, :mandatory, :mandatory?, :stable_id, :fillable?, :public?, :type_champ, to: :@type_de_champ FILL_DURATION_SHORT = 10.seconds FILL_DURATION_MEDIUM = 1.minute @@ -96,6 +96,18 @@ class TypesDeChamp::TypeDeChampBase end end + def facets(table:) + [ + Facet.new( + table:, + column: stable_id.to_s, + label: libelle, + type: TypeDeChamp.filter_hash_type(type_champ), + value_column: TypeDeChamp.filter_hash_value_column(type_champ) + ) + ] + end + private def paths