From e41b8cfa98190e63838f77f9125eed522bef4daf Mon Sep 17 00:00:00 2001 From: Spythere Date: Mon, 17 Mar 2025 14:04:43 +0100 Subject: [PATCH] chore: added internal station routes filters --- .../StationsView/StationFilterCard.vue | 14 +++++++++----- src/components/StationsView/utils.ts | 12 ++++++++++-- src/locales/en.json | 6 +++++- src/locales/pl.json | 6 +++++- src/managers/stationFilterManager.ts | 17 ++++++++++++----- 5 files changed, 41 insertions(+), 14 deletions(-) diff --git a/src/components/StationsView/StationFilterCard.vue b/src/components/StationsView/StationFilterCard.vue index 3227693..d843686 100644 --- a/src/components/StationsView/StationFilterCard.vue +++ b/src/components/StationsView/StationFilterCard.vue @@ -121,7 +121,7 @@
-
+
, generalInfo: StationGe const otherAvailability = availability == 'nonPublic' || availability == 'unavailable' || availability == 'abandoned'; + const internalRoutes = routes.all.filter((r) => r.isInternal && !r.isRouteSBL && !r.hidden); + return ( filters['minLevel'] > reqLevel + (otherAvailability ? 1 : 0) || filters['maxLevel'] < reqLevel + (otherAvailability ? 1 : 0) || @@ -130,7 +132,13 @@ function filterSliderValues(filters: Record, generalInfo: StationGe filters['minOneWayCatenary'] > routes.singleElectrifiedNames.length || filters['minOneWay'] > routes.singleOtherNames.length || filters['minTwoWayCatenary'] > routes.doubleElectrifiedNames.length || - filters['minTwoWay'] > routes.doubleOtherNames.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 ); } @@ -235,7 +243,7 @@ export const sortStations = (a: Station, b: Station, sorter: ActiveSorter) => { return a.name.localeCompare(b.name); }; -export const filterStations = (station: Station, filters: Record) => { +export const filterStations = (station: Station, filters: Record) => { if (filters['free'] && (!station.onlineInfo || station.onlineInfo.dispatcherId == -1)) return false; diff --git a/src/locales/en.json b/src/locales/en.json index f018ac2..727e886 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -271,7 +271,11 @@ "minOneWayCatenary": "MIN. CATENARY SINGLE TRACK ROUTES", "minOneWay": "MIN. OTHER SINGLE TRACK ROUTES", "minTwoWayCatenary": "MIN. CATENARY DOUBLE TRACK ROUTES", - "minTwoWay": "MIN. OTHER DOUBLE TRACK ROUTES" + "minTwoWay": "MIN. OTHER DOUBLE TRACK ROUTES", + "minOneWayCatenaryInt": "MIN. INTERNAL CATENARY SINGLE TRACK ROUTES", + "minOneWayInt": "MIN. INTERNAL OTHER SINGLE TRACK ROUTES", + "minTwoWayCatenaryInt": "MIN. INTERNAL CATENARY DOUBLE TRACK ROUTES", + "minTwoWayInt": "MIN. INTERNAL OTHER DOUBLE TRACK ROUTES" }, "sceneries-search": "SCENERY SEARCH:", "sceneries-placeholder": "Enter scenery name...", diff --git a/src/locales/pl.json b/src/locales/pl.json index db33f06..67b3a02 100644 --- a/src/locales/pl.json +++ b/src/locales/pl.json @@ -269,7 +269,11 @@ "minOneWayCatenary": "SZLAKI JEDNOTOROWE ZELEKTR. (MINIMUM)", "minOneWay": "SZLAKI JEDNOTOROWE NIEZELEKTR. (MINIMUM)", "minTwoWayCatenary": "SZLAKI DWUTOROWE ZELEKTR. (MINIMUM)", - "minTwoWay": "SZLAKI DWUTOROWE NIEZELEKTR. (MINIMUM)" + "minTwoWay": "SZLAKI DWUTOROWE NIEZELEKTR. (MINIMUM)", + "minOneWayCatenaryInt": "SZLAKI JEDNOTOROWE ZELEKTR. WEWNĘTRZNE (MINIMUM)", + "minOneWayInt": "SZLAKI JEDNOTOROWE NIEZELEKTR. WEWNĘTRZNE (MINIMUM)", + "minTwoWayCatenaryInt": "SZLAKI DWUTOROWE ZELEKTR. WEWNĘTRZNE (MINIMUM)", + "minTwoWayInt": "SZLAKI DWUTOROWE NIEZELEKTR. WEWNĘTRZNE (MINIMUM)" }, "sceneries-search": "WYSZUKAJ SCENERIĘ:", "sceneries-placeholder": "Wpisz nazwę scenerii...", diff --git a/src/managers/stationFilterManager.ts b/src/managers/stationFilterManager.ts index a920da4..b0fd3bd 100644 --- a/src/managers/stationFilterManager.ts +++ b/src/managers/stationFilterManager.ts @@ -59,22 +59,29 @@ export const initFilters = { onlineFromHours: 0, minLevel: 0, maxLevel: 20, - minOneWayCatenary: 0, minOneWay: 0, + minOneWayCatenary: 0, minTwoWayCatenary: 0, - minTwoWay: 0, + minOneWayInt: 0, + minOneWayCatenaryInt: 0, + minTwoWayCatenaryInt: 0, + // minTwoWay: 0, authors: '' }; -export const initSliders = [ +export const sliderStates = [ { id: 'maxVmax', minRange: 0, maxRange: 200, step: 10 }, { id: 'minVmax', minRange: 0, maxRange: 200, step: 10 }, { id: 'minLevel', minRange: 0, maxRange: 20, step: 1 }, { id: 'maxLevel', minRange: 0, maxRange: 20, step: 1 }, - { id: 'minOneWayCatenary', minRange: 0, maxRange: 5, step: 1 }, { id: 'minOneWay', minRange: 0, maxRange: 5, step: 1 }, + { id: 'minOneWayCatenary', minRange: 0, maxRange: 5, step: 1 }, { id: 'minTwoWayCatenary', minRange: 0, maxRange: 5, step: 1 }, - { id: 'minTwoWay', minRange: 0, maxRange: 5, step: 1 } + { id: 'minOneWayInt', minRange: 0, maxRange: 5, step: 1 }, + { id: 'minOneWayCatenaryInt', minRange: 0, maxRange: 5, step: 1 }, + { id: 'minTwoWayCatenaryInt', minRange: 0, maxRange: 5, step: 1 }, + // { id: 'minTwoWay', minRange: 0, maxRange: 5, step: 1 }, + // { id: 'minTwoWayInt', minRange: 0, maxRange: 5, step: 1 } ]; export type StationFilter = keyof typeof initFilters;