chore(filters): added station filtering by route types and maximum count

This commit is contained in:
2026-03-12 21:59:53 +01:00
parent 1a39c9054b
commit ffe26a8fd2
8 changed files with 62 additions and 40 deletions
+3 -3
View File
@@ -1,7 +1,7 @@
<template>
<div class="filter-slider">
<input
v-for="slider in sliderOptionsList[sliderGroup]"
v-for="slider in sliderGroupsOptions[sliderGroup]"
type="range"
:name="slider.id"
:id="slider.id"
@@ -15,13 +15,13 @@
<script lang="ts" setup>
import { inject, PropType } from 'vue';
import { SliderGroup, sliderOptionsList } from '../../managers/stationFilterManager';
import { SliderGroup, sliderGroupsOptions } from '../../managers/stationFilterManager';
const filters = inject('StationsView_filters') as Record<string, any>;
const props = defineProps({
sliderGroup: {
type: Object as PropType<SliderGroup>,
type: String as PropType<SliderGroup>,
required: true
}
});
@@ -141,8 +141,8 @@
<FilterSlider :sliderGroup="sliderGroup" />
<span class="slider-value">
{{ filters[sliderOptionsList[sliderGroup][0].id] }} -
{{ filters[sliderOptionsList[sliderGroup][1].id] }}
{{ filters[sliderGroupsOptions[sliderGroup][0].id] }} -
{{ filters[sliderGroupsOptions[sliderGroup][1].id] }}
</span>
<div class="slider-content">
@@ -194,7 +194,7 @@ import {
initFilters,
sliderGroups,
getChangedFilters,
sliderOptionsList
sliderGroupsOptions
} from '../../managers/stationFilterManager';
import { StationFilterSection } from '../../managers/stationFilterManager';
@@ -212,7 +212,7 @@ export default defineComponent({
filtersSections,
sliderGroups,
sliderOptionsList,
sliderGroupsOptions,
minimumHours: 0,
+33 -21
View File
@@ -120,28 +120,40 @@ function filterSliderValues(filters: Record<string, any>, generalInfo: StationGe
const otherAvailability =
availability == 'nonPublic' || availability == 'unavailable' || availability == 'abandoned';
const internalRoutes = routes.all.filter((r) => r.isInternal && !r.isRouteSBL && !r.hidden);
if (filters['minLevel'] > reqLevel + (otherAvailability ? 1 : 0)) return true;
if (filters['maxLevel'] < reqLevel + (otherAvailability ? 1 : 0)) return true;
if (filters['minVmax'] > routes.maxRouteSpeed) return true;
if (filters['maxVmax'] < routes.minRouteSpeed) return true;
return (
filters['minLevel'] > reqLevel + (otherAvailability ? 1 : 0) ||
filters['maxLevel'] < reqLevel + (otherAvailability ? 1 : 0) ||
filters['minVmax'] > routes.maxRouteSpeed ||
filters['maxVmax'] < routes.minRouteSpeed ||
(filters['no-1track'] && routes.single.length != 0) ||
(filters['no-2track'] && routes.double.length != 0) ||
filters['minOneWayCatenary'] > routes.singleElectrifiedNames.length ||
filters['minOneWay'] > routes.singleOtherNames.length ||
filters['minTwoWayCatenary'] > routes.doubleElectrifiedNames.length ||
filters['minTwoWay'] > routes.doubleOtherNames.length ||
filters['minOneWayCatenaryInt'] >
internalRoutes.filter((r) => r.routeTracks == 1 && r.isElectric == true).length ||
filters['minOneWayInt'] >
internalRoutes.filter((r) => r.routeTracks == 1 && r.isElectric == false).length ||
filters['minTwoWayCatenaryInt'] >
internalRoutes.filter((r) => r.routeTracks == 2 && r.isElectric == true).length ||
filters['minTwoWayInt'] >
internalRoutes.filter((r) => r.routeTracks == 2 && r.isElectric == false).length
);
if (filters['oneWay'] && routes.singleOtherNames.length > 0) return true;
if (filters['oneWayCatenary'] && routes.singleElectrifiedNames.length > 0) return true;
if (filters['twoWay'] && routes.doubleOtherNames.length > 0) return true;
if (filters['twoWayCatenary'] && routes.doubleElectrifiedNames.length > 0) return true;
if (filters['minOneWay'] > routes.singleOtherNames.length) return true;
if (filters['maxOneWay'] < routes.singleOtherNames.length) return true;
if (filters['minOneWayCatenary'] > routes.singleElectrifiedNames.length) return true;
if (filters['maxOneWayCatenary'] < routes.singleElectrifiedNames.length) return true;
if (filters['minTwoWay'] > routes.doubleOtherNames.length) return true;
if (filters['maxTwoWay'] < routes.doubleOtherNames.length) return true;
if (filters['minTwoWayCatenary'] > routes.doubleElectrifiedNames.length) return true;
if (filters['maxTwoWayCatenary'] < routes.doubleElectrifiedNames.length) return true;
if (filters['oneWayInt'] && routes.singleOtherInternalNames.length > 0) return true;
if (filters['oneWayCatenaryInt'] && routes.singleElectrifiedInternalNames.length > 0) return true;
if (filters['twoWayInt'] && routes.doubleOtherInternalNames.length > 0) return true;
if (filters['twoWayCatenaryInt'] && routes.doubleElectrifiedInternalNames.length > 0) return true;
// Internal routes
if (filters['minOneWayInt'] > routes.singleOtherInternalNames.length) return true;
if (filters['maxOneWayInt'] < routes.singleOtherInternalNames.length) return true;
if (filters['minOneWayCatenaryInt'] > routes.singleElectrifiedInternalNames.length) return true;
if (filters['maxOneWayCatenaryInt'] < routes.singleElectrifiedInternalNames.length) return true;
if (filters['minTwoWayInt'] > routes.doubleOtherInternalNames.length) return true;
if (filters['maxTwoWayInt'] < routes.doubleOtherInternalNames.length) return true;
if (filters['minTwoWayCatenaryInt'] > routes.doubleElectrifiedInternalNames.length) return true;
if (filters['maxTwoWayCatenaryInt'] < routes.doubleElectrifiedInternalNames.length) return true;
}
function filterInputValues(filters: Record<string, any>, generalInfo: StationGeneralInfo) {
-1
View File
@@ -316,7 +316,6 @@
"now": "NOW",
"hour": "h",
"no-limit": "NO LIMIT",
"include-selected": "INCLUDE SELECTED",
"save": "REMEMBER FILTERS",
"reset": "RESET FILTERS",
"close": "CLOSE FILTERS"
-1
View File
@@ -324,7 +324,6 @@
"now": "TERAZ",
"hour": " godz.",
"no-limit": "BEZ LIMITU",
"include-selected": "POKAŻ ZAZNACZONE",
"save": "ZAPAMIĘTAJ FILTRY",
"reset": "RESETUJ FILTRY",
"close": "ZAMKNIJ FILTRY"
+1 -4
View File
@@ -59,9 +59,6 @@ export const initFilters = {
mixed: false,
SBL: false,
PBL: false,
'include-selected': false,
'no-1track': false,
'no-2track': false,
free: true,
occupied: false,
nonPublic: false,
@@ -123,7 +120,7 @@ export const sliderGroups: SliderGroup[] = [
'routeTwoWayInternalCatenary'
];
export const sliderOptionsList: Record<SliderGroup, SliderOptions[]> = {
export const sliderGroupsOptions: Record<SliderGroup, SliderOptions[]> = {
vMax: [
{ id: 'minVmax', minRange: 0, maxRange: 200, step: 10 },
{ id: 'maxVmax', minRange: 0, maxRange: 200, step: 10 }
+14 -5
View File
@@ -29,7 +29,7 @@ export const useMainStore = defineStore('mainStore', {
chosenModalTrainId: undefined,
modalLastClickedTarget: null,
currentLocale: 'pl',
currentLocale: 'pl'
}) as MainStoreState,
actions: {
@@ -391,11 +391,13 @@ export const useMainStore = defineStore('mainStore', {
const tracksKey = route.routeTracks == 2 ? 'double' : 'single';
const isElectric = route.isElectric;
const routesKey: keyof StationRoutes = `${tracksKey}${
!isElectric ? 'Other' : 'Electrified'
}Names`;
}${route.isInternal ? 'Internal' : ''}Names`;
acc[routesKey].push(route.routeName);
if (!route.isInternal) acc[routesKey].push(route.routeName);
if (route.isRouteSBL) acc['sblNames'].push(route.routeName);
acc.minRouteSpeed =
@@ -410,14 +412,21 @@ export const useMainStore = defineStore('mainStore', {
return acc;
},
{
all: [],
single: [],
double: [],
singleElectrifiedNames: [],
singleOtherNames: [],
double: [],
doubleElectrifiedNames: [],
doubleOtherNames: [],
singleElectrifiedInternalNames: [],
singleOtherInternalNames: [],
doubleElectrifiedInternalNames: [],
doubleOtherInternalNames: [],
sblNames: [],
all: [],
minRouteSpeed: 0,
maxRouteSpeed: 0
} as StationRoutes
+7 -1
View File
@@ -130,6 +130,12 @@ export interface StationRoutes {
singleOtherNames: string[];
doubleElectrifiedNames: string[];
doubleOtherNames: string[];
singleElectrifiedInternalNames: string[];
singleOtherInternalNames: string[];
doubleElectrifiedInternalNames: string[];
doubleOtherInternalNames: string[];
sblNames: string[];
minRouteSpeed: number;
@@ -241,4 +247,4 @@ export interface TooltipTrainInfo {
headVehicleName: string;
stockCount: number;
trainTimetableCategory?: string;
}
}