-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce start and enddate within SummaryView for Listings including…
… events
- Loading branch information
1 parent
e2661a3
commit 204f28e
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
...lto-plonede/src/customizations/volto/components/manage/Blocks/Listing/SummaryTemplate.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 = ( | ||
<ConditionalLink to={flattenToAppURL(href)} condition={!isEditMode}> | ||
{linkTitle || href} | ||
</ConditionalLink> | ||
); | ||
} else if (href) { | ||
link = <a href={href}>{linkTitle || href}</a>; | ||
} | ||
|
||
return ( | ||
<> | ||
<div className="items"> | ||
{items.map((item) => ( | ||
<div className="listing-item" key={item['@id']}> | ||
<ConditionalLink item={item} condition={!isEditMode}> | ||
<Component componentName="PreviewImage" item={item} alt="" /> | ||
<div className="listing-body"> | ||
<h3>{item.title || item.id}</h3> | ||
{ | ||
item.start && item.end && ( | ||
<p><FormattedDate date={item.start} /> - <FormattedDate date={item.end} /></p> | ||
) | ||
} | ||
<p>{item.description}</p> | ||
</div> | ||
</ConditionalLink> | ||
</div> | ||
))} | ||
</div> | ||
|
||
{link && <div className="footer">{link}</div>} | ||
</> | ||
); | ||
}; | ||
|
||
SummaryTemplate.propTypes = { | ||
items: PropTypes.arrayOf(PropTypes.any).isRequired, | ||
linkMore: PropTypes.any, | ||
isEditMode: PropTypes.bool, | ||
}; | ||
|
||
export default SummaryTemplate; |