feat: router links embeded into timetable stop names

This commit is contained in:
2024-08-18 23:45:42 +02:00
parent 6bd62f13a1
commit 80a5b56785
6 changed files with 77 additions and 25 deletions
@@ -214,6 +214,12 @@ export default defineComponent({
this.loadSelectedOption();
},
watch: {
station() {
this.loadSelectedOption();
}
},
setup(props) {
const route = useRoute();
const currentURL = computed(() => `${location.origin}${route.fullPath}`);
+5 -2
View File
@@ -3,7 +3,9 @@
class="stop-label"
:data-minor="stop.isSBL || (stop.nameRaw.endsWith(', po.') && !stop.duration)"
>
<span class="name" v-html="stop.nameHtml"></span>
<router-link :to="`/scenery?station=${stop.sceneryName}`" @click="closeModal">
<span class="name" v-html="stop.nameHtml"></span>
</router-link>
<span
v-if="stop.position != 'begin'"
@@ -67,9 +69,10 @@
import { PropType, defineComponent } from 'vue';
import dateMixin from '../../mixins/dateMixin';
import { TrainScheduleStop } from './TrainSchedule.vue';
import modalTrainMixin from '../../mixins/modalTrainMixin';
export default defineComponent({
mixins: [dateMixin],
mixins: [dateMixin, modalTrainMixin],
props: {
stop: {
+9 -9
View File
@@ -165,20 +165,18 @@ export default defineComponent({
computed: {
scheduleStops(): TrainScheduleStop[] {
let currentSceneryIndex = 0;
if (!this.train.timetableData) return [];
const { timetablePath } = this.train.timetableData;
let currentPathIndex = 0;
return (
this.train.timetableData?.followingStops.map((stop, i, arr) => {
const isExternal =
i > 0 &&
stop.arrivalLine != null &&
(stop.arrivalLine != arr[i - 1].departureLine ||
(stop.arrivalLine == arr[i - 1].departureLine &&
!/-|_|(^it\d+)|(^sbl)/gi.test(stop.arrivalLine)));
i < arr.length - 1 &&
stop.departureLine === timetablePath[currentPathIndex].departureRouteExt;
if (isExternal) currentSceneryIndex++;
const sceneryName = this.train.timetableData!.sceneryNames[currentSceneryIndex];
const sceneryName = timetablePath[currentPathIndex].stationName;
const sceneryInfo = this.apiStore.sceneryData.find((st) => st.name == sceneryName);
const arrivalLineInfo = sceneryInfo?.routesInfo.find(
@@ -189,6 +187,8 @@ export default defineComponent({
(r) => r.routeName == stop.departureLine
);
if (isExternal) currentPathIndex++;
return {
nameHtml: stop.stopName,
nameRaw: stop.stopNameRAW,