mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-04 22:08:12 +00:00
filtrowanie ukrytych szlaków
This commit is contained in:
@@ -1,41 +1,49 @@
|
|||||||
<template>
|
<template>
|
||||||
<section class="info-routes" v-if="station.generalInfo">
|
<section class="info-routes" v-if="station.generalInfo">
|
||||||
<div class="routes one-way" v-if="station.generalInfo.routes.oneWay.length > 0">
|
<div class="routes one-way" v-if="filteredOneWayRoutes.length > 0">
|
||||||
<b>{{ $t('scenery.one-way-routes') }}</b>
|
<b>{{ $t('scenery.one-way-routes') }}</b>
|
||||||
|
|
||||||
<ul class="routes-list">
|
<ul class="routes-list">
|
||||||
<li
|
<li
|
||||||
v-for="route in station.generalInfo.routes.oneWay"
|
v-for="route in filteredOneWayRoutes"
|
||||||
:key="route.name"
|
:key="route.routeName"
|
||||||
@click="setActiveShowLength(route.name)"
|
@click="setActiveShowLength(route.routeName)"
|
||||||
>
|
>
|
||||||
<span :class="{ 'no-catenary': !route.catenary, internal: route.isInternal }">
|
<span :class="{ 'no-catenary': !route.isElectric, internal: route.isInternal }">
|
||||||
{{ route.name }}</span
|
{{ route.routeName }}</span
|
||||||
>
|
>
|
||||||
<span v-if="route.speed" class="speed">
|
<span v-if="route.routeSpeed" class="speed">
|
||||||
{{ activeShowLength.includes(route.name) ? route.length + 'm' : route.speed }}
|
{{
|
||||||
|
activeShowLength.includes(route.routeName)
|
||||||
|
? route.routeLength + 'm'
|
||||||
|
: route.routeSpeed
|
||||||
|
}}
|
||||||
</span>
|
</span>
|
||||||
<span v-if="route.SBL" class="sbl">SBL</span>
|
<span v-if="route.isRouteSBL" class="sbl">SBL</span>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="routes two-way" v-if="station.generalInfo.routes.twoWay.length > 0">
|
<div class="routes two-way" v-if="filteredTwoWayRoutes.length > 0">
|
||||||
<b>{{ $t('scenery.two-way-routes') }}</b>
|
<b>{{ $t('scenery.two-way-routes') }}</b>
|
||||||
|
|
||||||
<ul class="routes-list">
|
<ul class="routes-list">
|
||||||
<li
|
<li
|
||||||
v-for="route in station.generalInfo.routes.twoWay"
|
v-for="route in filteredTwoWayRoutes"
|
||||||
:key="route.name"
|
:key="route.routeName"
|
||||||
@click="setActiveShowLength(route.name)"
|
@click="setActiveShowLength(route.routeName)"
|
||||||
>
|
>
|
||||||
<span :class="{ 'no-catenary': !route.catenary, internal: route.isInternal }">{{
|
<span :class="{ 'no-catenary': !route.isElectric, internal: route.isInternal }">{{
|
||||||
route.name
|
route.routeName
|
||||||
}}</span>
|
}}</span>
|
||||||
<span v-if="route.speed" class="speed">
|
<span v-if="route.routeSpeed" class="speed">
|
||||||
{{ activeShowLength.includes(route.name) ? route.length + 'm' : route.speed }}
|
{{
|
||||||
|
activeShowLength.includes(route.routeName)
|
||||||
|
? route.routeLength + 'm'
|
||||||
|
: route.routeSpeed
|
||||||
|
}}
|
||||||
</span>
|
</span>
|
||||||
<span v-if="route.SBL" class="sbl">SBL</span>
|
<span v-if="route.isRouteSBL" class="sbl">SBL</span>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
@@ -45,6 +53,9 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { PropType, defineComponent } from 'vue';
|
import { PropType, defineComponent } from 'vue';
|
||||||
import Station from '../../../scripts/interfaces/Station';
|
import Station from '../../../scripts/interfaces/Station';
|
||||||
|
import { StationRoutesInfo } from '../../../store/typings';
|
||||||
|
|
||||||
|
const routeFilter = (route: StationRoutesInfo) => !route.hidden;
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
props: {
|
props: {
|
||||||
@@ -66,6 +77,16 @@ export default defineComponent({
|
|||||||
return {
|
return {
|
||||||
activeShowLength: [] as string[]
|
activeShowLength: [] as string[]
|
||||||
};
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
computed: {
|
||||||
|
filteredOneWayRoutes() {
|
||||||
|
return this.station.generalInfo?.routes.oneWay.filter(routeFilter) || [];
|
||||||
|
},
|
||||||
|
|
||||||
|
filteredTwoWayRoutes() {
|
||||||
|
return this.station.generalInfo?.routes.twoWay.filter(routeFilter) || [];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Availability, OnlineScenery, ScheduledTrain } from '../../store/typings';
|
import { Availability, OnlineScenery, ScheduledTrain } from '../../store/typings';
|
||||||
import StationRoutes from './StationRoutes';
|
import { StationRoutes } from './StationRoutes';
|
||||||
|
|
||||||
export default interface Station {
|
export default interface Station {
|
||||||
name: string;
|
name: string;
|
||||||
|
|||||||
@@ -1,25 +1,8 @@
|
|||||||
export default interface StationRoutes {
|
import { StationRoutesInfo } from '../../store/typings';
|
||||||
oneWay: {
|
|
||||||
name: string;
|
|
||||||
catenary: boolean;
|
|
||||||
SBL: boolean;
|
|
||||||
TWB: boolean;
|
|
||||||
isInternal: boolean;
|
|
||||||
tracks: number;
|
|
||||||
speed: number;
|
|
||||||
length: number;
|
|
||||||
}[];
|
|
||||||
|
|
||||||
twoWay: {
|
export interface StationRoutes {
|
||||||
name: string;
|
oneWay: StationRoutesInfo[];
|
||||||
catenary: boolean;
|
twoWay: StationRoutesInfo[];
|
||||||
SBL: boolean;
|
|
||||||
TWB: boolean;
|
|
||||||
isInternal: boolean;
|
|
||||||
tracks: number;
|
|
||||||
speed: number;
|
|
||||||
length: number;
|
|
||||||
}[];
|
|
||||||
|
|
||||||
/* [catenary, noCatenary] */
|
/* [catenary, noCatenary] */
|
||||||
oneWayCatenaryRouteNames: string[];
|
oneWayCatenaryRouteNames: string[];
|
||||||
|
|||||||
+28
-35
@@ -1,5 +1,4 @@
|
|||||||
import { defineStore } from 'pinia';
|
import { defineStore } from 'pinia';
|
||||||
import StationRoutes from '../scripts/interfaces/StationRoutes';
|
|
||||||
import Train from '../scripts/interfaces/Train';
|
import Train from '../scripts/interfaces/Train';
|
||||||
import { parseSpawns, getScheduledTrains, getStationTrains } from './utils';
|
import { parseSpawns, getScheduledTrains, getStationTrains } from './utils';
|
||||||
|
|
||||||
@@ -9,6 +8,7 @@ import { Status } from '../typings/common';
|
|||||||
import Station from '../scripts/interfaces/Station';
|
import Station from '../scripts/interfaces/Station';
|
||||||
import { useApiStore } from './apiStore';
|
import { useApiStore } from './apiStore';
|
||||||
import { API } from '../typings/api';
|
import { API } from '../typings/api';
|
||||||
|
import { StationRoutes } from '../scripts/interfaces/StationRoutes';
|
||||||
|
|
||||||
export const useMainStore = defineStore('store', {
|
export const useMainStore = defineStore('store', {
|
||||||
state: () =>
|
state: () =>
|
||||||
@@ -155,46 +155,39 @@ export const useMainStore = defineStore('store', {
|
|||||||
const apiStore = useApiStore();
|
const apiStore = useApiStore();
|
||||||
|
|
||||||
return apiStore.sceneryData.map((scenery) => {
|
return apiStore.sceneryData.map((scenery) => {
|
||||||
|
const routes = scenery.routesInfo.reduce(
|
||||||
|
(acc, route) => {
|
||||||
|
const tracksKey = route.routeTracks == 2 ? 'twoWay' : 'oneWay';
|
||||||
|
const isElectric = route.isElectric;
|
||||||
|
const routesKey: keyof StationRoutes = `${tracksKey}${
|
||||||
|
!isElectric ? 'No' : ''
|
||||||
|
}CatenaryRouteNames`;
|
||||||
|
|
||||||
|
if (!route.isInternal) acc[routesKey].push(route.routeName);
|
||||||
|
if (route.isRouteSBL) acc['sblRouteNames'].push(route.routeName);
|
||||||
|
|
||||||
|
acc[tracksKey].push(route);
|
||||||
|
|
||||||
|
return acc;
|
||||||
|
},
|
||||||
|
{
|
||||||
|
oneWay: [],
|
||||||
|
oneWayCatenaryRouteNames: [],
|
||||||
|
oneWayNoCatenaryRouteNames: [],
|
||||||
|
twoWay: [],
|
||||||
|
twoWayCatenaryRouteNames: [],
|
||||||
|
twoWayNoCatenaryRouteNames: [],
|
||||||
|
sblRouteNames: []
|
||||||
|
} as StationRoutes
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name: scenery.name,
|
name: scenery.name,
|
||||||
|
|
||||||
generalInfo: {
|
generalInfo: {
|
||||||
...scenery,
|
...scenery,
|
||||||
authors: scenery.authors?.split(',').map((a) => a.trim()),
|
authors: scenery.authors?.split(',').map((a) => a.trim()),
|
||||||
routes:
|
routes: routes,
|
||||||
scenery.routesInfo.reduce(
|
|
||||||
(acc, route) => {
|
|
||||||
const propName: keyof StationRoutes = `${
|
|
||||||
route.routeTracks == 2 ? 'twoWay' : 'oneWay'
|
|
||||||
}${route.isElectric ? '' : 'No'}CatenaryRouteNames`;
|
|
||||||
|
|
||||||
acc[route.routeTracks == 2 ? 'twoWay' : 'oneWay'].push({
|
|
||||||
name: route.routeName,
|
|
||||||
SBL: route.isRouteSBL,
|
|
||||||
TWB: false,
|
|
||||||
catenary: route.isElectric,
|
|
||||||
isInternal: route.isInternal,
|
|
||||||
tracks: route.routeTracks,
|
|
||||||
length: route.routeLength,
|
|
||||||
speed: route.routeSpeed
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!route.isInternal) acc[propName].push(route.routeName);
|
|
||||||
|
|
||||||
if (route.isRouteSBL) acc['sblRouteNames'].push(route.routeName);
|
|
||||||
|
|
||||||
return acc;
|
|
||||||
},
|
|
||||||
{
|
|
||||||
oneWay: [],
|
|
||||||
twoWay: [],
|
|
||||||
sblRouteNames: [],
|
|
||||||
oneWayCatenaryRouteNames: [],
|
|
||||||
oneWayNoCatenaryRouteNames: [],
|
|
||||||
twoWayCatenaryRouteNames: [],
|
|
||||||
twoWayNoCatenaryRouteNames: []
|
|
||||||
} as StationRoutes
|
|
||||||
) || {},
|
|
||||||
checkpoints: scenery.checkpoints
|
checkpoints: scenery.checkpoints
|
||||||
? scenery.checkpoints
|
? scenery.checkpoints
|
||||||
.split(';')
|
.split(';')
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ export interface StationRoutesInfo {
|
|||||||
routeLength: number;
|
routeLength: number;
|
||||||
routeSpeed: number;
|
routeSpeed: number;
|
||||||
routeTracks: number;
|
routeTracks: number;
|
||||||
|
hidden?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface StationJSONData {
|
export interface StationJSONData {
|
||||||
|
|||||||
Reference in New Issue
Block a user