Marginless items grid when no title exists. Fetch only for loading items.

This commit is contained in:
Mateus Machado Luna 2019-03-11 19:02:10 -03:00
parent aa11b73c8f
commit abe1a442ad
4 changed files with 38 additions and 7 deletions

View File

@ -223,6 +223,19 @@
display: flex;
flex-direction: row;
justify-content: center; }
.wp-block-tainacan-items-list ul.items-list.items-list-without-margin,
.wp-block-tainacan-items-list ul.items-list-edit.items-list-without-margin {
grid-template-columns: repeat(auto-fill, 185px) !important;
justify-content: center !important;
grid-template-rows: auto !important; }
.wp-block-tainacan-items-list ul.items-list.items-list-without-margin li,
.wp-block-tainacan-items-list ul.items-list-edit.items-list-without-margin li {
margin: 0 !important;
height: 185px !important; }
.wp-block-tainacan-items-list ul.items-list.items-list-without-margin li img,
.wp-block-tainacan-items-list ul.items-list-edit.items-list-without-margin li img {
height: 185px !important;
margin-bottom: 0px !important; }
.wp-block-tainacan-items-list ul.items-list.items-layout-grid,
.wp-block-tainacan-items-list ul.items-list-edit.items-layout-grid {
padding: 0;

File diff suppressed because one or more lines are too long

View File

@ -318,6 +318,7 @@ registerBlockType('tainacan/items-list', {
</Button>
<Button
isPrimary
type="submit"
disabled={ temporaryCollectionId == undefined || temporaryCollectionId == null || temporaryCollectionId == ''}
onClick={ () => selectCollection(temporaryCollectionId) }>
{__('Select items', 'tainacan')}
@ -435,6 +436,7 @@ registerBlockType('tainacan/items-list', {
</Button>
<Button
isPrimary
type="submit"
onClick={ () => applySelectedItems() }>
{__('Finish', 'tainacan')}
</Button>
@ -554,7 +556,7 @@ registerBlockType('tainacan/items-list', {
isLoadingItems: isLoadingItems
});
let endpoint = '/collection/'+ collectionId + '/items/?perpage=' + itemsPerPage;
let endpoint = '/collection/'+ collectionId + '/items/?fetch_only=title,thumbnail&perpage=' + itemsPerPage;
if (title != undefined && title != '')
endpoint += '&search=' + title;
@ -590,7 +592,7 @@ registerBlockType('tainacan/items-list', {
if (itemsPage <= 1)
modalItems = [];
let endpoint = '/collection/'+ collectionId + '/items/?&perpage=' + itemsPerPage + '&paged=' + itemsPage;
let endpoint = '/collection/'+ collectionId + '/items/?fetch_only=title,thumbnail&perpage=' + itemsPerPage + '&paged=' + itemsPage;
isLoadingItems = true;
itemsPage++;
@ -634,10 +636,12 @@ registerBlockType('tainacan/items-list', {
function resetCollections() {
collectionId = null;
collectionPage = 1;
modalItems = [];
setAttributes({
collectionId: collectionId,
collectionPage: collectionPage
collectionPage: collectionPage,
modalItems: false
});
fetchModalCollections();
}
@ -829,6 +833,7 @@ registerBlockType('tainacan/items-list', {
<div className="block-control">
<Button
isPrimary
type="submit"
onClick={ () => openItemsModal() }>
{__('Select items', 'tainacan')}
</Button>

View File

@ -15,8 +15,21 @@
}
// Grid View Mode ----------------------------------------------------
ul.items-list.items-list-without-margin {
ul.items-list.items-list-without-margin,
ul.items-list-edit.items-list-without-margin {
grid-template-columns: repeat(auto-fill, 185px) !important;
justify-content: center !important;
grid-template-rows: auto !important;
li {
margin: 0 !important;
height: 185px !important;
img {
height: 185px !important;
margin-bottom: 0px !important;
}
}
}
ul.items-list.items-layout-grid,
ul.items-list-edit.items-layout-grid {