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