From 50f699f1391e0cfa0a181c6a1deecd4d0462fb3a Mon Sep 17 00:00:00 2001 From: Giulia Ghisini Date: Thu, 30 May 2024 14:09:42 +0200 Subject: [PATCH] feat: handle non_collassare_gli_elementi --- .../CartellaModulisticaView.jsx | 16 +++++-- .../View/CartellaModulisticaView/DocRow.jsx | 46 ++++++++++--------- 2 files changed, 37 insertions(+), 25 deletions(-) diff --git a/src/components/ItaliaTheme/View/CartellaModulisticaView/CartellaModulisticaView.jsx b/src/components/ItaliaTheme/View/CartellaModulisticaView/CartellaModulisticaView.jsx index 153ffa96b..e8db7b74d 100644 --- a/src/components/ItaliaTheme/View/CartellaModulisticaView/CartellaModulisticaView.jsx +++ b/src/components/ItaliaTheme/View/CartellaModulisticaView/CartellaModulisticaView.jsx @@ -138,10 +138,12 @@ const CartellaModulisticaView = ({ content }) => { ); } else { @@ -150,6 +152,7 @@ const CartellaModulisticaView = ({ content }) => { doc={doc} key={doc['@id']} searchableText={searchableText} + collapsable={!content.non_collassare_gli_elementi} /> ); } @@ -165,12 +168,17 @@ const CartellaModulisticaView = ({ content }) => { section.items ? section.items.filter(filterItemsFN) : [] } searchableText={searchableText} + collapsable={!content.non_collassare_gli_elementi} /> ) : (
{/*file,immagine,link*/} - +
); })} diff --git a/src/components/ItaliaTheme/View/CartellaModulisticaView/DocRow.jsx b/src/components/ItaliaTheme/View/CartellaModulisticaView/DocRow.jsx index f85c1714f..806b5d62d 100644 --- a/src/components/ItaliaTheme/View/CartellaModulisticaView/DocRow.jsx +++ b/src/components/ItaliaTheme/View/CartellaModulisticaView/DocRow.jsx @@ -56,19 +56,21 @@ const Downloads = ({ item, titleDoc, filteredWords }) => { ); }; -const DocRow = ({ doc, items, searchableText }) => { +const DocRow = ({ doc, items, searchableText, collapsable }) => { const filteredWords = searchableText.split(' '); - const [itemOpen, setItemOpen] = useState(searchableText?.length > 0 ?? false); + const [itemOpen, setItemOpen] = useState(!collapsable); useEffect(() => { //se ho fatto una ricerca, espando l'elemento - if (searchableText?.length > 0) { - setItemOpen(true); - } else { - setItemOpen(false); + if (collapsable) { + if (searchableText?.length > 0) { + setItemOpen(true); + } else { + setItemOpen(false); + } } - }, [searchableText]); + }, [searchableText, collapsable]); const titleWrapper = (
{
{titleWrapper}
- + {collapsable && ( + + )}