Disallow having more than one carousel block per post or page.

This commit is contained in:
Mateus Machado Luna 2019-08-02 16:45:59 -03:00
parent ed1acdf9ca
commit 12b6121e09
2 changed files with 15 additions and 5 deletions

View File

@ -23,7 +23,8 @@ document.addEventListener("DOMContentLoaded", () => {
collectionTextColor: '#ffffff',
tainacanApiRoot: '',
tainacanBaseUrl: '',
className: ''
className: '',
extraParams: {}
},
render(h){
return h(CarouselItemsListTheme, {
@ -44,7 +45,8 @@ document.addEventListener("DOMContentLoaded", () => {
collectionTextColor: this.collectionTextColor,
tainacanApiRoot: this.tainacanApiRoot,
tainacanBaseUrl: this.tainacanBaseUrl,
className: this.className
className: this.className,
extraParams: this.extraParams
}
});
},
@ -66,6 +68,7 @@ document.addEventListener("DOMContentLoaded", () => {
this.collectionTextColor = this.$el.attributes['collection-text-color'] != undefined ? this.$el.attributes['collection-text-color'].value : undefined;
this.tainacanApiRoot = this.$el.attributes['tainacan-api-root'] != undefined ? this.$el.attributes['tainacan-api-root'].value : undefined;
this.tainacanBaseUrl = this.$el.attributes['tainacan-base-url'] != undefined ? this.$el.attributes['tainacan-base-url'].value : undefined;
this.extraParams = this.$el.attributes['extra-params'] != undefined ? JSON.parse(this.$el.attributes['extra-params'].value) : undefined;
},
methods: {
__(text, domain) {

View File

@ -114,11 +114,16 @@ registerBlockType('tainacan/carousel-items-list', {
collectionTextColor: {
type: String,
default: "#ffffff"
},
extraParams: {
type: Object,
default: {}
}
},
supports: {
align: ['full', 'wide'],
html: false,
multiple: false
},
edit({ attributes, setAttributes, className, isSelected, clientId }){
let {
@ -142,7 +147,8 @@ registerBlockType('tainacan/carousel-items-list', {
isLoadingCollection,
collection,
collectionBackgroundColor,
collectionTextColor
collectionTextColor,
extraParams
} = attributes;
// Obtains block's client id to render it on save function
@ -184,7 +190,6 @@ registerBlockType('tainacan/carousel-items-list', {
}
function setContent(){
isLoading = true;
setAttributes({
@ -708,7 +713,8 @@ registerBlockType('tainacan/carousel-items-list', {
showCollectionHeader,
showCollectionLabel,
collectionBackgroundColor,
collectionTextColor
collectionTextColor,
extraParams
} = attributes;
return <div
className={ className }
@ -728,6 +734,7 @@ registerBlockType('tainacan/carousel-items-list', {
max-items-number={ maxItemsNumber }
tainacan-api-root={ tainacan_plugin.root }
tainacan-base-url={ tainacan_plugin.base_url }
extraParams={ JSON.stringify(extraParams) }
id={ 'wp-block-tainacan-carousel-items-list_' + blockId }>
{ content }
</div>