Search items update

This commit is contained in:
joycitta-siqueira 2022-06-28 17:12:43 -03:00
parent 6888243155
commit 8ee39d4db2
3 changed files with 8 additions and 13 deletions

View File

@ -71,7 +71,8 @@ export default defineComponent({
const setIsLoading = (state: boolean) => isLoading.value = state;
const setSearch = (value: string) => search.value = value;
const loadItemsByCollection = async (event: any, reset: boolean) => {
let hasMoreCollectionsItems = await tainacanStore.fetchItemsByCollection(props.id + '', { perPage: '12', orderBy: 'modified', reset: reset, search: search.value});
await tainacanStore.fetchItemsByCollection(props.id + '', { perPage: '12', orderBy: 'modified', reset: reset, search: search.value});
let hasMoreCollectionsItems = tainacanStore.totalCollectionItems && tainacanStore.totalCollectionItems !== 0;
if (event && event.target)
event.target.complete();
if (!hasMoreCollectionsItems){

View File

@ -52,7 +52,8 @@ export default {
const setSearch = (value: string) => search.value = value;
const infiniteScroll = ref();
const loadItems = async (event: any, reset: boolean) => {
let hasMoreItems = await tainacanStore.fetchItems({ perPage: '12', orderBy: 'modified', reset: reset, search: search.value});
await tainacanStore.fetchItems({ perPage: '12', orderBy: 'modified', reset: reset, search: search.value});
let hasMoreItems = tainacanStore.totalItems && tainacanStore.totalItems !== 0;
if (event && event.target)
event.target.complete();
if (!hasMoreItems){

View File

@ -101,13 +101,10 @@ const useTainacanStore = defineStore("tainacan", {
this.collectionItems.push(...response.data.items);
this.totalCollectionItems = response.headers['x-wp-total'];
if (!this.totalCollectionItems ||
this.totalCollectionItems === "0") {
return false;
} else {
this.nextItemsByCollectionPage++;
return true;
if (this.totalCollectionItems && this.totalCollectionItems !== "0") {
this.nextItemsByCollectionPage++;
}
} catch (err) {
this.collectionItems = [];
this.totalCollectionItems = 0;
@ -162,12 +159,8 @@ const useTainacanStore = defineStore("tainacan", {
this.items.push(...response.data.items);
this.totalItems = response.headers['x-wp-total'];
if (!this.totalItems ||
this.totalItems === "0") {
return false;
} else {
if (this.totalItems && this.totalItems !== "0") {
this.nextItemsPage++;
return true;
}
} catch (err) {