refactor(columns): rename virtual to displayable
This commit is contained in:
parent
8cdd7ef4df
commit
271602082b
6 changed files with 49 additions and 48 deletions
|
@ -1,16 +1,17 @@
|
|||
class Column
|
||||
attr_reader :table, :column, :label, :classname, :virtual, :type, :scope, :value_column, :filterable
|
||||
attr_reader :table, :column, :label, :classname, :type, :scope, :value_column, :filterable, :displayable
|
||||
|
||||
def initialize(table:, column:, label: nil, virtual: false, type: :text, value_column: :value, filterable: true, classname: '', scope: '')
|
||||
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
|
||||
@virtual = virtual
|
||||
@type = type
|
||||
@scope = scope
|
||||
@value_column = value_column
|
||||
@filterable = filterable
|
||||
# We need this for backward compatibility
|
||||
@displayable = virtual ? false : displayable
|
||||
end
|
||||
|
||||
def id
|
||||
|
@ -23,7 +24,7 @@ class Column
|
|||
|
||||
def to_json
|
||||
{
|
||||
table:, column:, label:, classname:, virtual:, type:, scope:, value_column:, filterable:
|
||||
table:, column:, label:, classname:, type:, scope:, value_column:, filterable:, displayable:
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -21,9 +21,9 @@ module ColumnsConcern
|
|||
.map { |column| Column.new(table: 'self', column:, type: :date) }
|
||||
|
||||
virtual_dates = ['updated_since', 'depose_since', 'en_construction_since', 'en_instruction_since', 'processed_since']
|
||||
.map { |column| Column.new(table: 'self', column:, type: :date, virtual: true) }
|
||||
.map { |column| Column.new(table: 'self', column:, type: :date, displayable: false) }
|
||||
|
||||
states = [Column.new(table: 'self', column: 'state', type: :enum, scope: 'instructeurs.dossiers.filterable_state', virtual: true)]
|
||||
states = [Column.new(table: 'self', column: 'state', type: :enum, scope: 'instructeurs.dossiers.filterable_state', displayable: false)]
|
||||
|
||||
[common, dates, sva_svr_columns(for_filters: true), virtual_dates, states].flatten.compact
|
||||
end
|
||||
|
@ -39,7 +39,7 @@ module ColumnsConcern
|
|||
]
|
||||
|
||||
if for_filters
|
||||
columns << Column.new(table: 'self', column: 'sva_svr_decision_before', type: :date, virtual: true,
|
||||
columns << Column.new(table: 'self', column: 'sva_svr_decision_before', type: :date, displayable: false,
|
||||
label: I18n.t("#{sva_svr_decision}_decision_before", scope:))
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue