Combobox, POI

This commit is contained in:
Michal Kváček
2023-07-17 13:03:42 +02:00
parent bbb21278fd
commit 2d76d136cf
14 changed files with 352 additions and 345 deletions
+30 -23
View File
@@ -1,4 +1,6 @@
import {defineStore} from 'pinia'
import {apolloWrapper} from "src/graphql/apollo";
import {POI_LIST} from "src/graphql/queries/poi";
export const usePointsOfInterestStore = defineStore('PointsOfInterest', {
state: () => ({
@@ -16,23 +18,23 @@ export const usePointsOfInterestStore = defineStore('PointsOfInterest', {
console.log('item', item);
return item;
},
pointTypeName() {
return (typeName) => {
const typeToNameMap = {
poi: "General POI",
airport: "Airport",
}
return typeToNameMap[typeName] || "Unknown";
}
},
groupByTypes() {
const groupedByType = {};
for (const item of this.items) {
if (!groupedByType[item.type]) groupedByType[item.type] = [];
groupedByType[item.type].push(item);
}
return groupedByType;
}
// pointTypeName() {
// return (typeName) => {
// const typeToNameMap = {
// poi: "General POI",
// airport: "Airport",
// }
// return typeToNameMap[typeName] || "Unknown";
// }
// },
// groupByTypes() {
// const groupedByType = {};
// for (const item of this.items) {
// if (!groupedByType[item.type]) groupedByType[item.type] = [];
// groupedByType[item.type].push(item);
// }
// return groupedByType;
// }
},
actions: {
@@ -41,12 +43,17 @@ export const usePointsOfInterestStore = defineStore('PointsOfInterest', {
this.items.push({id: poiId, "name": "Zamek " + poiId, "type": "poi", "location": {"lat": 50, "lng": 10}});
},
fetch() {
console.log("fetch poi");
this.items = [
{id: 1, "name": "LKLT", private: false, "type": "airport", "location": {"lat": 50, "lng": 10}},
{id: 2, "name": "Hrad", "type": "poi", "location": {"lat": 50, "lng": 10}},
{id: 3, "name": "Zamek", "type": "poi", "location": {"lat": 50, "lng": 10}},
]
return apolloWrapper.query(POI_LIST).then(result => {
this.items = result.data.pointsOfInterest;
return result.data.pointsOfInterest;
});
// console.log("fetch poi");
// this.items = [
// {id: 1, "name": "LKLT", private: false, "type": "airport", "location": {"lat": 50, "lng": 10}},
// {id: 2, "name": "Hrad", "type": "poi", "location": {"lat": 50, "lng": 10}},
// {id: 3, "name": "Zamek", "type": "poi", "location": {"lat": 50, "lng": 10}},
// ]
}
}
})