Vyhledavani i ve verejnych POI

This commit is contained in:
Michal Kváček
2024-02-01 14:48:05 +01:00
parent 418469d81c
commit d69ceac14b
3 changed files with 26 additions and 18 deletions
+2 -2
View File
@@ -15,8 +15,8 @@ ${FRAGMENT_POI_LIST_INFO}
`; `;
export const POI_PUBLIC_LIST = gql` export const POI_PUBLIC_LIST = gql`
query poiList($limit: Int!, $offset: Int) { query poiList($limit: Int!, $offset: Int, $search: String) {
pointsOfInterest(limit: $limit, offset: $offset, public: true) { pointsOfInterest(limit: $limit, offset: $offset, search: $search, public: true) {
totalItemsCount totalItemsCount
items { items {
...pointOfInterestListInfo ...pointOfInterestListInfo
+22 -14
View File
@@ -6,8 +6,8 @@ import POIList from "components/poi/POIList.vue";
import {useAppStore} from "stores/App"; import {useAppStore} from "stores/App";
import {useMeta} from "quasar"; import {useMeta} from "quasar";
import {metaData} from "src/composables/meta"; import {metaData} from "src/composables/meta";
import {loadPage, paginationLimit} from "src/composables/pagination"; import {loadPage, paginationLimit, paginationOffset} from "src/composables/pagination";
import ListFilters from "components/ListFilters.vue";
useAppStore().setPageTitle("Místa"); useAppStore().setPageTitle("Místa");
useAppStore().setBreadcrumbs([ useAppStore().setBreadcrumbs([
@@ -18,24 +18,32 @@ useMeta(() => metaData({
title: "Místa" title: "Místa"
})) }))
const loadNextPage = (appendItems) => loadPage({ const loadNextPage = (appendItems, filters) => loadPage({
fetchFunc: usePointsOfInterestStore().fetchPublic, fetchFunc: usePointsOfInterestStore().fetchPublic,
appendItems filters, appendItems
}); });
loadNextPage(false); loadNextPage(false);
const handleFiltersChanged = (filters) => {
paginationOffset.value = 0;
loadNextPage(false, filters);
}
const {pointsOfInterest, totalItemsCount, isQueryRunning} = storeToRefs(usePointsOfInterestStore()); const {pointsOfInterest, totalItemsCount, isQueryRunning} = storeToRefs(usePointsOfInterestStore());
</script> </script>
<template> <template>
<BasicListSkeleton :items="paginationLimit" v-if="isQueryRunning && !pointsOfInterest.length"/> <div class="q-pa-md">
<POIList <ListFilters @filters-changed="handleFiltersChanged"/>
v-else
:public="true" <BasicListSkeleton :items="paginationLimit" v-if="isQueryRunning && !pointsOfInterest.length"/>
:items="pointsOfInterest" <POIList
:total-items-count="totalItemsCount" v-else
:is-query-running="isQueryRunning" :public="true"
:items-per-page="paginationLimit" :items="pointsOfInterest"
@load-more="loadNextPage(true)" :total-items-count="totalItemsCount"
/> :is-query-running="isQueryRunning"
:items-per-page="paginationLimit"
@load-more="loadNextPage(true)"
/>
</div>
</template> </template>
+2 -2
View File
@@ -36,10 +36,10 @@ export const usePointsOfInterestStore = defineStore('PointsOfInterest', () => {
variables: {limit, offset, search} variables: {limit, offset, search}
}).then(data => setItems(data, appendItems, pointsOfInterest, totalItemsCount)); }).then(data => setItems(data, appendItems, pointsOfInterest, totalItemsCount));
const fetchPublic = ({limit, offset, appendItems}) => query({ const fetchPublic = ({limit, offset, appendItems, search = undefined}) => query({
isQueryRunning, isQueryRunning,
query: POI_PUBLIC_LIST, query: POI_PUBLIC_LIST,
variables: {limit, offset} variables: {limit, offset, search}
}).then(data => setItems(data, appendItems, pointsOfInterest, totalItemsCount)); }).then(data => setItems(data, appendItems, pointsOfInterest, totalItemsCount));
const create = (input) => mutate({ const create = (input) => mutate({