small refactors

This commit is contained in:
simon lehericey 2024-07-19 18:03:15 +02:00 committed by mfo
parent 772424ff5e
commit 7a1c25271d
No known key found for this signature in database
GPG key ID: 7CE3E1F5B794A8EC
2 changed files with 6 additions and 5 deletions

View file

@ -1,4 +1,6 @@
class Facet
attr_reader :table, :column, :label, :classname, :virtual, :type, :scope, :value_column, :filterable
TYPE_DE_CHAMP = 'type_de_champ'
def initialize(table:, column:, label: nil, virtual: false, type: :text, value_column: :value, filterable: true, classname: '', scope: '')
@ -13,7 +15,9 @@ class Facet
@filterable = filterable
end
attr_reader :table, :column, :label, :classname, :virtual, :type, :scope, :value_column, :filterable
def id
"#{table}/#{column}"
end
def ==(other)
other.to_json == to_json

View file

@ -236,10 +236,7 @@ class ProcedurePresentation < ApplicationRecord
end
def update_displayed_fields(facet_ids)
if facet_ids.nil?
facet_ids = []
end
facet_ids = Array.wrap(facet_ids)
facets = facet_ids.map { |id| Facet.find(procedure:, id:) }
update!(displayed_fields: facets)