Use <router-link> instead of <tr> with click handler in StationTable

This commit is contained in:
dominik-korsa
2024-08-21 14:41:11 +02:00
parent 41e4b45599
commit 81cd165fe7
5 changed files with 26 additions and 27 deletions
@@ -19,7 +19,7 @@
:key="train.id"
:data-status="status"
>
<router-link :to="train.driverRouteLocation" class="block-link">
<router-link :to="train.driverRouteLocation" class="a-block">
<span class="user_train">{{ train.trainNo }}</span>
<span class="user_name">{{ train.driverName }}</span>
</router-link>
@@ -64,7 +64,7 @@
</div>
<router-link
class="timetable-item block-link"
class="timetable-item a-block"
v-else
v-for="(row, i) in sceneryTimetables"
:key="row.train.id + i"
@@ -175,7 +175,7 @@
</template>
<script lang="ts">
import { computed, defineComponent, PropType, ref, watch } from 'vue';
import { computed, defineComponent, PropType, ref } from 'vue';
import { useRoute } from 'vue-router';
import Loading from '../Global/Loading.vue';
+12 -16
View File
@@ -52,15 +52,15 @@
</thead>
<tbody>
<tr
<router-link
v-for="station in filteredStationList"
:class="{ 'last-selected': lastSelectedStationName == station.name }"
class="a-row"
role="row"
:key="station.name"
@click.left="setScenery(station.name)"
@click.right="openForumSite($event, station.generalInfo?.url)"
@keydown.enter="setScenery(station.name)"
@keydown.space="openForumSite($event, station.generalInfo?.url)"
@click.right.prevent="openForumSite($event, station.generalInfo?.url)"
@keydown.space.prevent="openForumSite($event, station.generalInfo?.url)"
tabindex="0"
:to="getSceneryRoute(station.name)"
>
<td class="station-name" :class="station.generalInfo?.availability">
<b v-if="station.generalInfo?.project" style="color: salmon">{{
@@ -294,7 +294,7 @@
>
{{ station.onlineInfo?.scheduledTrainCount.confirmed ?? '-' }}
</td>
</tr>
</router-link>
</tbody>
</table>
@@ -334,7 +334,6 @@ export default defineComponent({
data: () => ({
headIconsIds,
headIds,
lastSelectedStationName: '',
getChangedFilters
}),
@@ -364,21 +363,18 @@ export default defineComponent({
},
methods: {
setScenery(name: string) {
getSceneryRoute(name: string) {
const station = this.filteredStationList.find((station) => station.name === name);
if (!station) return;
// TODO: Hide tooltips when navigating away
this.lastSelectedStationName = station.name;
this.tooltipStore.hide();
this.$router.push({
return {
name: 'SceneryView',
query: {
station: station.name,
region: this.$route.query.region || undefined
}
});
};
},
openDonationCard(e: Event) {
@@ -503,7 +499,7 @@ table {
}
}
tr {
tr, .a-row {
background-color: $rowCol;
&:nth-child(even) {
+1 -1
View File
@@ -18,7 +18,7 @@
v-for="train in trains"
:key="train.id"
>
<router-link class="block-link" :to="train.driverRouteLocation">
<router-link class="a-block" :to="train.driverRouteLocation">
<TrainInfo :train="train" :extended="false" />
</router-link>
</li>
+10 -7
View File
@@ -123,11 +123,13 @@ input {
border-radius: 50%;
}
a:not(.block-link):not(.a-button) {
display: inline-block;
color: white;
a {
text-decoration: none;
color: inherit;
}
a:not(.a-block):not(.a-button):not(.a-row) {
display: inline-block;
transition: color 0.3s;
@@ -138,11 +140,12 @@ a:not(.block-link):not(.a-button) {
}
}
a.block-link {
a.a-block {
display: block;
}
color: inherit;
text-decoration: none;
a.a-row {
display: table-row;
}
ul {