Skip to content

Commit

Permalink
fix: fixed requiredBlocks config with spread and added controls in Ev…
Browse files Browse the repository at this point in the history
…entView props (#374)
  • Loading branch information
SaraBianchi authored Oct 23, 2023
1 parent c4abcd9 commit f4ec297
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
11 changes: 9 additions & 2 deletions src/components/ItaliaTheme/View/EventoView/EventoCosE.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
richTextHasContent,
Gallery,
} from 'design-comuni-plone-theme/components/ItaliaTheme/View';
import { contentFolderHasItems } from 'design-comuni-plone-theme/helpers';

const messages = defineMessages({
cos_e: {
Expand All @@ -36,7 +37,11 @@ const messages = defineMessages({
const EventoCosE = ({ content }) => {
const intl = useIntl();

return (
return richTextHasContent(content?.descrizione_estesa) ||
contentFolderHasItems(content, 'immagini') ||
contentFolderHasItems(content, 'video') ||
content?.persone_amministrazione?.length > 0 ||
richTextHasContent(content?.descrizione_destinatari) ? (
<RichTextSection
tag_id={'text-body'}
title={intl.formatMessage(messages.cos_e)}
Expand All @@ -48,7 +53,7 @@ const EventoCosE = ({ content }) => {
<h5 className="parteciperanno-section">
{intl.formatMessage(messages.parteciperanno)}
</h5>
{content.persone_amministrazione.map((item, i) => (
{content?.persone_amministrazione?.map((item, i) => (
<UniversalLink
href={flattenToAppURL(item['@id'])}
key={item['@id']}
Expand Down Expand Up @@ -85,6 +90,8 @@ const EventoCosE = ({ content }) => {
</div>
)}
</RichTextSection>
) : (
<></>
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const EventoUlterioriInformazioni = ({ content }) => {
richTextHasContent(content?.ulteriori_informazioni) ||
content?.event_url ||
richTextHasContent(content?.patrocinato_da) ||
content?.strutture_politiche.length > 0,
content?.strutture_politiche?.length > 0,
[content],
);

Expand Down Expand Up @@ -64,11 +64,11 @@ const EventoUlterioriInformazioni = ({ content }) => {
)}
</div>
)}
{content?.strutture_politiche.length > 0 && (
{content?.strutture_politiche?.length > 0 && (
<div className="mt-4">
<h5>{intl.formatMessage(messages.strutture_politiche)}</h5>
<div className="card-wrapper card-teaser-wrapper card-teaser-wrapper-equal">
{content.strutture_politiche.map((item, i) => (
{content?.strutture_politiche?.map((item, i) => (
<GenericCard
key={i}
index={item['@id']}
Expand Down
4 changes: 1 addition & 3 deletions src/config/italiaConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -438,9 +438,7 @@ export default function applyConfig(voltoConfig) {
blocksConfig: { ...config.blocks.blocksConfig, ...customBlocks },
groupBlocksOrder: config.blocks.groupBlocksOrder.concat(customBlocksOrder),
initialBlocks: { ...config.blocks.initialBlocks, ...customInitialBlocks },
requiredBlocks: {
...config.blocks.requiredBlocks.concat(...customRequiredBlocks),
},
requiredBlocks: [...config.blocks.requiredBlocks, ...customRequiredBlocks],
showEditBlocksInBabelView: true,
};

Expand Down

0 comments on commit f4ec297

Please sign in to comment.