composables, mazani letu, skeletony
This commit is contained in:
+16
-5
@@ -1,14 +1,25 @@
|
||||
import {defineStore} from 'pinia'
|
||||
import {useQuasar} from "quasar";
|
||||
import {useMeta} from "quasar";
|
||||
|
||||
export const useAppStore = defineStore('App', {
|
||||
state: () => ({
|
||||
pageTitle: null,
|
||||
fabButton: {icon: null, label: null, action: {}}
|
||||
breadcrumbs: []
|
||||
}),
|
||||
|
||||
getters: {},
|
||||
|
||||
actions: {
|
||||
resetAfterRouteChange() {
|
||||
this.setPageTitle("");
|
||||
this.setBreadcrumbs([]);
|
||||
},
|
||||
setPageTitle(pageTitle) {
|
||||
this.pageTitle = pageTitle;
|
||||
useMeta({title: pageTitle !== '' ? `${pageTitle} - Polétání.cz` : 'Polétání.cz'});
|
||||
|
||||
|
||||
console.log("setPageTitle:", pageTitle);
|
||||
},
|
||||
setBreadcrumbs(breadcrumbs) {
|
||||
this.breadcrumbs = breadcrumbs;
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {defineStore} from 'pinia'
|
||||
import {apolloWrapper} from "src/graphql/apollo";
|
||||
import {COPILOTS_LIST} from "src/graphql/queries/copilots";
|
||||
import {COPILOTS_DETAIL, COPILOTS_LIST} from "src/graphql/queries/copilots";
|
||||
|
||||
export const useCopilotsStore = defineStore('SecondPilots', {
|
||||
state: () => ({
|
||||
@@ -13,6 +13,9 @@ export const useCopilotsStore = defineStore('SecondPilots', {
|
||||
create(formData) {
|
||||
console.log("not implemented");
|
||||
},
|
||||
fetchDetail(copilotId) {
|
||||
return apolloWrapper.query(COPILOTS_DETAIL, {id: copilotId}).then(({data}) => data.copilot);
|
||||
},
|
||||
fetch() {
|
||||
return apolloWrapper.query(COPILOTS_LIST).then(result => {
|
||||
this.items = result.data.copilots;
|
||||
|
||||
+15
-11
@@ -1,7 +1,7 @@
|
||||
import {defineStore} from 'pinia'
|
||||
import {apolloWrapper} from "src/graphql/apollo"
|
||||
import {FLIGHT_DETAIL, FLIGHTS_LIST} from "src/graphql/queries/flights";
|
||||
import {EDIT_FLIGHT, CREATE_FLIGHT} from "src/graphql/mutations/flight";
|
||||
import {EDIT_FLIGHT, CREATE_FLIGHT, DELETE_FLIGHT} from "src/graphql/mutations/flight";
|
||||
|
||||
export const useFlightsStore = defineStore('Flights', {
|
||||
state: () => ({
|
||||
@@ -38,16 +38,20 @@ export const useFlightsStore = defineStore('Flights', {
|
||||
fetch() {
|
||||
return apolloWrapper
|
||||
.query(FLIGHTS_LIST)
|
||||
.then((result) => {
|
||||
this.items = result.data.flights;
|
||||
.then(({data}) => {
|
||||
this.items = data.flights;
|
||||
|
||||
return result.data.flights;
|
||||
return data.flights;
|
||||
});
|
||||
},
|
||||
deleteItem(id) {
|
||||
const idx = this.items.indexOf(this.items.find(f => f.id === id));
|
||||
this.items.splice(idx, 1);
|
||||
console.log("maxu let ID " + id + " na indexu " + idx);
|
||||
}
|
||||
}
|
||||
})
|
||||
delete(id) {
|
||||
return apolloWrapper.mutate(DELETE_FLIGHT, {id}).then(({data}) => {
|
||||
|
||||
const idx = this.items.indexOf(this.items.find(f => f.id === id));
|
||||
this.items.splice(idx, 1);
|
||||
|
||||
return data.deleteFlight;
|
||||
})
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import {defineStore} from 'pinia'
|
||||
import {apolloWrapper} from "src/graphql/apollo";
|
||||
import {POI_LIST} from "src/graphql/queries/poi";
|
||||
import {POI_DETAIL, POI_LIST} from "src/graphql/queries/poi";
|
||||
import {EDIT_POI} from "src/graphql/mutations/poi";
|
||||
|
||||
export const usePointsOfInterestStore = defineStore('PointsOfInterest', {
|
||||
state: () => ({
|
||||
@@ -18,42 +19,27 @@ 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;
|
||||
// }
|
||||
},
|
||||
|
||||
actions: {
|
||||
fetchDetail(poiId) {
|
||||
console.log("fetch poi detail");
|
||||
this.items.push({id: poiId, "name": "Zamek " + poiId, "type": "poi", "location": {"lat": 50, "lng": 10}});
|
||||
update(id, input) {
|
||||
return apolloWrapper.mutate(EDIT_POI, {id, input}).then((data) => {
|
||||
console.log("Pridat update POI ve store");
|
||||
return data.data.editPointOfInterest;
|
||||
})
|
||||
},
|
||||
|
||||
fetchDetail(id) {
|
||||
if (typeof id !== "number") {
|
||||
id = parseInt(id);
|
||||
}
|
||||
return apolloWrapper.query(POI_DETAIL, {id}).then(result => result.data.pointOfInterest);
|
||||
},
|
||||
fetch() {
|
||||
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}},
|
||||
// ]
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user