mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 13:28:11 +00:00
fix: scenery timetable duplicates; fix: not opening train modal for queries
This commit is contained in:
@@ -103,7 +103,7 @@ export default defineComponent({
|
|||||||
showTimetable(timetable: API.TimetableHistory.Data, target: EventTarget | null) {
|
showTimetable(timetable: API.TimetableHistory.Data, target: EventTarget | null) {
|
||||||
if (timetable?.terminated) return;
|
if (timetable?.terminated) return;
|
||||||
|
|
||||||
this.selectModalTrain(timetable.driverName + timetable.trainNo.toString(), target);
|
this.selectModalTrainById(`${timetable.driverName}${timetable.trainNo}`, target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -18,8 +18,8 @@
|
|||||||
tabindex="0"
|
tabindex="0"
|
||||||
:key="train.id"
|
:key="train.id"
|
||||||
:data-status="status"
|
:data-status="status"
|
||||||
@click.prevent="selectModalTrain(train.id, $event.currentTarget)"
|
@click.prevent="selectModalTrain(train, $event.currentTarget)"
|
||||||
@keydown.enter="selectModalTrain(train.id, $event.currentTarget)"
|
@keydown.enter="selectModalTrain(train, $event.currentTarget)"
|
||||||
>
|
>
|
||||||
<span class="user_train">{{ train.trainNo }}</span>
|
<span class="user_train">{{ train.trainNo }}</span>
|
||||||
<span class="user_name">{{ train.driverName }}</span>
|
<span class="user_name">{{ train.driverName }}</span>
|
||||||
|
|||||||
@@ -39,8 +39,8 @@
|
|||||||
<div class="timetable-list">
|
<div class="timetable-list">
|
||||||
<transition-group name="list-anim">
|
<transition-group name="list-anim">
|
||||||
<div
|
<div
|
||||||
style="padding-bottom: 5em"
|
|
||||||
v-if="apiStore.dataStatuses.connection == 0 && sceneryTimetables.length == 0"
|
v-if="apiStore.dataStatuses.connection == 0 && sceneryTimetables.length == 0"
|
||||||
|
style="padding-bottom: 5em"
|
||||||
key="list-loading"
|
key="list-loading"
|
||||||
>
|
>
|
||||||
<Loading />
|
<Loading />
|
||||||
@@ -65,11 +65,11 @@
|
|||||||
<div
|
<div
|
||||||
class="timetable-item"
|
class="timetable-item"
|
||||||
v-else
|
v-else
|
||||||
v-for="row in sceneryTimetables"
|
v-for="(row, i) in sceneryTimetables"
|
||||||
:key="row.train.id + row.checkpointStop.arrivalTimestamp"
|
:key="row.train.id"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
@click.prevent.stop="selectModalTrain(row.train.id, $event.currentTarget)"
|
@click.prevent.stop="selectModalTrain(row.train, $event.currentTarget)"
|
||||||
@keydown.enter.prevent="selectModalTrain(row.train.id, $event.currentTarget)"
|
@keydown.enter.prevent="selectModalTrain(row.train, $event.currentTarget)"
|
||||||
>
|
>
|
||||||
<span class="timetable-general">
|
<span class="timetable-general">
|
||||||
<span class="general-info">
|
<span class="general-info">
|
||||||
@@ -236,8 +236,6 @@ export default defineComponent({
|
|||||||
if (!this.station) return [];
|
if (!this.station) return [];
|
||||||
if (!this.onlineScenery) return [];
|
if (!this.onlineScenery) return [];
|
||||||
|
|
||||||
console.log(this.onlineScenery.scheduledTrains, this.chosenCheckpoint);
|
|
||||||
|
|
||||||
return this.onlineScenery.scheduledTrains
|
return this.onlineScenery.scheduledTrains
|
||||||
.filter(
|
.filter(
|
||||||
(ct) =>
|
(ct) =>
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ export default defineComponent({
|
|||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
chosenTrain() {
|
chosenTrain() {
|
||||||
return this.store.trainList.find((train) => train.id == this.store.chosenModalTrainId);
|
return this.store.trainList.find((train) => train.modalId == this.store.chosenModalTrainId);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -18,8 +18,8 @@
|
|||||||
v-for="train in trains"
|
v-for="train in trains"
|
||||||
:key="train.id"
|
:key="train.id"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
@click.stop="selectModalTrain(train.id, $event.currentTarget)"
|
@click.stop="selectModalTrain(train, $event.currentTarget)"
|
||||||
@keydown.enter="selectModalTrain(train.id, $event.currentTarget)"
|
@keydown.enter="selectModalTrain(train, $event.currentTarget)"
|
||||||
>
|
>
|
||||||
<TrainInfo :train="train" :extended="false" />
|
<TrainInfo :train="train" :extended="false" />
|
||||||
</li>
|
</li>
|
||||||
@@ -77,17 +77,6 @@ export default defineComponent({
|
|||||||
|
|
||||||
return Status.Data.Loaded;
|
return Status.Data.Loaded;
|
||||||
}
|
}
|
||||||
},
|
|
||||||
|
|
||||||
activated() {
|
|
||||||
const query = this.$route.query;
|
|
||||||
if (query.trainNo && query.driverName) {
|
|
||||||
this.searchedDriver = query.driverName.toString();
|
|
||||||
this.searchedTrain = query.trainNo.toString();
|
|
||||||
setTimeout(() => {
|
|
||||||
this.selectModalTrain(query.driverName! + query.trainNo!.toString());
|
|
||||||
}, 20);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { defineComponent } from 'vue';
|
import { defineComponent } from 'vue';
|
||||||
import { useMainStore } from '../store/mainStore';
|
import { useMainStore } from '../store/mainStore';
|
||||||
import { useTooltipStore } from '../store/tooltipStore';
|
import { useTooltipStore } from '../store/tooltipStore';
|
||||||
|
import { Train } from '../typings/common';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
data() {
|
data() {
|
||||||
@@ -11,8 +12,14 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
selectModalTrain(trainId: string, target?: EventTarget | null) {
|
selectModalTrain(train: Train, target?: EventTarget | null) {
|
||||||
this.store.chosenModalTrainId = trainId;
|
this.store.chosenModalTrainId = train.modalId;
|
||||||
|
document.body.classList.add('no-scroll');
|
||||||
|
if (target) this.store.modalLastClickedTarget = target;
|
||||||
|
},
|
||||||
|
|
||||||
|
selectModalTrainById(modalId: string, target?: EventTarget | null) {
|
||||||
|
this.store.chosenModalTrainId = modalId;
|
||||||
document.body.classList.add('no-scroll');
|
document.body.classList.add('no-scroll');
|
||||||
if (target) this.store.modalLastClickedTarget = target;
|
if (target) this.store.modalLastClickedTarget = target;
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -60,8 +60,6 @@ export const useApiStore = defineStore('apiStore', {
|
|||||||
if (!this.activeData) this.dataStatuses.connection = Status.Data.Loading;
|
if (!this.activeData) this.dataStatuses.connection = Status.Data.Loading;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
console.log('Fetching active data at ' + new Date().toLocaleTimeString('pl-PL'));
|
|
||||||
|
|
||||||
const response = await this.client!.get<API.ActiveData.Response>('api/getActiveData');
|
const response = await this.client!.get<API.ActiveData.Response>('api/getActiveData');
|
||||||
|
|
||||||
this.activeData = response.data;
|
this.activeData = response.data;
|
||||||
|
|||||||
+12
-13
@@ -36,17 +36,13 @@ export const useMainStore = defineStore('mainStore', {
|
|||||||
}) as MainStoreState,
|
}) as MainStoreState,
|
||||||
|
|
||||||
getters: {
|
getters: {
|
||||||
checkpointsTrains() {
|
|
||||||
return checkpointsTrains;
|
|
||||||
},
|
|
||||||
|
|
||||||
trainList(): Train[] {
|
trainList(): Train[] {
|
||||||
const apiStore = useApiStore();
|
const apiStore = useApiStore();
|
||||||
|
|
||||||
checkpointsTrains.clear();
|
checkpointsTrains.clear();
|
||||||
sceneriesTrains.clear();
|
sceneriesTrains.clear();
|
||||||
|
|
||||||
const x = (apiStore.activeData?.trains ?? [])
|
return (apiStore.activeData?.trains ?? [])
|
||||||
.filter((train) => train.timetable || train.online)
|
.filter((train) => train.timetable || train.online)
|
||||||
.map((train) => {
|
.map((train) => {
|
||||||
const stock = train.stockString.split(';');
|
const stock = train.stockString.split(';');
|
||||||
@@ -65,6 +61,7 @@ export const useMainStore = defineStore('mainStore', {
|
|||||||
|
|
||||||
const trainObj = {
|
const trainObj = {
|
||||||
id: train.id,
|
id: train.id,
|
||||||
|
modalId: `${train.driverName}${train.trainNo}`, // simplified id for train modal
|
||||||
|
|
||||||
trainNo: train.trainNo,
|
trainNo: train.trainNo,
|
||||||
mass: train.mass,
|
mass: train.mass,
|
||||||
@@ -131,8 +128,6 @@ export const useMainStore = defineStore('mainStore', {
|
|||||||
|
|
||||||
return trainObj;
|
return trainObj;
|
||||||
});
|
});
|
||||||
|
|
||||||
return x;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// computed active sceneries
|
// computed active sceneries
|
||||||
@@ -143,7 +138,6 @@ export const useMainStore = defineStore('mainStore', {
|
|||||||
|
|
||||||
if (!apiStore.activeData?.activeSceneries) return [];
|
if (!apiStore.activeData?.activeSceneries) return [];
|
||||||
|
|
||||||
console.time('activeSceneryList');
|
|
||||||
const offlineActiveSceneries = this.trainList.reduce((acc, train) => {
|
const offlineActiveSceneries = this.trainList.reduce((acc, train) => {
|
||||||
if (!train.timetableData) return acc;
|
if (!train.timetableData) return acc;
|
||||||
|
|
||||||
@@ -238,9 +232,16 @@ export const useMainStore = defineStore('mainStore', {
|
|||||||
|
|
||||||
const station = this.stationList.find((s) => s.name === scenery.name);
|
const station = this.stationList.find((s) => s.name === scenery.name);
|
||||||
|
|
||||||
const checkpoints = [scenery.name];
|
let checkpointsSet: Set<string> = new Set();
|
||||||
if (station?.generalInfo?.checkpoints && station.generalInfo.checkpoints.length > 0)
|
|
||||||
checkpoints.push(...station.generalInfo.checkpoints.filter((cp) => cp !== station.name));
|
// Add checkpoints to active scenery data
|
||||||
|
checkpointsSet.add(scenery.name.toLowerCase());
|
||||||
|
|
||||||
|
station?.generalInfo?.checkpoints.forEach((cpName) => {
|
||||||
|
checkpointsSet.add(cpName.toLowerCase());
|
||||||
|
});
|
||||||
|
|
||||||
|
const checkpoints = Array.from(checkpointsSet);
|
||||||
|
|
||||||
scenery.stationTrains =
|
scenery.stationTrains =
|
||||||
sceneriesTrains.get(scenery.name)?.filter((sc) => sc.region == this.region.id) ?? [];
|
sceneriesTrains.get(scenery.name)?.filter((sc) => sc.region == this.region.id) ?? [];
|
||||||
@@ -266,8 +267,6 @@ export const useMainStore = defineStore('mainStore', {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
console.timeEnd('activeSceneryList');
|
|
||||||
|
|
||||||
return allActiveSceneries;
|
return allActiveSceneries;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ export interface RegionCounters {
|
|||||||
|
|
||||||
export interface Train {
|
export interface Train {
|
||||||
id: string;
|
id: string;
|
||||||
|
modalId: string;
|
||||||
mass: number;
|
mass: number;
|
||||||
length: number;
|
length: number;
|
||||||
speed: number;
|
speed: number;
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ export default defineComponent({
|
|||||||
|
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
if (this.trainId) {
|
if (this.trainId) {
|
||||||
this.selectModalTrain(this.trainId);
|
this.selectModalTrainById(this.trainId);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user