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) {
|
||||
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"
|
||||
:key="train.id"
|
||||
:data-status="status"
|
||||
@click.prevent="selectModalTrain(train.id, $event.currentTarget)"
|
||||
@keydown.enter="selectModalTrain(train.id, $event.currentTarget)"
|
||||
@click.prevent="selectModalTrain(train, $event.currentTarget)"
|
||||
@keydown.enter="selectModalTrain(train, $event.currentTarget)"
|
||||
>
|
||||
<span class="user_train">{{ train.trainNo }}</span>
|
||||
<span class="user_name">{{ train.driverName }}</span>
|
||||
|
||||
@@ -39,8 +39,8 @@
|
||||
<div class="timetable-list">
|
||||
<transition-group name="list-anim">
|
||||
<div
|
||||
style="padding-bottom: 5em"
|
||||
v-if="apiStore.dataStatuses.connection == 0 && sceneryTimetables.length == 0"
|
||||
style="padding-bottom: 5em"
|
||||
key="list-loading"
|
||||
>
|
||||
<Loading />
|
||||
@@ -65,11 +65,11 @@
|
||||
<div
|
||||
class="timetable-item"
|
||||
v-else
|
||||
v-for="row in sceneryTimetables"
|
||||
:key="row.train.id + row.checkpointStop.arrivalTimestamp"
|
||||
v-for="(row, i) in sceneryTimetables"
|
||||
:key="row.train.id"
|
||||
tabindex="0"
|
||||
@click.prevent.stop="selectModalTrain(row.train.id, $event.currentTarget)"
|
||||
@keydown.enter.prevent="selectModalTrain(row.train.id, $event.currentTarget)"
|
||||
@click.prevent.stop="selectModalTrain(row.train, $event.currentTarget)"
|
||||
@keydown.enter.prevent="selectModalTrain(row.train, $event.currentTarget)"
|
||||
>
|
||||
<span class="timetable-general">
|
||||
<span class="general-info">
|
||||
@@ -236,8 +236,6 @@ export default defineComponent({
|
||||
if (!this.station) return [];
|
||||
if (!this.onlineScenery) return [];
|
||||
|
||||
console.log(this.onlineScenery.scheduledTrains, this.chosenCheckpoint);
|
||||
|
||||
return this.onlineScenery.scheduledTrains
|
||||
.filter(
|
||||
(ct) =>
|
||||
|
||||
@@ -21,7 +21,7 @@ export default defineComponent({
|
||||
|
||||
computed: {
|
||||
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"
|
||||
:key="train.id"
|
||||
tabindex="0"
|
||||
@click.stop="selectModalTrain(train.id, $event.currentTarget)"
|
||||
@keydown.enter="selectModalTrain(train.id, $event.currentTarget)"
|
||||
@click.stop="selectModalTrain(train, $event.currentTarget)"
|
||||
@keydown.enter="selectModalTrain(train, $event.currentTarget)"
|
||||
>
|
||||
<TrainInfo :train="train" :extended="false" />
|
||||
</li>
|
||||
@@ -77,17 +77,6 @@ export default defineComponent({
|
||||
|
||||
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>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { defineComponent } from 'vue';
|
||||
import { useMainStore } from '../store/mainStore';
|
||||
import { useTooltipStore } from '../store/tooltipStore';
|
||||
import { Train } from '../typings/common';
|
||||
|
||||
export default defineComponent({
|
||||
data() {
|
||||
@@ -11,8 +12,14 @@ export default defineComponent({
|
||||
},
|
||||
|
||||
methods: {
|
||||
selectModalTrain(trainId: string, target?: EventTarget | null) {
|
||||
this.store.chosenModalTrainId = trainId;
|
||||
selectModalTrain(train: Train, target?: EventTarget | null) {
|
||||
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');
|
||||
if (target) this.store.modalLastClickedTarget = target;
|
||||
},
|
||||
|
||||
@@ -60,8 +60,6 @@ export const useApiStore = defineStore('apiStore', {
|
||||
if (!this.activeData) this.dataStatuses.connection = Status.Data.Loading;
|
||||
|
||||
try {
|
||||
console.log('Fetching active data at ' + new Date().toLocaleTimeString('pl-PL'));
|
||||
|
||||
const response = await this.client!.get<API.ActiveData.Response>('api/getActiveData');
|
||||
|
||||
this.activeData = response.data;
|
||||
|
||||
+12
-13
@@ -36,17 +36,13 @@ export const useMainStore = defineStore('mainStore', {
|
||||
}) as MainStoreState,
|
||||
|
||||
getters: {
|
||||
checkpointsTrains() {
|
||||
return checkpointsTrains;
|
||||
},
|
||||
|
||||
trainList(): Train[] {
|
||||
const apiStore = useApiStore();
|
||||
|
||||
checkpointsTrains.clear();
|
||||
sceneriesTrains.clear();
|
||||
|
||||
const x = (apiStore.activeData?.trains ?? [])
|
||||
return (apiStore.activeData?.trains ?? [])
|
||||
.filter((train) => train.timetable || train.online)
|
||||
.map((train) => {
|
||||
const stock = train.stockString.split(';');
|
||||
@@ -65,6 +61,7 @@ export const useMainStore = defineStore('mainStore', {
|
||||
|
||||
const trainObj = {
|
||||
id: train.id,
|
||||
modalId: `${train.driverName}${train.trainNo}`, // simplified id for train modal
|
||||
|
||||
trainNo: train.trainNo,
|
||||
mass: train.mass,
|
||||
@@ -131,8 +128,6 @@ export const useMainStore = defineStore('mainStore', {
|
||||
|
||||
return trainObj;
|
||||
});
|
||||
|
||||
return x;
|
||||
},
|
||||
|
||||
// computed active sceneries
|
||||
@@ -143,7 +138,6 @@ export const useMainStore = defineStore('mainStore', {
|
||||
|
||||
if (!apiStore.activeData?.activeSceneries) return [];
|
||||
|
||||
console.time('activeSceneryList');
|
||||
const offlineActiveSceneries = this.trainList.reduce((acc, train) => {
|
||||
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 checkpoints = [scenery.name];
|
||||
if (station?.generalInfo?.checkpoints && station.generalInfo.checkpoints.length > 0)
|
||||
checkpoints.push(...station.generalInfo.checkpoints.filter((cp) => cp !== station.name));
|
||||
let checkpointsSet: Set<string> = new Set();
|
||||
|
||||
// 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 =
|
||||
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;
|
||||
},
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ export interface RegionCounters {
|
||||
|
||||
export interface Train {
|
||||
id: string;
|
||||
modalId: string;
|
||||
mass: number;
|
||||
length: number;
|
||||
speed: number;
|
||||
|
||||
@@ -109,7 +109,7 @@ export default defineComponent({
|
||||
|
||||
this.$nextTick(() => {
|
||||
if (this.trainId) {
|
||||
this.selectModalTrain(this.trainId);
|
||||
this.selectModalTrainById(this.trainId);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user