From 8002387b4a69ea2e342ed138d22b8265a0b6155d Mon Sep 17 00:00:00 2001 From: Victor Fernandez de Alba Date: Wed, 28 Jun 2023 11:44:20 +0200 Subject: [PATCH] Accordion schema --- src/components/Blocks/Accordion/schema.jsx | 9 ++++++++- src/components/Blocks/schema.js | 1 + src/index.js | 17 ++++++++++++++++- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/components/Blocks/Accordion/schema.jsx b/src/components/Blocks/Accordion/schema.jsx index 96c191ce..16c17ca6 100644 --- a/src/components/Blocks/Accordion/schema.jsx +++ b/src/components/Blocks/Accordion/schema.jsx @@ -8,14 +8,21 @@ const messages = defineMessages({ }); export function AccordionSchemaEnhancer({ schema, formData, intl }) { - schema.required = []; + // Opinionated removal of the options fieldset schema.fieldsets = schema.fieldsets.filter((item) => item.id !== 'options'); + + // Some other opinionated defaults + schema.required = []; schema.properties.right_arrows.default = true; schema.properties.collapsed.default = false; schema.properties.non_exclusive.default = false; + + // Add headline - TODO: Remove when https://github.com/eea/volto-accordion-block/pull/71 + // is merged schema.fieldsets[0].fields = ['headline', ...schema.fieldsets[0].fields]; schema.properties.headline = { title: intl.formatMessage(messages.headline), }; + return schema; } diff --git a/src/components/Blocks/schema.js b/src/components/Blocks/schema.js index 3de42df4..598da3ff 100644 --- a/src/components/Blocks/schema.js +++ b/src/components/Blocks/schema.js @@ -33,5 +33,6 @@ export const defaultStylingSchema = ({ schema, formData, intl }) => { colors, default: defaultBGColor, }; + return schema; }; diff --git a/src/index.js b/src/index.js index ce5d7963..22903ff5 100644 --- a/src/index.js +++ b/src/index.js @@ -126,7 +126,22 @@ const applyConfig = (config) => { ...config.blocks.blocksConfig.accordion, icon: accordionSVG, allowedBlocks: ['slate', 'teaser', 'image', 'listing', 'slateTable'], - schemaEnhancer: AccordionSchemaEnhancer, + colors: BG_COLORS, + schemaEnhancer: composeSchema( + AccordionSchemaEnhancer, + defaultStylingSchema, + ), + sidebarTab: 1, + blocksConfig: { + ...config.blocks.blocksConfig, + teaser: { + ...config.blocks.blocksConfig.teaser, + schemaEnhancer: composeSchema( + gridTeaserDisableStylingSchema, + teaserSchemaEnhancer, + ), + }, + }, }; config.blocks.blocksConfig.__grid = {