Skip to content

Commit

Permalink
revert champ on exported_column
Browse files Browse the repository at this point in the history
  • Loading branch information
LeSim committed Nov 20, 2024
1 parent 02812bc commit 8653c7f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
3 changes: 1 addition & 2 deletions app/models/exported_column.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ def initialize(column:, libelle:)
def id = { id: column.id, libelle: }.to_json

def libelle_with_value(champ_or_dossier, format:)
raw_value = champ_or_dossier.present? ? @column.value(champ_or_dossier) : nil
[libelle, ExportedColumnFormatter.format(column:, raw_value:, format:), spreadsheet_architect_type]
[libelle, ExportedColumnFormatter.format(column:, champ_or_dossier:, format:), spreadsheet_architect_type]
end

def spreadsheet_architect_type
Expand Down
8 changes: 4 additions & 4 deletions app/services/exported_column_formatter.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# frozen_string_literal: true

class ExportedColumnFormatter
def self.format(column:, raw_value:, format:)
return if raw_value.nil?
def self.format(column:, champ_or_dossier:, format:)
return if champ_or_dossier.nil?

raw_value = column.value(champ_or_dossier)

case column.type
when :boolean
Expand All @@ -13,8 +15,6 @@ def self.format(column:, raw_value:, format:)
format_enum(column:, raw_value:)
when :enums
format_enums(column:, raw_values: raw_value)
when :datetime, :date
I18n.l(raw_value)
else
raw_value
end
Expand Down

0 comments on commit 8653c7f

Please sign in to comment.