demarches-normaliennes/app/models/column.rb
mfo ec9a03ac17
Merge pull request #10693 from mfo/US/filter-by-json-path-3
ETQ instructeur, je peux filtrer par les donnée de champs issues d'API, a commencer par RNA/RNF SIRET
2024-08-21 09:50:47 +00:00

34 lines
955 B
Ruby

class Column
attr_reader :table, :column, :label, :classname, :type, :scope, :value_column, :filterable, :displayable
def initialize(table:, column:, label: nil, type: :text, value_column: :value, filterable: true, displayable: true, classname: '', scope: '', virtual: nil)
@table = table
@column = column
@label = label || I18n.t(column, scope: [:activerecord, :attributes, :procedure_presentation, :fields, table])
@classname = classname
@type = type
@scope = scope
@value_column = value_column
@filterable = filterable
# We need this for backward compatibility
@displayable = virtual ? false : displayable
end
def id
"#{table}/#{column}"
end
def self.make_id(table, column)
"#{table}/#{column}"
end
def ==(other)
other.to_json == to_json
end
def to_json
{
table:, column:, label:, classname:, type:, scope:, value_column:, filterable:, displayable:
}
end
end