From 12b6121e099b86f94908c201edb94cf40afa705c Mon Sep 17 00:00:00 2001 From: Mateus Machado Luna Date: Fri, 2 Aug 2019 16:45:59 -0300 Subject: [PATCH] Disallow having more than one carousel block per post or page. --- .../carousel-items-list-theme.js | 7 +++++-- .../tainacan-items/carousel-items-list/index.js | 13 ++++++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/gutenberg-blocks/tainacan-items/carousel-items-list/carousel-items-list-theme.js b/src/gutenberg-blocks/tainacan-items/carousel-items-list/carousel-items-list-theme.js index 65286bc8b..9cd31f64e 100644 --- a/src/gutenberg-blocks/tainacan-items/carousel-items-list/carousel-items-list-theme.js +++ b/src/gutenberg-blocks/tainacan-items/carousel-items-list/carousel-items-list-theme.js @@ -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) { diff --git a/src/gutenberg-blocks/tainacan-items/carousel-items-list/index.js b/src/gutenberg-blocks/tainacan-items/carousel-items-list/index.js index 1ce0b14ea..455fd309b 100644 --- a/src/gutenberg-blocks/tainacan-items/carousel-items-list/index.js +++ b/src/gutenberg-blocks/tainacan-items/carousel-items-list/index.js @@ -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
{ content }