diff --git a/src/gutenberg-blocks/tainacan-facets/facets-list/facets-list-theme.js b/src/gutenberg-blocks/tainacan-facets/facets-list/facets-list-theme.js index ea0c8d83c..c294635da 100644 --- a/src/gutenberg-blocks/tainacan-facets/facets-list/facets-list-theme.js +++ b/src/gutenberg-blocks/tainacan-facets/facets-list/facets-list-theme.js @@ -10,7 +10,8 @@ document.addEventListener("DOMContentLoaded", () => { metadatumId: '', metadatumType: '', collectionId: '', - collectionSlug: '', + collectionSlug: '', + parentTermId: null, showImage: true, showItemsCount: true, showSearchBar: false, @@ -30,7 +31,8 @@ document.addEventListener("DOMContentLoaded", () => { metadatumId: this.metadatumId, metadatumType: this.metadatumType, collectionId: this.collectionId, - collectionSlug: this.collectionSlug, + collectionSlug: this.collectionSlug, + parentTermId: this.parentTermId, showImage: this.showImage, showItemsCount: this.showItemsCount, showSearchBar: this.showSearchBar, @@ -51,6 +53,7 @@ document.addEventListener("DOMContentLoaded", () => { this.metadatumType = this.$el.attributes['metadatum-type'] != undefined ? this.$el.attributes['metadatum-type'].value : undefined; this.collectionId = this.$el.attributes['collection-id'] != undefined ? this.$el.attributes['collection-id'].value : undefined; this.collectionSlug = this.$el.attributes['collection-slug'] != undefined ? this.$el.attributes['collection-slug'].value : undefined; + this.parentTermId = this.$el.attributes['parent-term-id'] != undefined ? this.$el.attributes['parent-term-id'].value : undefined; this.showImage = this.$el.attributes['show-image'] != undefined ? this.$el.attributes['show-image'].value == 'true' : true; this.showItemsCount = this.$el.attributes['show-items-count'] != undefined ? this.$el.attributes['show-items-count'].value == 'true' : true; this.showSearchBar = this.$el.attributes['show-search-bar'] != undefined ? this.$el.attributes['show-search-bar'].value == 'true' : false; diff --git a/src/gutenberg-blocks/tainacan-facets/facets-list/facets-list-theme.vue b/src/gutenberg-blocks/tainacan-facets/facets-list/facets-list-theme.vue index 9ea3dc21a..90f305d0f 100644 --- a/src/gutenberg-blocks/tainacan-facets/facets-list/facets-list-theme.vue +++ b/src/gutenberg-blocks/tainacan-facets/facets-list/facets-list-theme.vue @@ -158,7 +158,8 @@ export default { metadatumId: String, metadatumType: String, collectionId: String, - collectionSlug: String, + collectionSlug: String, + parentTermId: String, showImage: Boolean, showItemsCount: Boolean, showSearchBar: Boolean, @@ -227,7 +228,15 @@ export default { queryObject.offset = this.offset; if (this.lastTerm != undefined) queryObject.last_term = this.lastTerm; - + + // Set up parentTerm for taxonomies + if (this.parentTermId !== undefined && this.parentTermId !== null && this.parentTermId !== '' && this.metadatumType == 'Taxonomy') + queryObject.parent = this.parentTermId; + else { + delete queryObject.parent; + this.parentTermId = null; + } + // Parameter fo tech entity object with image and url queryObject['context'] = 'extended'; diff --git a/src/gutenberg-blocks/tainacan-facets/facets-list/index.js b/src/gutenberg-blocks/tainacan-facets/facets-list/index.js index 9d2e3c521..bb5291d9c 100644 --- a/src/gutenberg-blocks/tainacan-facets/facets-list/index.js +++ b/src/gutenberg-blocks/tainacan-facets/facets-list/index.js @@ -422,7 +422,7 @@ registerBlockType('tainacan/facets-list', {  { parentTerm && parentTerm.name ? parentTerm.name : __('Any term.', 'tainacan') }
@@ -542,7 +542,8 @@ registerBlockType('tainacan/facets-list', { setAttributes({ metadatumId: metadatumId, metadatumType: metadatumType, - isModalOpen: false + isModalOpen: false, + parentTerm: null }); setContent(); }} @@ -585,7 +586,7 @@ registerBlockType('tainacan/facets-list', { isPrimary type="submit" onClick={ () => openMetadataModal() }> - {__('Configure search', 'tainacan')} + {__('Select facets', 'tainacan')} ): null @@ -642,12 +643,32 @@ registerBlockType('tainacan/facets-list', { {__('List facets from a Tainacan Collection or Repository', 'tainacan')}

- + { + parentTerm && parentTerm.id && metadatumType == 'Taxonomy'? +
+ +

{__('or', 'tainacan')}

+ +
+ : + + } + ) : null } @@ -699,7 +720,8 @@ registerBlockType('tainacan/facets-list', { content, blockId, collectionId, - collectionSlug, + collectionSlug, + parentTerm, showImage, showItemsCount, showLoadMore, @@ -711,13 +733,13 @@ registerBlockType('tainacan/facets-list', { maxFacetsNumber, showSearchBar, } = attributes; - return
{ let someFacets = response.data.values.map((facet) => ({ name: facet.label, id: facet.value + '' })); @@ -198,30 +179,6 @@ export default class ParentTermModal extends React.Component { }); _.debounce(this.fetchFacets(value), 300); }}/> - { - this.state.facetOrderBy = aFacetOrderBy; - this.state.offset = 0; - this.state.lastTerm = undefined - this.setState({ - facetOrderBy: this.state.facetOrderBy, - offset: this.state.offset, - lastTerm: this.state.lastTerm - }); - if (this.state.searchFacetName && this.state.searchFacetName != '') { - this.fetchFacets(this.state.searchFacetName); - } else { - this.fetchModalFacets(); - } - }}/>
{( this.state.searchFacetName != '' ? ( @@ -262,8 +219,8 @@ export default class ParentTermModal extends React.Component { className={'repository-radio-option'} selected={ this.state.temporaryFacetId } options={ [ - { label: __('Fetch terms children of any term', 'tainacan'), value: '' }, - { label: __('Fetch terms with no parent (root terms)', 'tainacan'), value: '0' } + { label: __('Terms children of any term', 'tainacan'), value: '' }, + { label: __('Terms with no parent (root terms)', 'tainacan'), value: '0' } ] } onChange={ ( aFacetId ) => { this.setState({ temporaryFacetId: aFacetId}); @@ -308,7 +265,6 @@ export default class ParentTermModal extends React.Component {