Fix działania reaktywności linków

This commit is contained in:
2022-12-20 21:31:59 +01:00
parent 7ea558642f
commit e478c510b2
2 changed files with 14 additions and 3 deletions
+4 -1
View File
@@ -21,7 +21,9 @@
<i18n-t keypath="journal.timetable-stats-longest" tag="p">
<template #id>
<b>{{ data.stats.timetableId }}</b>
<router-link :to="`/journal/timetables?timetableId=${data.stats.timetableId}`">{{
data.stats.timetableId
}}</router-link>
</template>
<template #author>
<b>{{ data.stats.timetableAuthor }}</b>
@@ -53,6 +55,7 @@
<script setup lang="ts">
import axios from 'axios';
import { reactive, ref } from 'vue';
import { onBeforeRouteUpdate, useRouter } from 'vue-router';
import { DataStatus } from '../../scripts/enums/DataStatus';
import { ITimetablesDailyStats, ITimetablesDailyStatsResponse } from '../../scripts/interfaces/api/StatsAPIData';
import { URLs } from '../../scripts/utils/apiURLs';
+10 -2
View File
@@ -134,6 +134,16 @@ export default defineComponent({
};
},
// Handle route updates for route-links
beforeRouteUpdate(to, from) {
const timetableId = to.query['timetableId']?.toString();
if (!timetableId) return;
this.searchersValues['search-train'] = `#${timetableId}`;
this.searchHistory();
},
activated() {
if (this.timetableId) {
this.searchersValues['search-train'] = `#${this.timetableId}`;
@@ -142,8 +152,6 @@ export default defineComponent({
},
mounted() {
console.log('mounted');
if (!this.timetableId) this.searchHistory();
},