diff --git a/src/AdvancedListingBlockTemplate.jsx b/src/AdvancedListingBlockTemplate.jsx index 3cb450c..4366de9 100644 --- a/src/AdvancedListingBlockTemplate.jsx +++ b/src/AdvancedListingBlockTemplate.jsx @@ -7,7 +7,8 @@ import config from '@plone/volto/registry'; import DefaultImageSVG from '@plone/volto/components/manage/Blocks/Listing/default-image.svg'; import { isInternalURL } from '@plone/volto/helpers/Url/Url'; import { Grid, Image } from 'semantic-ui-react'; - +import moment from 'moment'; +import { useIntl } from 'react-intl'; const AdvancedListingBlockTemplate = ({ items, linkTitle, @@ -16,6 +17,7 @@ const AdvancedListingBlockTemplate = ({ imageSide, imageWidth, howManyColumns, + effectiveDate, titleTag, }) => { let link = null; @@ -32,16 +34,21 @@ const AdvancedListingBlockTemplate = ({ const { settings } = config; const hasImage = imageSide !== null; - imageWidth = imageWidth ? imageWidth : 2; + const oneColumnElement = ['up', 'down', null].includes(imageSide); + const columnSize = oneColumnElement ? 1 : 2; + const imageGridWidth = oneColumnElement ? 12 : (imageWidth ? imageWidth : 2); + const contentGridWidth = oneColumnElement ? 12 : (hasImage ? 12 - imageWidth : 12); + const intl = useIntl(); + moment.locale(intl.locale); return ( <> - + {items.map((item) => ( - + < Grid.Column key={item['@id']} > - - {imageSide === 'left' && ( - + + {['up', 'left'].includes(imageSide) && ( + {!item[settings.listingPreviewImageField] && ( )} - + {titleTag ? ( titleTag(item.title ? item.title : item.id) ) : (

{item.title ? item.title : item.id}

)} + {effectiveDate && +

{moment(item.effective).format("L")}

+ }

{item.description}

- {imageSide === 'right' && ( - + {['right', 'down'].includes(imageSide) && ( + {!item[settings.listingPreviewImageField] && ( { - const { intl, schema } = props; - + const { intl, schema, formData } = props; + const imageWidth = ['right', 'left'].includes(formData.imageSide) ? ['imageWidth'] : []; return { ...schema, fieldsets: [ @@ -25,13 +25,18 @@ export const advancedSchema = (props) => { { id: 'image', title: intl.formatMessage(messages.imageConfiguration), - fields: ['imageSide', 'imageWidth'], + fields: ['imageSide', ...imageWidth], }, { id: 'title', title: intl.formatMessage(messages.titleConfiguration), fields: ['titleTag'], }, + { + id: 'date', + title: intl.formatMessage(messages.dateConfiguration), + fields: ['effectiveDate'], + }, ], properties: { ...schema.properties, @@ -64,8 +69,11 @@ export const advancedSchema = (props) => { ), choices: [ [null, 'No image'], - ['right', 'right'], + ['up', 'up'], ['left', 'left'], + ['right', 'right'], + ['down', 'down'], + ], }, titleTag: { @@ -79,6 +87,13 @@ export const advancedSchema = (props) => { [(children) =>

{children}

, 'H4'], ], }, + effectiveDate: { + title: intl.formatMessage(messages.dateConfiguration), + description: intl.formatMessage( + messages.dateConfigurationDescription, + ), + type: 'boolean' + }, }, }; }; diff --git a/src/messages.js b/src/messages.js index c33754f..998d7d9 100644 --- a/src/messages.js +++ b/src/messages.js @@ -44,6 +44,14 @@ const messages = defineMessages({ id: 'Default HTML tag will be H3', defaultMessage: 'Default HTML tag will be H3', }, + dateConfiguration: { + id: 'effectiveDate', + defaultMessage: 'effectiveDate', + }, + dateConfigurationDescription: { + id: 'Show effectiveDate', + defaultMessage: 'Show effectiveDate', + }, }); export default messages;