diff --git a/README.md b/README.md index c4f7b0d..2e9dc12 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ -# volto-listingadvanced-variation +![alt tag name](https://img.shields.io/github/v/tag/codesyntax/volto-listingadvanced-variation) + +# volto-listingadvanced-variation Volto addon to add an additional variation to the default listing block with advanced features diff --git a/src/advancedSchema.js b/src/advancedSchema.js index 01bb8ec..41b8f95 100644 --- a/src/advancedSchema.js +++ b/src/advancedSchema.js @@ -2,7 +2,7 @@ import messages from './messages'; export const advancedSchema = (props) => { const { intl, schema, formData } = props; - const imageWidth = ['right', 'left'].includes(formData.imageSide) + const imageWidth = ['right', 'left'].includes(formData?.imageSide) ? ['imageWidth'] : []; const headingChoices = [ @@ -10,24 +10,27 @@ export const advancedSchema = (props) => { ['h3', 'H3'], ['h4', 'H4'], ]; + let heading = + formData && formData['@type'] === 'listing' + ? [ + { + id: 'header', + title: intl.formatMessage(messages.headerConfiguration), + fields: ['header', 'headerUrl', 'headerTag'], + }, + ] + : []; + const include_fieldsets = ['default', 'searchquery', 'facets', 'controls']; + return { ...schema, fieldsets: [ - { - id: 'default', - title: 'Default', - fields: ['variation'], - }, - { - id: 'querystring', - title: intl.formatMessage(messages.querystring), - fields: ['querystring'], - }, - { - id: 'header', - title: intl.formatMessage(messages.headerConfiguration), - fields: ['header', 'headerUrl', 'headerTag'], - }, + ...(schema.fieldsets && + schema.fieldsets.length > 0 && + schema.fieldsets.filter((fieldset) => + include_fieldsets.includes(fieldset.id), + )), + ...heading, { id: 'columns', title: intl.formatMessage(messages.columnsConfiguration),