generated from eea/volto-addon-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6b053a8
commit bf3fdd9
Showing
23 changed files
with
558 additions
and
573 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,132 +1,176 @@ | ||
import CardsCarousel from './templates/CardsCarousel'; | ||
import CardsGallery from './templates/CardsGallery'; | ||
import NewsList from './templates/NewsList'; | ||
import Summary from './templates/Summary'; | ||
import { compose } from 'redux'; | ||
import Carousel from './layout-templates/Carousel'; | ||
import Gallery from './layout-templates/Gallery'; | ||
import Listing from './layout-templates/Listing'; | ||
import { | ||
setBasicStylingSchema, | ||
setCardStylingSchema, | ||
setCardModelSchema, | ||
setItemModelSchema, | ||
} from './schema'; | ||
|
||
import { | ||
DefaultCardLayout, | ||
ImageCardLayout, | ||
LeftImageCardLayout, | ||
RightImageCardLayout, | ||
} from './CardTemplates'; | ||
|
||
import { DefaultItemLayout } from './ItemTemplates'; | ||
import { SearchItemLayout } from './SearchItemTemplate'; | ||
} from './item-templates/CardTemplates'; | ||
|
||
import { BasicListingBlockStylesSchema } from './schema'; | ||
import { DefaultItemLayout } from './item-templates/ItemTemplates'; | ||
import { SearchItemLayout } from './item-templates/SearchItemTemplate'; | ||
|
||
import { CardStylingSchemaEnhancer } from './schema'; | ||
import universalCardSchemaEnhancer from '@eeacms/volto-listing-block/components/UniversalCard/schema'; | ||
|
||
const applyConfig = (config) => { | ||
// moment date locale. See https://momentjs.com/ - Multiple Locale Support | ||
config.settings.dateLocale = config.settings.dateLocale || 'en'; | ||
config.settings.dateLocale = config.settings.dateLocale ?? 'en'; | ||
const { listing } = config.blocks.blocksConfig; | ||
|
||
const blacklist = ['summary']; | ||
|
||
const { schemaEnhancer } = listing; | ||
|
||
listing.stylesSchema = BasicListingBlockStylesSchema; | ||
|
||
listing.schemaEnhancer = (props) => { | ||
// NOTE: this is a schema finalizer | ||
const schema = schemaEnhancer ? schemaEnhancer(props) : props.schema; | ||
listing.schemaEnhancer = moveQueryToFieldset(listing.schemaEnhancer); | ||
|
||
// move querystring to its own fieldset; | ||
schema.fieldsets[0].fields = schema.fieldsets[0].fields.filter( | ||
(f) => f !== 'querystring', | ||
); | ||
schema.fieldsets.splice(1, 0, { | ||
id: 'querystring', | ||
title: 'Query', | ||
fields: ['querystring'], | ||
}); | ||
|
||
return schema; | ||
}; | ||
// The split of responsibilities is as follows: | ||
// the Listing block variation takes care of the Layout responsibility (how | ||
// the items are listed) | ||
// The variation takes care of how the individual item is displayed. | ||
// With our own variations being based on the UniversalCard, we have another | ||
// level of control on how each item is displayed. | ||
|
||
listing.variations = [ | ||
...listing.variations.filter(({ id }) => blacklist.indexOf(id) === -1), | ||
{ | ||
id: 'summary', | ||
isDefault: false, | ||
title: 'Item listing', | ||
template: Summary, | ||
schemaEnhancer: Summary.schemaEnhancer, | ||
stylesSchema: Summary.styleSchemaEnhancer, | ||
title: 'Listing', | ||
template: Listing, | ||
schemaEnhancer: compose( | ||
Listing.schemaEnhancer, // layout schema | ||
setBasicStylingSchema, | ||
universalCardSchemaEnhancer, | ||
), | ||
}, | ||
{ | ||
id: 'cardsCarousel', | ||
isDefault: false, | ||
title: 'Cards carousel', | ||
template: CardsCarousel, | ||
schemaEnhancer: CardsCarousel.schemaEnhancer, | ||
stylesSchema: CardsCarousel.styleSchemaEnhancer, | ||
}, | ||
{ | ||
id: 'customCardsGalleryVariationId', | ||
isDefault: false, | ||
title: 'Cards gallery', | ||
template: CardsGallery, | ||
schemaEnhancer: CardsGallery.schemaEnhancer, | ||
stylesSchema: CardStylingSchemaEnhancer, | ||
title: 'Carousel', | ||
template: Carousel, | ||
schemaEnhancer: compose( | ||
Carousel.schemaEnhancer, | ||
setBasicStylingSchema, | ||
universalCardSchemaEnhancer, | ||
), | ||
}, | ||
{ | ||
id: 'customNewsListVariationId', | ||
id: 'cardsGallery', // 'customCardsGalleryVariationId' | ||
isDefault: false, | ||
title: 'News List', | ||
template: NewsList, | ||
schemaEnhancer: NewsList.schemaEnhancer, | ||
title: 'Gallery', | ||
template: Gallery, | ||
schemaEnhancer: compose( | ||
Gallery.schemaEnhancer, | ||
setBasicStylingSchema, | ||
universalCardSchemaEnhancer, | ||
), | ||
}, | ||
]; | ||
|
||
listing.extensions = { | ||
...listing.extensions, | ||
itemTemplates: [ | ||
{ | ||
id: 'item', | ||
isDefault: true, | ||
title: 'Basic Item', | ||
view: DefaultItemLayout, | ||
}, | ||
{ | ||
id: 'searchItem', | ||
isDefault: false, | ||
title: 'Search Item', | ||
view: SearchItemLayout, | ||
stylesSchema: SearchItemLayout.styleSchemaEnhancer, | ||
}, | ||
], | ||
cardTemplates: [ | ||
{ | ||
id: 'card', | ||
isDefault: true, | ||
title: 'Card (default)', | ||
view: DefaultCardLayout, | ||
template: DefaultCardLayout, | ||
schemaEnhancer: compose(setCardModelSchema, setCardStylingSchema), | ||
}, | ||
{ | ||
id: 'imageCard', | ||
title: 'Image Card', | ||
view: ImageCardLayout, | ||
template: ImageCardLayout, | ||
schemaEnhancer: compose(setCardModelSchema, setCardStylingSchema), | ||
}, | ||
{ | ||
id: 'imageOnLeft', | ||
title: 'Image on left', | ||
view: LeftImageCardLayout, | ||
template: LeftImageCardLayout, | ||
schemaEnhancer: compose(setCardModelSchema, setCardStylingSchema), | ||
}, | ||
{ | ||
id: 'imageOnRight', | ||
title: 'Image on right', | ||
view: RightImageCardLayout, | ||
template: RightImageCardLayout, | ||
schemaEnhancer: compose(setCardModelSchema, setCardStylingSchema), | ||
}, | ||
{ | ||
id: 'item', | ||
isDefault: true, | ||
title: 'Listing Item', | ||
template: DefaultItemLayout, | ||
schemaEnhancer: compose( | ||
setItemModelSchema, | ||
setCardStylingSchema, | ||
DefaultItemLayout.schemaEnhancer, | ||
), | ||
}, | ||
{ | ||
id: 'searchItem', | ||
isDefault: false, | ||
title: 'Search Item', | ||
template: SearchItemLayout, | ||
schemaEnhancer: compose( | ||
setCardStylingSchema, | ||
SearchItemLayout.schemaEnhancer, | ||
), | ||
}, | ||
], | ||
}; | ||
|
||
// Theming | ||
// This bug needs to be fixed first: https://github.com/plone/volto/issues/3675 | ||
// listing.enableStyling = true; | ||
|
||
return config; | ||
}; | ||
|
||
export default applyConfig; | ||
|
||
const moveQueryToFieldset = (schemaEnhancer) => (props) => { | ||
// NOTE: this is a schema finalizer | ||
const schema = schemaEnhancer ? schemaEnhancer(props) : props.schema; | ||
|
||
// move querystring to its own fieldset; | ||
schema.fieldsets[0].fields = schema.fieldsets[0].fields.filter( | ||
(f) => f !== 'querystring', | ||
); | ||
schema.fieldsets.splice(1, 0, { | ||
id: 'querystring', | ||
title: 'Query', | ||
fields: ['querystring'], | ||
}); | ||
|
||
return schema; | ||
}; | ||
|
||
// import { CardStylingSchemaEnhancer } from '../schema'; | ||
// CardsCarousel.styleSchemaEnhancer = ({ schema, intl }) => { | ||
// return CardStylingSchemaEnhancer({ schema }); | ||
// }; | ||
|
||
// Listing.schemaEnhancer = UniversalItem.schemaEnhancer; | ||
// | ||
// Listing.styleSchemaEnhancer = ({ schema, intl }) => { | ||
// return schema; | ||
// }; | ||
// listing.stylesSchema = BasicListingBlockStylesSchema; | ||
// stylesSchema: Summary.styleSchemaEnhancer, | ||
// stylesSchema: CardStylingSchemaEnhancer, | ||
// stylesSchema: CardsCarousel.styleSchemaEnhancer, | ||
// stylesSchema: SearchItemLayout.styleSchemaEnhancer, | ||
// { | ||
// id: 'customNewsListVariationId', | ||
// isDefault: false, | ||
// title: 'News List', | ||
// template: NewsList, | ||
// // schemaEnhancer: NewsList.schemaEnhancer, | ||
// }, | ||
// Theming | ||
// This bug needs to be fixed first: https://github.com/plone/volto/issues/3675 | ||
// listing.enableStyling = true; | ||
// import NewsList from './templates/NewsList'; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.