Adds taxonomy name to terms modal. Shows spinner while loading terms or taxonomies.

This commit is contained in:
Mateus Machado Luna 2019-03-08 16:55:14 -03:00
parent a6405187e5
commit f9898c7dba
4 changed files with 56 additions and 19 deletions

View File

@ -166,7 +166,12 @@
grid-gap: 0px;
justify-content: space-evenly;
list-style-type: none;
margin: 12px; }
margin: 12px;
max-height: 50vh;
overflow-y: auto; }
.wp-block-tainacan-terms-modal .modal-terms-list .components-base-control,
.wp-block-tainacan-terms-modal .modal-taxonomies-list .components-base-control__field .components-base-control {
overflow: hidden; }
.wp-block-tainacan-terms-modal .modal-terms-list .modal-terms-list-item,
.wp-block-tainacan-terms-modal .modal-terms-list .components-radio-control__option,
.wp-block-tainacan-terms-modal .modal-taxonomies-list .components-base-control__field .modal-terms-list-item,
@ -188,6 +193,12 @@
overflow: hidden;
display: inline-block;
max-width: 85%; }
@media only screen and (max-width: 768px) {
.wp-block-tainacan-terms-modal .modal-terms-list .modal-terms-list-item label,
.wp-block-tainacan-terms-modal .modal-terms-list .components-radio-control__option label,
.wp-block-tainacan-terms-modal .modal-taxonomies-list .components-base-control__field .modal-terms-list-item label,
.wp-block-tainacan-terms-modal .modal-taxonomies-list .components-base-control__field .components-radio-control__option label {
max-width: 80%; } }
.wp-block-tainacan-terms-modal .modal-terms-loadmore-section {
display: flex;
align-items: baseline;

View File

@ -1,6 +1,6 @@
{
"version": 3,
"mappings": "AAAA,6BAA8B;EAC1B,MAAM,EAAE,QAAQ;EAGhB,iDAAoB;IAChB,QAAQ,EAAE,QAAQ;IAClB,KAAK,EAAE,CAAC;EAIZ,4CAAe;IACX,OAAO,EAAE,IAAI;IACb,cAAc,EAAE,GAAG;IACnB,eAAe,EAAE,MAAM;EAI3B;oEACqC;IACjC,OAAO,EAAE,CAAC;IACV,OAAO,EAAE,QAAQ;IACjB,OAAO,EAAE,IAAI;IACb,qBAAqB,EAAE,wBAAwB;IAC/C,QAAQ,EAAE,GAAG;IACb,eAAe,EAAE,YAAY;IAC7B,eAAe,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",
"sources": ["../../gutenberg-blocks/tainacan-terms/terms-list/terms-list.scss"],
"names": [],
"file": "tainacan-gutenberg-blocks-style.css"

View File

@ -104,6 +104,10 @@ registerBlockType('tainacan/terms-list', {
type: String,
default: ''
},
taxonomyName: {
type: String,
default: ''
},
showImage: {
type: Boolean,
default: true
@ -157,7 +161,8 @@ registerBlockType('tainacan/terms-list', {
terms,
content,
searchTermName,
taxonomyId,
taxonomyId,
taxonomyName,
temporaryTaxonomyId,
isLoadingTerms,
isLoadingTaxonomies,
@ -219,7 +224,7 @@ registerBlockType('tainacan/terms-list', {
</div>
{(
searchTaxonomyName != '' ? (
taxonomies.length > 0 ?
taxonomies.length > 0 && !isLoadingTaxonomies ?
(
<div>
<div className="modal-taxonomies-list">
@ -237,14 +242,16 @@ registerBlockType('tainacan/terms-list', {
} } />
}
</div>
{ isLoadingTaxonomies ? <Spinner /> : null }
</div>
) :
isLoadingTaxonomies ? (
<Spinner />
) :
<div className="modal-terms-loadmore-section">
<p>{ __('Sorry, no taxonomy found.', 'tainacan') }</p>
</div>
</div>
):
modalTaxonomies.length > 0 ?
modalTaxonomies.length > 0 && !isLoadingTaxonomies?
(
<div>
<div className="modal-taxonomies-list">
@ -262,7 +269,6 @@ registerBlockType('tainacan/terms-list', {
} } />
}
</div>
{ isLoadingTaxonomies ? <Spinner /> : null }
<div className="modal-terms-loadmore-section">
<p>{ __('Showing', 'tainacan') + " " + modalTaxonomies.length + " " + __('of', 'tainacan') + " " + totalModalTaxonomies + " " + __('taxonomies', 'tainacan') + "."}</p>
{
@ -277,7 +283,7 @@ registerBlockType('tainacan/terms-list', {
}
</div>
</div>
) :
) : isLoadingTaxonomies ? <Spinner/> :
<div className="modal-terms-loadmore-section">
<p>{ __('Sorry, no taxonomy found.', 'tainacan') }</p>
</div>
@ -293,6 +299,7 @@ registerBlockType('tainacan/terms-list', {
</Button>
<Button
isPrimary
disabled={ temporaryTaxonomyId == undefined || temporaryTaxonomyId == null || temporaryTaxonomyId == ''}
onClick={ () => selectTaxonomy(temporaryTaxonomyId) }>
{__('Select terms', 'tainacan')}
</Button>
@ -306,7 +313,7 @@ registerBlockType('tainacan/terms-list', {
return (
<Modal
className="wp-block-tainacan-terms-modal"
title={__('Select the desired terms', 'tainacan')}
title={__('Select the desired terms for taxonomy ' + taxonomyName, 'tainacan')}
onRequestClose={ () => setAttributes( { isModalOpen: false } ) }
contentLabel={__('Select terms', 'tainacan')}>
<div>
@ -323,7 +330,8 @@ registerBlockType('tainacan/terms-list', {
</div>
{(
searchTermName != '' ? (
terms.length > 0 ?
terms.length > 0 && !isLoadingTerms ?
(
<div>
<ul className="modal-terms-list">
@ -348,15 +356,14 @@ registerBlockType('tainacan/terms-list', {
)
}
</ul>
{ isLoadingTerms ? <Spinner /> : null }
</div>
)
:
: isLoadingTerms ? <Spinner/> :
<div className="modal-terms-loadmore-section">
<p>{ __('Sorry, no terms found.', 'tainacan') }</p>
</div>
) :
modalTerms.length > 0 ?
) :
modalTerms.length > 0 && !isLoadingTerms ?
(
<div>
<ul className="modal-terms-list">
@ -380,7 +387,6 @@ registerBlockType('tainacan/terms-list', {
)
}
</ul>
{ isLoadingTerms ? <Spinner /> : null }
<div className="modal-terms-loadmore-section">
<p>{ __('Showing', 'tainacan') + " " + modalTerms.length + " " + __('of', 'tainacan') + " " + totalModalTerms + " " + __('terms', 'tainacan') + "."}</p>
{
@ -395,7 +401,7 @@ registerBlockType('tainacan/terms-list', {
}
</div>
</div>
) :
) : isLoadingTerms ? <Spinner /> :
<div className="modal-terms-loadmore-section">
<p>{ __('Sorry, no terms found.', 'tainacan') }</p>
</div>
@ -597,9 +603,10 @@ registerBlockType('tainacan/terms-list', {
function openTermsModal() {
temporarySelectedTerms = JSON.parse(JSON.stringify(selectedTermsObject));
if (taxonomyId != null && taxonomyId != undefined)
if (taxonomyId != null && taxonomyId != undefined) {
fetchTaxonomy();
fetchModalTerms(0);
else {
} else {
taxonomyPage = 1;
fetchModalTaxonomies()
}
@ -631,6 +638,7 @@ registerBlockType('tainacan/terms-list', {
setAttributes({
taxonomyId: taxonomyId
});
fetchTaxonomy();
fetchModalTerms(0);
setContent();
@ -680,6 +688,16 @@ registerBlockType('tainacan/terms-list', {
setContent();
}
function fetchTaxonomy() {
tainacan.get('/taxonomies/' + taxonomyId)
.then((response) => {
taxonomyName = response.data.name;
setAttributes({ taxonomyName: taxonomyName });
}).catch(error => {
console.log('Error trying to fetch taxonomy: ' + error);
});
}
function updateLayout(newLayout) {
layout = newLayout;

View File

@ -219,6 +219,12 @@
justify-content: space-evenly;
list-style-type: none;
margin: 12px;
max-height: 50vh;
overflow-y: auto;
.components-base-control {
overflow: hidden;
}
.modal-terms-list-item,
.components-radio-control__option {
@ -235,6 +241,8 @@
overflow: hidden;
display: inline-block;
max-width: 85%;
@media only screen and (max-width: 768px) { max-width: 80%; }
}
}
}