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