2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2023-07-03 22:41:46 +02:00
|
|
|
class Dossiers::ChampsRowsShowComponent < ApplicationComponent
|
|
|
|
attr_reader :profile
|
|
|
|
attr_reader :seen_at
|
2023-06-28 09:55:57 +02:00
|
|
|
|
2023-07-03 22:41:46 +02:00
|
|
|
def initialize(champs:, profile:, seen_at:)
|
2024-03-14 15:13:13 +01:00
|
|
|
@champs, @profile, @seen_at = champs, profile, seen_at
|
2023-04-28 10:33:01 +02:00
|
|
|
end
|
|
|
|
|
2024-03-14 15:13:13 +01:00
|
|
|
private
|
2023-06-28 09:55:57 +02:00
|
|
|
|
2024-03-14 15:13:13 +01:00
|
|
|
def updated_at_after_deposer(champ)
|
|
|
|
return if champ.dossier.depose_at.blank?
|
2024-03-18 21:22:14 +01:00
|
|
|
return if champ.new_record?
|
2024-03-14 15:13:13 +01:00
|
|
|
|
|
|
|
if champ.updated_at > champ.dossier.depose_at
|
|
|
|
champ.updated_at
|
|
|
|
end
|
2023-04-28 10:33:01 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def number_with_html_delimiter(num)
|
|
|
|
# we are using the span delimiter that doesn't insert spaces when copying and pasting the number
|
|
|
|
number_with_delimiter(num, delimiter: tag.span(class: 'numbers-delimiter'))
|
|
|
|
end
|
2023-06-28 09:55:57 +02:00
|
|
|
|
|
|
|
def blank_key(champ)
|
2023-07-03 22:41:46 +02:00
|
|
|
key = ".blank_optional"
|
2023-06-28 09:55:57 +02:00
|
|
|
key += "_attachment" if champ.type_de_champ.piece_justificative?
|
|
|
|
|
|
|
|
key
|
|
|
|
end
|
2023-06-29 07:16:39 +02:00
|
|
|
|
|
|
|
def each_champ(&block)
|
2023-07-03 16:50:07 +02:00
|
|
|
@champs.filter { _1.visible? && !_1.exclude_from_view? && !_1.header_section? }.each(&block)
|
2023-06-29 07:16:39 +02:00
|
|
|
end
|
2023-04-28 10:33:01 +02:00
|
|
|
end
|