2024-04-29 00:17:15 +02:00
|
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
2018-12-18 11:17:52 +01:00
|
|
|
|
class Champs::RepetitionChamp < Champ
|
2024-08-27 10:29:10 +02:00
|
|
|
|
delegate :libelle_for_export, to: :type_de_champ
|
2018-12-18 11:17:52 +01:00
|
|
|
|
|
|
|
|
|
def rows
|
2024-08-27 10:29:10 +02:00
|
|
|
|
dossier.project_rows_for(type_de_champ)
|
2023-11-28 17:33:29 +01:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def row_ids
|
2024-08-27 10:29:10 +02:00
|
|
|
|
dossier.repetition_row_ids(type_de_champ)
|
2018-12-18 11:17:52 +01:00
|
|
|
|
end
|
|
|
|
|
|
2024-08-27 10:29:10 +02:00
|
|
|
|
def add_row(updated_by:)
|
2024-09-27 15:44:57 +02:00
|
|
|
|
dossier.repetition_add_row(type_de_champ, updated_by:)
|
2019-01-30 16:14:15 +01:00
|
|
|
|
end
|
|
|
|
|
|
2024-08-27 10:29:10 +02:00
|
|
|
|
def remove_row(row_id, updated_by:)
|
|
|
|
|
dossier.repetition_remove_row(type_de_champ, row_id, updated_by:)
|
2024-04-15 15:06:05 +02:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def focusable_input_id
|
|
|
|
|
rows.last&.first&.focusable_input_id
|
|
|
|
|
end
|
|
|
|
|
|
2018-12-18 11:17:52 +01:00
|
|
|
|
def search_terms
|
|
|
|
|
# The user cannot enter any information here so it doesn’t make much sense to search
|
|
|
|
|
end
|
2019-04-03 14:29:30 +02:00
|
|
|
|
|
|
|
|
|
class Row < Hashie::Dash
|
|
|
|
|
property :index
|
2023-11-28 17:33:29 +01:00
|
|
|
|
property :row_id
|
2024-03-15 14:10:12 +01:00
|
|
|
|
property :dossier
|
|
|
|
|
|
|
|
|
|
def dossier_id
|
|
|
|
|
dossier.id.to_s
|
|
|
|
|
end
|
2019-04-03 14:29:30 +02:00
|
|
|
|
|
2019-07-11 10:28:44 +02:00
|
|
|
|
def read_attribute_for_serialization(attribute)
|
|
|
|
|
self[attribute]
|
|
|
|
|
end
|
|
|
|
|
|
2021-10-22 12:18:43 +02:00
|
|
|
|
def spreadsheet_columns(types_de_champ)
|
2019-04-03 14:29:30 +02:00
|
|
|
|
[
|
|
|
|
|
['Dossier ID', :dossier_id],
|
|
|
|
|
['Ligne', :index]
|
2024-03-15 14:10:12 +01:00
|
|
|
|
] + dossier.champs_for_export(types_de_champ, row_id)
|
2019-04-03 14:29:30 +02:00
|
|
|
|
end
|
|
|
|
|
end
|
2018-12-18 11:17:52 +01:00
|
|
|
|
end
|