Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional description #24

Merged
merged 6 commits into from
Jan 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,43 @@ All notable changes to this project will be documented in this file. Dates are d

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### [0.9.0](https://github.com/codesyntax/volto-listingadvanced-variation/compare/0.8.0...0.9.0)

- bump [`#21`](https://github.com/codesyntax/volto-listingadvanced-variation/pull/21)

#### [0.8.0](https://github.com/codesyntax/volto-listingadvanced-variation/compare/0.6.0...0.8.0)

> 29 October 2021

- bump version [`#20`](https://github.com/codesyntax/volto-listingadvanced-variation/pull/20)
- Automated release 0.8.0 [`d56196e`](https://github.com/codesyntax/volto-listingadvanced-variation/commit/d56196ebdc29dd300264fa234680ff44b7759a5f)

#### [0.6.0](https://github.com/codesyntax/volto-listingadvanced-variation/compare/0.4.0...0.6.0)

> 29 October 2021

- README fix addons list name [`#19`](https://github.com/codesyntax/volto-listingadvanced-variation/pull/19)
- document the addon installation [`#18`](https://github.com/codesyntax/volto-listingadvanced-variation/pull/18)
- Automated release 0.6.0 [`d61f101`](https://github.com/codesyntax/volto-listingadvanced-variation/commit/d61f101e5dc6ed041f4eedd54971ffeb259066be)
- increase version number [`99a519d`](https://github.com/codesyntax/volto-listingadvanced-variation/commit/99a519de24d309af76ebfbd19022b077071c2d9b)
- version [`c2a3e1f`](https://github.com/codesyntax/volto-listingadvanced-variation/commit/c2a3e1fb10586b026bf8c4e54364337b73c03b15)

#### [0.4.0](https://github.com/codesyntax/volto-listingadvanced-variation/compare/0.3.0...0.4.0)

> 28 October 2021

- Effective date option and image position changes [`#17`](https://github.com/codesyntax/volto-listingadvanced-variation/pull/17)
- add effective date option and some extra options to image position [`b66ab77`](https://github.com/codesyntax/volto-listingadvanced-variation/commit/b66ab779f0caf1d56bc5965caecd1ee3b9d8e192)
- Automated release 0.4.0 [`df8c879`](https://github.com/codesyntax/volto-listingadvanced-variation/commit/df8c8796f6e9c6627bd347dd775e6b5dea727ef3)

#### [0.3.0](https://github.com/codesyntax/volto-listingadvanced-variation/compare/0.0.5...0.3.0)

> 28 October 2021

- bump [`#16`](https://github.com/codesyntax/volto-listingadvanced-variation/pull/16)
- ups [`#15`](https://github.com/codesyntax/volto-listingadvanced-variation/pull/15)
- always minor [`#14`](https://github.com/codesyntax/volto-listingadvanced-variation/pull/14)
- Automated release 0.3.0 [`3ae93dc`](https://github.com/codesyntax/volto-listingadvanced-variation/commit/3ae93dcffa9846b23e8924e12196186f6b859790)

#### [0.0.5](https://github.com/codesyntax/volto-listingadvanced-variation/compare/0.0.4...0.0.5)

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@codesyntax/volto-listingadvanced-variation",
"version": "0.8.0",
"version": "0.9.0",
"description": "volto-listingadvanced-variation: Volto add-on",
"main": "src/index.js",
"license": "MIT",
Expand Down
19 changes: 12 additions & 7 deletions src/AdvancedListingBlockTemplate.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const AdvancedListingBlockTemplate = ({
howManyColumns,
effectiveDate,
titleTag,
showDescription,
}) => {
let link = null;
let href = linkHref?.[0]?.['@id'] || '';
Expand All @@ -36,15 +37,19 @@ const AdvancedListingBlockTemplate = ({
const hasImage = imageSide !== null;
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 imageGridWidth = oneColumnElement ? 12 : imageWidth ? imageWidth : 2;
const contentGridWidth = oneColumnElement
? 12
: hasImage
? 12 - imageWidth
: 12;
const intl = useIntl();
moment.locale(intl.locale);
return (
<>
<Grid columns={howManyColumns ? howManyColumns : 1} stretched>
{items.map((item) => (
< Grid.Column key={item['@id']} >
<Grid.Column key={item['@id']}>
<ConditionalLink item={item} condition={!isEditMode}>
<Grid columns={columnSize}>
{['up', 'left'].includes(imageSide) && (
Expand Down Expand Up @@ -74,10 +79,10 @@ const AdvancedListingBlockTemplate = ({
) : (
<h3>{item.title ? item.title : item.id}</h3>
)}
{effectiveDate &&
<p>{moment(item.effective).format("L")}</p>
}
<p>{item.description}</p>
{effectiveDate && <p>{moment(item.effective).format('L')}</p>}
{showDescription && item.description && (
<p>{item.description}</p>
)}
</Grid.Column>
{['right', 'down'].includes(imageSide) && (
<Grid.Column width={imageGridWidth}>
Expand Down
24 changes: 18 additions & 6 deletions src/advancedSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import messages from './messages';

export const advancedSchema = (props) => {
const { intl, schema, formData } = props;
const imageWidth = ['right', 'left'].includes(formData.imageSide) ? ['imageWidth'] : [];
const imageWidth = ['right', 'left'].includes(formData.imageSide)
? ['imageWidth']
: [];
return {
...schema,
fieldsets: [
Expand Down Expand Up @@ -32,6 +34,11 @@ export const advancedSchema = (props) => {
title: intl.formatMessage(messages.titleConfiguration),
fields: ['titleTag'],
},
{
id: 'description',
title: intl.formatMessage(messages.descriptionConfiguration),
fields: ['showDescription'],
},
{
id: 'date',
title: intl.formatMessage(messages.dateConfiguration),
Expand Down Expand Up @@ -73,7 +80,6 @@ export const advancedSchema = (props) => {
['left', 'left'],
['right', 'right'],
['down', 'down'],

],
},
titleTag: {
Expand All @@ -87,12 +93,18 @@ export const advancedSchema = (props) => {
[(children) => <h4>{children}</h4>, 'H4'],
],
},
effectiveDate: {
title: intl.formatMessage(messages.dateConfiguration),
showDescription: {
title: intl.formatMessage(messages.descriptionConfigurationTitle),
description: intl.formatMessage(
messages.dateConfigurationDescription,
messages.descriptionConfigurationDescription,
),
type: 'boolean'
type: 'boolean',
default: true,
},
effectiveDate: {
title: intl.formatMessage(messages.dateConfiguration),
description: intl.formatMessage(messages.dateConfigurationDescription),
type: 'boolean',
},
},
};
Expand Down
13 changes: 13 additions & 0 deletions src/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,19 @@ const messages = defineMessages({
id: 'Default HTML tag will be H3',
defaultMessage: 'Default HTML tag will be H3',
},
descriptionConfiguration: {
id: 'description',
defaultMessage: 'Description',
},
descriptionConfigurationTitle: {
id: 'descriptionConfigurationTitle',
defaultMessage: 'Show the description?',
},
descriptionConfigurationDescription: {
id: 'descriptionConfigurationDescription',
defaultMessage: 'If selected, the description will be shown',
},

dateConfiguration: {
id: 'effectiveDate',
defaultMessage: 'effectiveDate',
Expand Down