diff --git a/app/assets/stylesheets/attestation.scss b/app/assets/stylesheets/attestation.scss
index e01a9168b..33cb38c48 100644
--- a/app/assets/stylesheets/attestation.scss
+++ b/app/assets/stylesheets/attestation.scss
@@ -178,4 +178,14 @@
bottom: 0;
}
}
+
+ .tdc-repetition li {
+ margin-bottom: 5mm;
+
+ dl {
+ display: grid;
+ grid-template-columns: auto 1fr;
+ gap: 1mm 5mm;
+ }
+ }
}
diff --git a/app/models/champ_presentations/repetition_presentation.rb b/app/models/champ_presentations/repetition_presentation.rb
new file mode 100644
index 000000000..6a9c2bcb6
--- /dev/null
+++ b/app/models/champ_presentations/repetition_presentation.rb
@@ -0,0 +1,58 @@
+# frozen_string_literal: true
+
+class ChampPresentations::RepetitionPresentation
+ attr_reader :libelle
+ attr_reader :rows
+
+ def initialize(libelle, rows)
+ @libelle = libelle
+ @rows = rows
+ end
+
+ def to_s
+ ([libelle] + rows.map do |champs|
+ champs.map do |champ|
+ "#{champ.libelle} : #{champ}"
+ end.join("\n")
+ end).join("\n\n")
+ end
+
+ def to_tiptap_node
+ {
+ type: 'orderedList',
+ attrs: { class: 'tdc-repetition' },
+ content: rows.map do |champs|
+ {
+ type: 'listItem',
+ content: [
+ {
+ type: 'descriptionList',
+ content: champs.map do |champ|
+ [
+ {
+ type: 'descriptionTerm',
+ content: [
+ {
+ type: 'text',
+ text: champ.libelle
+ }
+ ]
+ },
+ {
+ type: 'descriptionDetails',
+ content: [
+ {
+ type: 'text',
+ text: champ.to_s
+ }
+ ]
+ }
+ ]
+ end.flatten
+ }
+ ]
+ }
+ end
+ }
+ end
+end
diff --git a/app/models/champs/repetition_champ.rb b/app/models/champs/repetition_champ.rb
index 1bae90913..7ea9d83cd 100644
--- a/app/models/champs/repetition_champ.rb
+++ b/app/models/champs/repetition_champ.rb
@@ -44,14 +44,6 @@ class Champs::RepetitionChamp < Champ
# The user cannot enter any information here so it doesn’t make much sense to search
end
- def for_tag(path = :value)
- ([libelle] + rows.map do |champs|
- champs.map do |champ|
- "#{champ.libelle} : #{champ}"
- end.join("\n")
- end).join("\n\n")
- end
-
def rows_for_export
row_ids.map.with_index(1) do |row_id, index|
Champs::RepetitionChamp::Row.new(index:, row_id:, dossier:)
diff --git a/app/models/types_de_champ/repetition_type_de_champ.rb b/app/models/types_de_champ/repetition_type_de_champ.rb
index 492cfa0f2..740e572b1 100644
--- a/app/models/types_de_champ/repetition_type_de_champ.rb
+++ b/app/models/types_de_champ/repetition_type_de_champ.rb
@@ -1,6 +1,13 @@
# frozen_string_literal: true
class TypesDeChamp::RepetitionTypeDeChamp < TypesDeChamp::TypeDeChampBase
+ def self.champ_value_for_tag(champ, path = :value)
+ return nil if path != :value
+ return champ_default_value if champ.rows.blank?
+
+ ChampPresentations::RepetitionPresentation.new(champ.libelle, champ.rows)
+ end
+
def estimated_fill_duration(revision)
estimated_rows_in_repetition = 2.5
diff --git a/app/services/tiptap_service.rb b/app/services/tiptap_service.rb
index 6fd0a4e35..a55644353 100644
--- a/app/services/tiptap_service.rb
+++ b/app/services/tiptap_service.rb
@@ -79,10 +79,16 @@ class TiptapService
"
First paragraph
") end end + + context 'ordered list with custom classes' do + let(:json) do + { + type: 'doc', + content: [ + { + type: 'orderedList', + attrs: { class: "my-class" }, + content: [ + { + type: 'listItem', + content: [ + { + type: 'paragraph', + content: [ + { + type: 'text', + text: 'Item 1' + } + ] + } + ] + } + ] + } + ] + } + end + + it "set class attribute" do + expect(described_class.new.to_html(json, substitutions)).to eq('Item 1