mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 13:28:11 +00:00
Zmiana instancji store'a na Pinia
This commit is contained in:
@@ -50,13 +50,12 @@ import SceneryHeader from '@/components/SceneryView/SceneryHeader.vue';
|
||||
import ActionButton from '@/components/Global/ActionButton.vue';
|
||||
|
||||
import { computed, ComputedRef, defineComponent, provide, reactive } from '@vue/runtime-core';
|
||||
import { useStore } from '@/store';
|
||||
import { GETTERS } from '@/constants/storeConstants';
|
||||
import { useRoute } from 'vue-router';
|
||||
|
||||
import axios from 'axios';
|
||||
import { URLs } from '@/scripts/utils/apiURLs';
|
||||
import Station from '@/scripts/interfaces/Station';
|
||||
import { useStore } from '@/store/store';
|
||||
|
||||
export default defineComponent({
|
||||
components: { SceneryInfo, SceneryTimetable, SceneryHistory, ActionButton, SceneryHeader },
|
||||
@@ -79,16 +78,13 @@ export default defineComponent({
|
||||
const store = useStore();
|
||||
|
||||
const savedSceneryHistory = reactive({});
|
||||
const data: ComputedRef<StoreData> = computed(() => store.getters[GETTERS.allData]);
|
||||
|
||||
const timetableOnly = computed(() => (route.query['timetable_only'] == '1' ? true : false));
|
||||
|
||||
const isComponentVisible = computed(() => route.path === '/scenery');
|
||||
|
||||
const stationInfo = computed(() => {
|
||||
return data.value.stationList.find(
|
||||
(station) => station.name === route.query.station?.toString().replace(/_/g, ' ')
|
||||
);
|
||||
return store.stationList.find((station) => station.name === route.query.station?.toString().replace(/_/g, ' '));
|
||||
});
|
||||
|
||||
provide('savedSceneryHistory', savedSceneryHistory);
|
||||
@@ -98,8 +94,7 @@ export default defineComponent({
|
||||
// });
|
||||
|
||||
return {
|
||||
data,
|
||||
currentRegion: computed(() => store.getters[GETTERS.currentRegion]),
|
||||
currentRegion: store.region,
|
||||
timetableOnly,
|
||||
isComponentVisible,
|
||||
stationInfo,
|
||||
@@ -119,10 +114,6 @@ export default defineComponent({
|
||||
},
|
||||
},
|
||||
|
||||
async mounted() {
|
||||
// this.stationInfo = (this.$store.getters[GETTERS.allData] as StoreData).stationList.find((station) => station.name === this.$route.query.station?.toString().replace(/_/g, ' '))
|
||||
},
|
||||
|
||||
async activated() {
|
||||
if (this.currentRegion.id != 'eu' && this.viewMode == 'history') this.viewMode = 'info';
|
||||
|
||||
|
||||
@@ -36,10 +36,8 @@ import StationTable from '@/components/StationsView/StationTable.vue';
|
||||
import FilterCard from '@/components/StationsView/StationFilterCard.vue';
|
||||
import SelectBox from '@/components/Global/SelectBox.vue';
|
||||
|
||||
import { StoreData } from '@/scripts/interfaces/StoreData';
|
||||
import { computed, ComputedRef, defineComponent, reactive } from 'vue';
|
||||
import { useStore } from '@/store';
|
||||
import { GETTERS } from '@/constants/storeConstants';
|
||||
import { useStore } from '@/store/store';
|
||||
|
||||
export default defineComponent({
|
||||
components: {
|
||||
@@ -73,10 +71,8 @@ export default defineComponent({
|
||||
const filterManager = reactive(new StationFilterManager());
|
||||
const focusedStationName = '';
|
||||
|
||||
const data: ComputedRef<StoreData> = computed(() => store.getters[GETTERS.allData]);
|
||||
|
||||
const computedStations: ComputedRef<Station[]> = computed(() => {
|
||||
return filterManager.getFilteredStationList(store.getters[GETTERS.stationList]);
|
||||
return filterManager.getFilteredStationList(store.stationList);
|
||||
});
|
||||
|
||||
const focusedStationInfo = computed(() =>
|
||||
@@ -84,7 +80,6 @@ export default defineComponent({
|
||||
);
|
||||
|
||||
return {
|
||||
data,
|
||||
computedStations,
|
||||
filterManager,
|
||||
focusedStationName,
|
||||
@@ -111,7 +106,7 @@ export default defineComponent({
|
||||
methods: {
|
||||
toggleCardsState(name: string): void {
|
||||
if (name == 'filter') {
|
||||
this.filterCardOpen = !this.filterCardOpen;
|
||||
this.filterCardOpen = !this.filterCardOpen;
|
||||
}
|
||||
},
|
||||
changeSorter(index: number) {
|
||||
@@ -187,7 +182,6 @@ export default defineComponent({
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
|
||||
|
||||
@include smallScreen {
|
||||
.options-bar {
|
||||
font-size: 1.1em;
|
||||
|
||||
@@ -15,15 +15,14 @@
|
||||
<script lang="ts">
|
||||
import { computed, ComputedRef, defineComponent, PropType, provide, reactive, ref, TrainFilter } from 'vue';
|
||||
import { filteredTrainList } from '@/scripts/managers/trainFilterManager';
|
||||
import { trainFilters } from "@/data/trainOptions";
|
||||
import { trainFilters } from '@/data/trainOptions';
|
||||
|
||||
import Train from '@/scripts/interfaces/Train';
|
||||
import TrainTable from '@/components/TrainsView/TrainTable.vue';
|
||||
import TrainStats from '@/components/TrainsView/TrainStats.vue';
|
||||
import TrainOptions from '@/components/TrainsView/TrainOptions.vue';
|
||||
|
||||
import { useStore } from '@/store';
|
||||
import { GETTERS } from '@/constants/storeConstants';
|
||||
import { useStore } from '@/store/store';
|
||||
|
||||
export default defineComponent({
|
||||
components: {
|
||||
@@ -35,13 +34,13 @@ export default defineComponent({
|
||||
props: {
|
||||
train: {
|
||||
type: String,
|
||||
required: false
|
||||
required: false,
|
||||
},
|
||||
|
||||
driver: {
|
||||
type: String,
|
||||
required: false
|
||||
}
|
||||
required: false,
|
||||
},
|
||||
},
|
||||
|
||||
data: () => ({
|
||||
@@ -52,7 +51,7 @@ export default defineComponent({
|
||||
setup() {
|
||||
const store = useStore();
|
||||
|
||||
const trainList: ComputedRef<Train[]> = computed(() => store.getters[GETTERS.trainList]);
|
||||
const trainList = store.trainList;
|
||||
|
||||
const sorterActive = ref({ id: 'distance', dir: -1 });
|
||||
const filterList = reactive([...trainFilters]) as TrainFilter[];
|
||||
@@ -68,16 +67,9 @@ export default defineComponent({
|
||||
provide('isTrainOptionsCardVisible', isTrainOptionsCardVisible);
|
||||
|
||||
const computedTrains: ComputedRef<Train[]> = computed(() => {
|
||||
return filteredTrainList(
|
||||
trainList.value,
|
||||
searchedTrain.value,
|
||||
searchedDriver.value,
|
||||
sorterActive.value,
|
||||
filterList
|
||||
);
|
||||
return filteredTrainList(trainList, searchedTrain.value, searchedDriver.value, sorterActive.value, filterList);
|
||||
});
|
||||
|
||||
|
||||
return {
|
||||
trainList,
|
||||
computedTrains,
|
||||
@@ -88,9 +80,9 @@ export default defineComponent({
|
||||
},
|
||||
|
||||
activated() {
|
||||
if(this.train) {
|
||||
if (this.train) {
|
||||
this.searchedTrain = this.train;
|
||||
this.searchedDriver = this.driver || "";
|
||||
this.searchedDriver = this.driver || '';
|
||||
}
|
||||
// if (this.train) {
|
||||
// this.searchedTrain = this.train;
|
||||
|
||||
Reference in New Issue
Block a user