parent
1eac6beb51
commit
b97cbd3402
9 changed files with 60 additions and 1 deletions
|
@ -54,6 +54,10 @@ class Champ < ApplicationRecord
|
|||
value
|
||||
end
|
||||
|
||||
def for_tag
|
||||
value.present? ? value.to_s : ''
|
||||
end
|
||||
|
||||
def main_value_name
|
||||
:value
|
||||
end
|
||||
|
|
|
@ -9,6 +9,10 @@ class Champs::DateChamp < Champ
|
|||
value.present? ? I18n.l(Date.parse(value)) : ""
|
||||
end
|
||||
|
||||
def for_tag
|
||||
value.present? ? I18n.l(Date.parse(value)) : ""
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def format_before_save
|
||||
|
|
|
@ -9,6 +9,10 @@ class Champs::DatetimeChamp < Champ
|
|||
value.present? ? I18n.l(Time.zone.parse(value)) : ""
|
||||
end
|
||||
|
||||
def for_tag
|
||||
value.present? ? I18n.l(Time.zone.parse(value)) : ""
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def format_before_save
|
||||
|
|
|
@ -33,6 +33,10 @@ class Champs::LinkedDropDownListChamp < Champ
|
|||
value.present? ? [primary_value, secondary_value].filter(&:present?).join(' / ') : ""
|
||||
end
|
||||
|
||||
def for_tag
|
||||
value.present? ? [primary_value, secondary_value].filter(&:present?).join(' / ') : ""
|
||||
end
|
||||
|
||||
def for_export
|
||||
value.present? ? "#{primary_value || ''};#{secondary_value || ''}" : nil
|
||||
end
|
||||
|
|
|
@ -13,6 +13,10 @@ class Champs::MultipleDropDownListChamp < Champ
|
|||
selected_options.join(', ')
|
||||
end
|
||||
|
||||
def for_tag
|
||||
selected_options.join(', ')
|
||||
end
|
||||
|
||||
def for_export
|
||||
value.present? ? selected_options.join(', ') : nil
|
||||
end
|
||||
|
|
|
@ -19,6 +19,14 @@ class Champs::RepetitionChamp < Champ
|
|||
# The user cannot enter any information here so it doesn’t make much sense to search
|
||||
end
|
||||
|
||||
def for_tag
|
||||
([libelle] + rows.map do |champs|
|
||||
champs.map do |champ|
|
||||
"#{champ.libelle} : #{champ}"
|
||||
end.join("\n")
|
||||
end).join("\n\n")
|
||||
end
|
||||
|
||||
def rows_for_export
|
||||
rows.each.with_index(1).map do |champs, index|
|
||||
Champs::RepetitionChamp::Row.new(index: index, dossier_id: dossier_id.to_s, champs: champs)
|
||||
|
|
|
@ -9,6 +9,10 @@ class Champs::YesNoChamp < Champ
|
|||
processed_value
|
||||
end
|
||||
|
||||
def for_tag
|
||||
processed_value
|
||||
end
|
||||
|
||||
def for_export
|
||||
processed_value
|
||||
end
|
||||
|
|
|
@ -14,7 +14,7 @@ class TypesDeChamp::TypeDeChampBase
|
|||
libelle: libelle,
|
||||
description: description,
|
||||
lambda: -> (champs) {
|
||||
champs.find { |champ| champ.type_de_champ == tdc }
|
||||
champs.find { |champ| champ.type_de_champ == tdc }&.for_tag
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
@ -114,6 +114,33 @@ describe TagsSubstitutionConcern, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
context 'when the procedure has a type de champ repetition' do
|
||||
let(:template) { '--Répétition--' }
|
||||
let(:types_de_champ) do
|
||||
[
|
||||
create(:type_de_champ_repetition, libelle: 'Répétition', types_de_champ: [
|
||||
create(:type_de_champ_text, libelle: 'Nom'),
|
||||
create(:type_de_champ_text, libelle: 'Prénom')
|
||||
])
|
||||
]
|
||||
end
|
||||
|
||||
before do
|
||||
repetition = dossier.champs
|
||||
.find { |champ| champ.libelle == 'Répétition' }
|
||||
repetition.add_row(1)
|
||||
paul_champs, pierre_champs = repetition.rows
|
||||
|
||||
paul_champs.first.update(value: 'Paul')
|
||||
paul_champs.last.update(value: 'Chavard')
|
||||
|
||||
pierre_champs.first.update(value: 'Pierre')
|
||||
pierre_champs.last.update(value: 'de La Morinerie')
|
||||
end
|
||||
|
||||
it { is_expected.to eq("Répétition\n\nNom : Paul\nPrénom : Chavard\n\nNom : Pierre\nPrénom : de La Morinerie") }
|
||||
end
|
||||
|
||||
context 'when the procedure has a linked drop down menus type de champ' do
|
||||
let(:type_de_champ) do
|
||||
create(:type_de_champ_linked_drop_down_list, libelle: 'libelle')
|
||||
|
|
Loading…
Reference in a new issue