From bcca3ea159d11b0fb4709a689a8b6e5b34689e26 Mon Sep 17 00:00:00 2001 From: Giulia Ghisini <51911425+giuliaghisini@users.noreply.github.com> Date: Mon, 17 Jun 2024 10:01:26 +0200 Subject: [PATCH] feat: CartellaModulistica view improvements (#687) * feat: cartella modulistica - mostra ricerca in testata con flag nel content-type * feat: higlight search in CartellaModulistica * feat: expand item if searchableText is setted * fix: removed debug * feat: handle non_collassare_gli_elementi * fix: docrow link * feat: display Pagemetadata in CartellaModulistica if show_modified field is setted --- .../CartellaModulisticaView.jsx | 32 ++++- .../View/CartellaModulisticaView/DocRow.jsx | 134 ++++++++++++------ .../Views/_cartellaModulistica.scss | 19 ++- 3 files changed, 134 insertions(+), 51 deletions(-) diff --git a/src/components/ItaliaTheme/View/CartellaModulisticaView/CartellaModulisticaView.jsx b/src/components/ItaliaTheme/View/CartellaModulisticaView/CartellaModulisticaView.jsx index 1b7eb730f..5ad0f75c5 100644 --- a/src/components/ItaliaTheme/View/CartellaModulisticaView/CartellaModulisticaView.jsx +++ b/src/components/ItaliaTheme/View/CartellaModulisticaView/CartellaModulisticaView.jsx @@ -108,7 +108,9 @@ const CartellaModulisticaView = ({ content }) => { {/* -------SEARCH------- */} - + {content?.ricerca_in_testata && ( + + )} {modulistica.length > 0 && (
@@ -136,13 +138,23 @@ const CartellaModulisticaView = ({ content }) => { ); } else { - return ; + return ( + + ); } })} @@ -155,18 +167,24 @@ const CartellaModulisticaView = ({ content }) => { items={ section.items ? section.items.filter(filterItemsFN) : [] } + searchableText={searchableText} + collapsable={!content.non_collassare_gli_elementi} /> ) : (
{/*file,immagine,link*/} - +
); })}
)} - + {content.show_modified && } diff --git a/src/components/ItaliaTheme/View/CartellaModulisticaView/DocRow.jsx b/src/components/ItaliaTheme/View/CartellaModulisticaView/DocRow.jsx index 569b900de..d2cea39ae 100644 --- a/src/components/ItaliaTheme/View/CartellaModulisticaView/DocRow.jsx +++ b/src/components/ItaliaTheme/View/CartellaModulisticaView/DocRow.jsx @@ -3,13 +3,16 @@ * @module components/theme/View/DocRow */ -import React, { useState } from 'react'; +import React, { useState, useEffect } from 'react'; +import cx from 'classnames'; +import { v4 as uuid } from 'uuid'; +import Highlighter from 'react-highlight-words'; + import { UniversalLink } from '@plone/volto/components'; import { flattenToAppURL } from '@plone/volto/helpers'; import { DownloadFileFormat } from 'design-comuni-plone-theme/components/ItaliaTheme/View'; import { FontAwesomeIcon } from 'design-comuni-plone-theme/components/ItaliaTheme'; import { Icon } from 'design-comuni-plone-theme/components/ItaliaTheme'; -import cx from 'classnames'; /** * DocRow view component class. @@ -18,13 +21,18 @@ import cx from 'classnames'; * @returns {string} Markup of the component. */ -const Downloads = ({ item, titleDoc }) => { +const Downloads = ({ item, titleDoc, filteredWords }) => { return item['@type'] === 'Modulo' ? ( - {!titleDoc ? ( -
{item.title}
- ) : ( - titleDoc !== item.title &&
{item.title}
+ {(!titleDoc || titleDoc !== item.title) && ( +
+ +
)}
@@ -33,24 +41,54 @@ const Downloads = ({ item, titleDoc }) => {
) : ( - -
{item.title}
- -
+ <> +
+ + + +
+
+ + + +
+ ); }; -const DocRow = ({ doc, items }) => { - const [itemOpen, setItemOpen] = useState(false); +const DocRow = ({ doc, items, searchableText, collapsable }) => { + const filteredWords = searchableText.split(' '); + const id = uuid(); + + const [itemOpen, setItemOpen] = useState(!collapsable); + + useEffect(() => { + //se ho fatto una ricerca, espando l'elemento + if (collapsable) { + if (searchableText?.length > 0) { + setItemOpen(true); + } else { + setItemOpen(false); + } + } + }, [searchableText, collapsable]); const titleWrapper = (
{ >
- {doc.title} + {doc?.description && (

{doc.description}

@@ -85,7 +128,11 @@ const DocRow = ({ doc, items }) => { {items?.length === 1 && (
{titleWrapper} - +
)} @@ -96,23 +143,26 @@ const DocRow = ({ doc, items }) => {
{titleWrapper}
- + {collapsable && ( + + )}
{
{items.map((modulo) => (
- +
))}
diff --git a/theme/ItaliaTheme/Views/_cartellaModulistica.scss b/theme/ItaliaTheme/Views/_cartellaModulistica.scss index 5033a4cd9..658b60e26 100644 --- a/theme/ItaliaTheme/Views/_cartellaModulistica.scss +++ b/theme/ItaliaTheme/Views/_cartellaModulistica.scss @@ -16,6 +16,11 @@ $docs-section-margin: 3em; } } + mark.highlighted-text { + padding: 0.2rem 0; + background-color: $highlight-search; + } + section.modulistica { .documents-section, .document-row-section { @@ -52,6 +57,7 @@ $docs-section-margin: 3em; &.has-children { padding-bottom: 1em; } + .description { font-size: 0.9rem; } @@ -68,10 +74,12 @@ $docs-section-margin: 3em; &.single-row { max-width: 70%; } + .title { font-size: 1.2em; font-weight: 500; } + p.description { margin: 0; } @@ -102,10 +110,9 @@ $docs-section-margin: 3em; } a.modulistica-link { - display: flex; - width: 100%; - align-items: center; - justify-content: space-between; + .external-link { + display: none; + } svg { width: 2em; @@ -124,6 +131,7 @@ $docs-section-margin: 3em; color: $secondary; font-size: 1rem; } + button { padding: 0 0.4em; border: none; @@ -135,6 +143,7 @@ $docs-section-margin: 3em; } } } + .accordion-content { overflow: hidden; height: auto; @@ -186,11 +195,13 @@ $docs-section-margin: 3em; flex-wrap: wrap; align-items: unset; justify-content: unset; + .title-wrap { &.single-row { max-width: none; } } + .title, .downloads { flex: 1 1 100%;