Rozszerzony rozkład jazdy

This commit is contained in:
2020-09-26 19:36:58 +02:00
parent 0b4a32eeb2
commit e347ab2277
7 changed files with 107 additions and 40 deletions
+5 -1
View File
@@ -1,5 +1,5 @@
<template> <template>
<div class="train-schedule"> <div class="train-schedule" @click="click">
<div class="schedule-wrapper"> <div class="schedule-wrapper">
<div class="schedule-bar"></div> <div class="schedule-bar"></div>
@@ -63,6 +63,10 @@ export default class TrainSchedule extends Vue {
return timeString + (delay != 0 ? " (" + (delay > 0 ? "+" : "") + delay.toString() + ")" : ""); return timeString + (delay != 0 ? " (" + (delay > 0 ? "+" : "") + delay.toString() + ")" : "");
} }
click() {
this.$emit('click')
}
} }
</script> </script>
@@ -28,6 +28,7 @@ export default class extends Vue {
searchedDriver = ""; searchedDriver = "";
@Prop() readonly passedSearchedTrain!: string; @Prop() readonly passedSearchedTrain!: string;
@Prop() readonly focusedTrain!: string;
// @Prop() readonly passedSearchedDriver!: string; // @Prop() readonly passedSearchedDriver!: string;
@Watch("searchedTrain") @Watch("searchedTrain")
@@ -48,6 +49,14 @@ export default class extends Vue {
} }
} }
@Watch("focusedTrain")
onFocusedTrainChanged(val: string, oldVal: string) {
console.log(val);
this.searchedTrain = val;
this.searchedDriver = "";
}
mounted() { mounted() {
if (this.passedSearchedTrain && this.passedSearchedTrain != "") { if (this.passedSearchedTrain && this.passedSearchedTrain != "") {
this.searchedTrain = this.passedSearchedTrain; this.searchedTrain = this.passedSearchedTrain;
+9 -8
View File
@@ -8,6 +8,7 @@
v-for="(train, i) in computedTrains" v-for="(train, i) in computedTrains"
:key="i" :key="i"
:id="train.timetableData.timetableId" :id="train.timetableData.timetableId"
@click="() => {changeFocusedTrain(train.trainNo);}"
> >
<span class="train-info"> <span class="train-info">
<span class="info"> <span class="info">
@@ -49,10 +50,7 @@
:class="{'online': train.online}" :class="{'online': train.online}"
>{{train.online ? "ONLINE" : "OFFLINE"}}</span> >{{train.online ? "ONLINE" : "OFFLINE"}}</span>
<button <button class="button">SZCZEGÓŁOWY ROZKŁAD</button>
class="button"
@click="changeScheduleShowState(train.timetableData.timetableId)"
>SZCZEGÓŁOWY ROZKŁAD</button>
</div> </div>
</span> </span>
@@ -124,7 +122,7 @@
:followingStops="train.timetableData.followingStops" :followingStops="train.timetableData.followingStops"
:currentStationName="train.currentStationName" :currentStationName="train.currentStationName"
@click="changeScheduleShowState(train.timetableData.timetableId)" @click="changeScheduleShowState(train.timetableData.timetableId)"
v-if="showSchedules.includes(train.timetableData.timetableId)" v-if="showedSchedule == train.timetableData.timetableId"
/> />
</li> </li>
</ul> </ul>
@@ -147,7 +145,7 @@ import TrainSchedule from "@/components/TrainsView/TrainSchedule.vue";
export default class TrainTable extends Vue { export default class TrainTable extends Vue {
@Prop() computedTrains!: Train[]; @Prop() computedTrains!: Train[];
showSchedules: number[] = []; showedSchedule = 0;
speedIcon: string = require("@/assets/icon-speed.svg"); speedIcon: string = require("@/assets/icon-speed.svg");
massIcon: string = require("@/assets/icon-mass.svg"); massIcon: string = require("@/assets/icon-mass.svg");
@@ -159,8 +157,7 @@ export default class TrainTable extends Vue {
routeIcon: string = require("@/assets/icon-route.svg"); routeIcon: string = require("@/assets/icon-route.svg");
changeScheduleShowState(timetableId: number) { changeScheduleShowState(timetableId: number) {
if (this.showSchedules.includes(timetableId)) this.showSchedules.splice(this.showSchedules.indexOf(timetableId), 1) this.showedSchedule = timetableId;
else this.showSchedules.push(timetableId);
} }
onImageError(e: Event) { onImageError(e: Event) {
@@ -177,6 +174,10 @@ export default class TrainTable extends Vue {
return acc; return acc;
}, []).join(" * "); }, []).join(" * ");
} }
changeFocusedTrain(trainNo: number) {
this.$emit('changeFocusedTrain', trainNo.toString());
}
} }
</script> </script>
+50 -4
View File
@@ -1,4 +1,5 @@
[{ [
{
"stationName": "Blaszki", "stationName": "Blaszki",
"stationURL": "https://td2.info.pl/scenerie/blaszki/", "stationURL": "https://td2.info.pl/scenerie/blaszki/",
"stationLines": "", "stationLines": "",
@@ -1748,7 +1749,7 @@
}, },
{ {
"stationName": "Hetmanice", "stationName": "Hetmanice",
"stationURL": "https://td2.info.pl/dzial-trenerski/hetmanice-stacja-dla-poczatkujacych/", "stationURL": "https://td2.info.pl/scenerie/hetmanice-stacja-dla-poczatkujacych/",
"stationLines": "", "stationLines": "",
"reqLevel": "0", "reqLevel": "0",
"supportersOnly": "NIE", "supportersOnly": "NIE",
@@ -1767,8 +1768,7 @@
} }
}, },
"default": false, "default": false,
"nonPublic": false, "nonPublic": false
"unavailable": true
}, },
{ {
"stationName": "Starzynki", "stationName": "Starzynki",
@@ -1865,5 +1865,51 @@
"nonPublic": false, "nonPublic": false,
"unavailable": true, "unavailable": true,
"stops": ["Sroka, podg."] "stops": ["Sroka, podg."]
},
{
"stationName": "Luzino",
"stationURL": "https://td2.info.pl/scenerie/luzino-6501/",
"stationLines": "",
"reqLevel": "3",
"supportersOnly": "NIE",
"signalType": "współczesna",
"controlType": "mechaniczne",
"SBL": "",
"twoWayBlock": "TAK",
"routes": {
"oneWay": {
"catenary": 2,
"noCatenary": 0
},
"twoWay": {
"catenary": 0,
"noCatenary": 0
}
},
"default": false,
"nonPublic": false
},
{
"stationName": "Zajączkowo",
"stationURL": "https://td2.info.pl/scenerie/zajaczkowo/",
"stationLines": "",
"reqLevel": "0",
"supportersOnly": "NIE",
"signalType": "kształtowa",
"controlType": "mechaniczne",
"SBL": "",
"twoWayBlock": "",
"routes": {
"oneWay": {
"catenary": 0,
"noCatenary": 2
},
"twoWay": {
"catenary": 0,
"noCatenary": 0
}
},
"default": false,
"nonPublic": false
} }
] ]
+1 -1
View File
@@ -1,4 +1,4 @@
export default interface { export default interface TrainStop {
stopName: string; stopName: string;
stopNameRAW: string; stopNameRAW: string;
stopType: string; stopType: string;
+8 -1
View File
@@ -7,11 +7,12 @@
@changeSearchedTrain="changeSearchedTrain" @changeSearchedTrain="changeSearchedTrain"
@changeSearchedDriver="changeSearchedDriver" @changeSearchedDriver="changeSearchedDriver"
:passedSearchedTrain="passedSearchedTrain" :passedSearchedTrain="passedSearchedTrain"
:focusedTrain="focusedTrain"
/> />
</div> </div>
<TrainStats :trains="trains" /> <TrainStats :trains="trains" />
<TrainTable :computedTrains="computedTrains" /> <TrainTable :computedTrains="computedTrains" @changeFocusedTrain="changeFocusedTrain" />
</div> </div>
</section> </section>
</template> </template>
@@ -44,8 +45,10 @@ export default class TrainsView extends Vue {
@Prop() readonly passedSearchedTrain!: string; @Prop() readonly passedSearchedTrain!: string;
sorterActive: { id: string; dir: number } = { id: "timetable", dir: 1 }; sorterActive: { id: string; dir: number } = { id: "timetable", dir: 1 };
searchedTrain: string = ""; searchedTrain: string = "";
searchedDriver: string = ""; searchedDriver: string = "";
focusedTrain: string = "";
changeSearchedTrain(trainNo: string) { changeSearchedTrain(trainNo: string) {
this.searchedTrain = trainNo; this.searchedTrain = trainNo;
@@ -55,6 +58,10 @@ export default class TrainsView extends Vue {
this.searchedDriver = name; this.searchedDriver = name;
} }
changeFocusedTrain(trainNo: string) {
this.focusedTrain = this.focusedTrain === trainNo ? "" : trainNo;
}
changeSorter(sorter: { id: string; dir: number }) { changeSorter(sorter: { id: string; dir: number }) {
this.sorterActive = sorter; this.sorterActive = sorter;
} }