refactor(attestation): hide libelle of empty repetitions

This commit is contained in:
Colin Darie 2024-09-04 17:32:21 +02:00
parent 9f9720d65b
commit 247bb6f8c6
No known key found for this signature in database
GPG key ID: 4FB865FDBCA4BCC4
4 changed files with 33 additions and 5 deletions

View file

@ -181,11 +181,17 @@
.tdc-repetition li {
margin-bottom: 5mm;
padding-left: 3mm;
dl {
display: grid;
grid-template-columns: auto 1fr;
gap: 1mm 5mm;
gap: 1mm 10mm;
}
.invisible {
visibility: hidden;
height: 0;
}
}
}

View file

@ -31,13 +31,14 @@ class ChampPresentations::RepetitionPresentation < ChampPresentations::BasePrese
[
{
type: 'descriptionTerm',
attrs: champ.blank? ? { class: 'invisible' } : nil, # still render libelle so width & alignment are preserved
content: [
{
type: 'text',
text: champ.libelle
}
]
},
}.compact,
{
type: 'descriptionDetails',
content: [

View file

@ -85,8 +85,8 @@ class TiptapService
"<li>#{children(content, substitutions, level + 1)}</li>"
in type: 'descriptionList', content:
"<dl>#{children(content, substitutions, level + 1)}</dl>"
in type: 'descriptionTerm', content:
"<dt>#{children(content, substitutions, level + 1)}</dt>"
in type: 'descriptionTerm', content:, **rest
"<dt#{class_list(rest[:attrs])}>#{children(content, substitutions, level + 1)}</dt>"
in type: 'descriptionDetails', content:
"<dd>#{children(content, substitutions, level + 1)}</dd>"
in type: 'text', text:, **rest

View file

@ -21,6 +21,9 @@ describe ChampPresentations::RepetitionPresentation do
nom.update(value: "ruby")
stars.update(value: 5)
nom, stars = dossier.champs[0].add_row(dossier.procedure.active_revision)
nom.update(value: "js")
nom, stars = dossier.champs[0].add_row(dossier.procedure.active_revision)
nom.update(value: "rust")
stars.update(value: 4)
@ -37,6 +40,9 @@ describe ChampPresentations::RepetitionPresentation do
nom : ruby
stars : 5
nom : js
stars :#{' '}
nom : rust
stars : 4
TXT
@ -63,7 +69,22 @@ describe ChampPresentations::RepetitionPresentation do
]
}
]
}, {
},
{
type: "listItem",
content: [
{
type: "descriptionList",
content: [
{ content: [{ text: "nom", type: "text" }], type: "descriptionTerm" },
{ content: [{ text: "js", type: "text" }], type: "descriptionDetails" },
{ content: [{ text: "stars", type: "text" }], type: "descriptionTerm", attrs: { class: "invisible" } },
{ content: [{ text: "", type: "text" }], type: "descriptionDetails" }
]
}
]
},
{
type: "listItem",
content: [
{