From 204f28e21ea13a3381c3315c37b3e6ca91b3e7e3 Mon Sep 17 00:00:00 2001 From: Adrian Schulz Date: Mon, 13 May 2024 15:49:35 +0200 Subject: [PATCH] Introduce start and enddate within SummaryView for Listings including events --- .../manage/Blocks/Listing/SummaryTemplate.jsx | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 frontend/src/addons/volto-plonede/src/customizations/volto/components/manage/Blocks/Listing/SummaryTemplate.jsx diff --git a/frontend/src/addons/volto-plonede/src/customizations/volto/components/manage/Blocks/Listing/SummaryTemplate.jsx b/frontend/src/addons/volto-plonede/src/customizations/volto/components/manage/Blocks/Listing/SummaryTemplate.jsx new file mode 100644 index 0000000..a9de0cf --- /dev/null +++ b/frontend/src/addons/volto-plonede/src/customizations/volto/components/manage/Blocks/Listing/SummaryTemplate.jsx @@ -0,0 +1,54 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import { ConditionalLink, Component, FormattedDate } from '@plone/volto/components'; +import { flattenToAppURL } from '@plone/volto/helpers'; + +import { isInternalURL } from '@plone/volto/helpers/Url/Url'; + +const SummaryTemplate = ({ items, linkTitle, linkHref, isEditMode }) => { + let link = null; + let href = linkHref?.[0]?.['@id'] || ''; + + if (isInternalURL(href)) { + link = ( + + {linkTitle || href} + + ); + } else if (href) { + link = {linkTitle || href}; + } + + return ( + <> +
+ {items.map((item) => ( +
+ + +
+

{item.title || item.id}

+ { + item.start && item.end && ( +

-

+ ) + } +

{item.description}

+
+
+
+ ))} +
+ + {link &&
{link}
} + + ); +}; + +SummaryTemplate.propTypes = { + items: PropTypes.arrayOf(PropTypes.any).isRequired, + linkMore: PropTypes.any, + isEditMode: PropTypes.bool, +}; + +export default SummaryTemplate;