feat(attestation): better presentation of repetition champs
This commit is contained in:
parent
09581ad028
commit
c9956c4881
8 changed files with 244 additions and 10 deletions
58
app/models/champ_presentations/repetition_presentation.rb
Normal file
58
app/models/champ_presentations/repetition_presentation.rb
Normal file
|
@ -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
|
Loading…
Add table
Add a link
Reference in a new issue