refactor(Facet): to column 🚀

This commit is contained in:
mfo 2024-08-19 14:34:36 +02:00
parent b910705353
commit dba6f9b3aa
No known key found for this signature in database
GPG key ID: 7CE3E1F5B794A8EC
22 changed files with 203 additions and 208 deletions

29
app/models/column.rb Normal file
View file

@ -0,0 +1,29 @@
class Column
attr_reader :table, :column, :label, :classname, :virtual, :type, :scope, :value_column, :filterable
def initialize(table:, column:, label: nil, virtual: false, type: :text, value_column: :value, filterable: true, classname: '', scope: '')
@table = table
@column = column
@label = label || I18n.t(column, scope: [:activerecord, :attributes, :procedure_presentation, :fields, table])
@classname = classname
@virtual = virtual
@type = type
@scope = scope
@value_column = value_column
@filterable = filterable
end
def id
"#{table}/#{column}"
end
def ==(other)
other.to_json == to_json
end
def to_json
{
table:, column:, label:, classname:, virtual:, type:, scope:, value_column:, filterable:
}
end
end