Przekierowanie do historii dr

This commit is contained in:
2022-05-25 14:14:50 +02:00
parent 2e5f692a6f
commit 9aad5f77dc
5 changed files with 54 additions and 27 deletions
+2 -2
View File
@@ -70,7 +70,7 @@
/ /
<router-link class="route" active-class="route-active" to="/trains">{{ $t('app.trains') }} </router-link> <router-link class="route" active-class="route-active" to="/trains">{{ $t('app.trains') }} </router-link>
/ /
<router-link class="route" active-class="route-active" to="/journal" <router-link class="route" active-class="route-active" to="/journal?view=timetables"
>{{ $t('app.journal') }} >{{ $t('app.journal') }}
</router-link> </router-link>
</span> </span>
@@ -79,7 +79,7 @@
</header> </header>
<main class="app_main"> <main class="app_main">
<router-view v-slot="{ Component }"> <router-view v-slot="{ Component }" :key="$route.fullPath">
<!-- <transition name="view-anim" mode="out-in"> --> <!-- <transition name="view-anim" mode="out-in"> -->
<keep-alive> <keep-alive>
<component :is="Component" /> <component :is="Component" />
@@ -133,7 +133,12 @@ export default defineComponent({
mixins: [dateMixin], mixins: [dateMixin],
props: { props: {
searchedSceneryName: { sceneryName: {
type: String,
required: false,
},
dispatcherName: {
type: String, type: String,
required: false, required: false,
}, },
@@ -202,16 +207,25 @@ export default defineComponent({
}, },
mounted() { mounted() {
const query = this.$route.query;
console.log("Mounted");
if (query.sceneryName || query.dispatcherName) {
this.searchersValues[1].value = query.sceneryName?.toString() || "";
this.searchersValues[0].value = query.dispatcherName?.toString() || "";
this.search();
return;
}
this.fetchHistoryData(); this.fetchHistoryData();
}, },
activated() { activated() {
window.addEventListener('scroll', this.handleScroll); window.addEventListener('scroll', this.handleScroll);
if (this.searchedSceneryName) {
this.searchersValues[1].value = this.searchedSceneryName;
this.search();
}
}, },
deactivated() { deactivated() {
@@ -112,7 +112,7 @@
<!-- Nick dyżurnego --> <!-- Nick dyżurnego -->
<div v-if="item.authorName"> <div v-if="item.authorName">
<b class="text--grayed">{{ $t('journal.dispatcher-name') }}&nbsp;</b> <b class="text--grayed">{{ $t('journal.dispatcher-name') }}&nbsp;</b>
<b>{{ item.authorName }}</b> <router-link class="dispatcher-link" :to="`/journal?view=dispatchers&dispatcherName=${item.authorName}`">{{ item.authorName }}</router-link>
</div> </div>
</div> </div>
@@ -437,4 +437,8 @@ export default defineComponent({
} }
} }
} }
.dispatcher-link {
font-weight: bold;
}
</style> </style>
+1 -1
View File
@@ -21,7 +21,7 @@ const routes: Array<RouteRecordRaw> = [
{ {
path: "/journal", path: "/journal",
name: "JournalView", name: "JournalView",
component: () => import("@/views/JournalView.vue"), component: () => import("@/views/JournalView.vue")
}, },
{ {
path: '/:catchAll(.*)', path: '/:catchAll(.*)',
+26 -17
View File
@@ -1,27 +1,30 @@
<template> <template>
<section class="journal-view"> <section class="journal-view">
<div class="journal-type-options"> <div class="journal-type-options">
<button <router-link
class="btn btn--text" class="router-link"
:class="{ checked: journalTypeChosen == 'timetables' }" :class="{ active: journalTypeChosen == 'timetables' }"
@click="changeJournalType('timetables')" to="/journal?view=timetables"
> >
{{ $t('journal.section-timetables') }} {{ $t('journal.section-timetables') }}
</button> </router-link>
&nbsp;&bull;&nbsp; &nbsp;&bull;&nbsp;
<button <router-link
class="btn btn--text" class="router-link"
:class="{ checked: journalTypeChosen == 'dispatchers' }" :class="{ active: journalTypeChosen == 'dispatchers' }"
@click="changeJournalType('dispatchers')" to="/journal?view=dispatchers"
> >
{{ $t('journal.section-dispatchers') }} {{ $t('journal.section-dispatchers') }}
</button> </router-link>
</div> </div>
<div class="journal-section"> <div class="journal-section">
<keep-alive> <keep-alive>
<JournalTimetables v-if="journalTypeChosen == 'timetables'" /> <JournalTimetables v-if="journalTypeChosen == 'timetables'" />
<JournalDispatchers v-else-if="journalTypeChosen == 'dispatchers'" :searchedSceneryName="$route.query.sceneryName?.toString()" /> <JournalDispatchers
v-else-if="journalTypeChosen == 'dispatchers'"
:sceneryName="$route.query.sceneryName?.toString()"
/>
</keep-alive> </keep-alive>
</div> </div>
</section> </section>
@@ -29,15 +32,17 @@
<script lang="ts"> <script lang="ts">
import JournalTimetables from '@/components/JournalView/JournalTimetables.vue'; import JournalTimetables from '@/components/JournalView/JournalTimetables.vue';
import { defineComponent } from 'vue'; import { defineComponent, ref } from 'vue';
import JournalDispatchers from '@/components/JournalView/JournalDispatchers.vue'; import JournalDispatchers from '@/components/JournalView/JournalDispatchers.vue';
export default defineComponent({ export default defineComponent({
components: { JournalTimetables, JournalDispatchers }, components: { JournalTimetables, JournalDispatchers },
data() { setup() {
const journalTypeChosen = ref('timetables');
return { return {
journalTypeChosen: 'timetables', journalTypeChosen,
}; };
}, },
@@ -49,9 +54,9 @@ export default defineComponent({
activated() { activated() {
const query = this.$route.query; const query = this.$route.query;
if(query.sceneryName) this.journalTypeChosen = 'dispatchers'; if (query.view == 'dispatchers') this.journalTypeChosen = 'dispatchers';
} },
}); });
</script> </script>
@@ -76,4 +81,8 @@ export default defineComponent({
display: flex; display: flex;
justify-content: center; justify-content: center;
} }
.router-link.active {
color: gold;
}
</style> </style>