mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 21:38:13 +00:00
feat(filters) filtering stations by real lines
This commit is contained in:
@@ -45,7 +45,21 @@
|
|||||||
</button>
|
</button>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section class="card_input-search authors">
|
<section class="card_input-search">
|
||||||
|
<input
|
||||||
|
v-model="filters['lines']"
|
||||||
|
id="line-numbers-search"
|
||||||
|
:placeholder="$t('filters.line-numbers-placeholder')"
|
||||||
|
@focus="preventKeyDown = true"
|
||||||
|
@blur="preventKeyDown = false"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<button class="btn--action btn--image" @click="resetLineNumbersInput">
|
||||||
|
<img src="/images/icon-exit.svg" alt="reset line numbers search" />
|
||||||
|
</button>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section class="card_input-search">
|
||||||
<select id="author" name="authors" v-model="filters['authors']">
|
<select id="author" name="authors" v-model="filters['authors']">
|
||||||
<option value="">{{ $t('filters.authors-placeholder') }}</option>
|
<option value="">{{ $t('filters.authors-placeholder') }}</option>
|
||||||
<option v-for="(author, i) in authorsOptions" :key="i" :value="author">
|
<option v-for="(author, i) in authorsOptions" :key="i" :value="author">
|
||||||
@@ -59,7 +73,7 @@
|
|||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section class="card_input-search">
|
<section class="card_input-search">
|
||||||
<select type="text" id="projects" name="projects" v-model="filters['projects']">
|
<select id="projects" name="projects" v-model="filters['projects']">
|
||||||
<option value="">{{ $t('filters.projects-placeholder') }}</option>
|
<option value="">{{ $t('filters.projects-placeholder') }}</option>
|
||||||
<option v-for="(project, i) in projectsOptions" :key="i" :value="project">
|
<option v-for="(project, i) in projectsOptions" :key="i" :value="project">
|
||||||
{{ project }}
|
{{ project }}
|
||||||
@@ -77,7 +91,7 @@
|
|||||||
v-for="(sectionFilters, sectionKey) in filtersSections"
|
v-for="(sectionFilters, sectionKey) in filtersSections"
|
||||||
:key="sectionKey"
|
:key="sectionKey"
|
||||||
>
|
>
|
||||||
<h3 class="text--primary">
|
<h3 class="section-header">
|
||||||
<span class="active-indicator" v-if="!areSectionFiltersDefault(sectionKey)"></span>
|
<span class="active-indicator" v-if="!areSectionFiltersDefault(sectionKey)"></span>
|
||||||
{{ $t(`filters.sections.${sectionKey}`) }}
|
{{ $t(`filters.sections.${sectionKey}`) }}
|
||||||
<button @click="resetSectionFilters(sectionKey)">RESET</button>
|
<button @click="resetSectionFilters(sectionKey)">RESET</button>
|
||||||
@@ -107,7 +121,7 @@
|
|||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section class="card_timestamp">
|
<section class="card_timestamp">
|
||||||
<h3 class="section-header">{{ $t('filters.minimum-hours-title') }}</h3>
|
<h3 class="hours-section-header">{{ $t('filters.minimum-hours-title') }}</h3>
|
||||||
|
|
||||||
<span class="clock">
|
<span class="clock">
|
||||||
<button class="btn--action" @click="subHour">-</button>
|
<button class="btn--action" @click="subHour">-</button>
|
||||||
@@ -314,6 +328,10 @@ export default defineComponent({
|
|||||||
this.filters['projects'] = '';
|
this.filters['projects'] = '';
|
||||||
},
|
},
|
||||||
|
|
||||||
|
resetLineNumbersInput() {
|
||||||
|
this.filters['lines'] = '';
|
||||||
|
},
|
||||||
|
|
||||||
handleSceneriesInput() {
|
handleSceneriesInput() {
|
||||||
const chosenStation = this.store.stationList.find(
|
const chosenStation = this.store.stationList.find(
|
||||||
({ name }) => name == this.chosenSearchScenery
|
({ name }) => name == this.chosenSearchScenery
|
||||||
@@ -399,6 +417,14 @@ export default defineComponent({
|
|||||||
@use '../../styles/animations';
|
@use '../../styles/animations';
|
||||||
|
|
||||||
h3.section-header {
|
h3.section-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
margin-bottom: 0.25em;
|
||||||
|
gap: 0.5em;
|
||||||
|
color: var(--clr-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
h3.hours-section-header {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
margin: 0.5em 0;
|
margin: 0.5em 0;
|
||||||
}
|
}
|
||||||
@@ -486,10 +512,6 @@ h3.section-header {
|
|||||||
padding: 0.5em;
|
padding: 0.5em;
|
||||||
border: 1px solid #aaa;
|
border: 1px solid #aaa;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.authors {
|
|
||||||
margin-top: 1em;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.section-filters {
|
.section-filters {
|
||||||
@@ -560,12 +582,6 @@ h3.section-header {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.option-section h3 {
|
.option-section h3 {
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
margin-bottom: 0.25em;
|
|
||||||
|
|
||||||
gap: 0.5em;
|
|
||||||
|
|
||||||
button {
|
button {
|
||||||
padding: 0.15em;
|
padding: 0.15em;
|
||||||
color: coral;
|
color: coral;
|
||||||
|
|||||||
@@ -364,7 +364,7 @@ export default defineComponent({
|
|||||||
|
|
||||||
const filters = inject('StationsView_filters') as Record<string, any>;
|
const filters = inject('StationsView_filters') as Record<string, any>;
|
||||||
const activeSorter = inject('StationsView_activeSorter') as ActiveSorter;
|
const activeSorter = inject('StationsView_activeSorter') as ActiveSorter;
|
||||||
|
|
||||||
const filteredStationList = computed(() =>
|
const filteredStationList = computed(() =>
|
||||||
mainStore.allStationInfo
|
mainStore.allStationInfo
|
||||||
.filter((station) => filterStations(station, filters))
|
.filter((station) => filterStations(station, filters))
|
||||||
|
|||||||
@@ -145,13 +145,33 @@ function filterSliderValues(filters: Record<string, any>, generalInfo: StationGe
|
|||||||
}
|
}
|
||||||
|
|
||||||
function filterInputValues(filters: Record<string, any>, generalInfo: StationGeneralInfo) {
|
function filterInputValues(filters: Record<string, any>, generalInfo: StationGeneralInfo) {
|
||||||
return (
|
if (
|
||||||
(filters['authors'].length > 3 &&
|
filters['authors'].length > 3 &&
|
||||||
!generalInfo.authors
|
generalInfo.authors &&
|
||||||
?.map((a) => a.toLocaleLowerCase())
|
!generalInfo.authors.some(
|
||||||
.includes(filters['authors'].toLocaleLowerCase())) ||
|
(a) => a.toLocaleLowerCase() == filters['authors'].toLocaleLowerCase()
|
||||||
(filters['projects'].length > 0 && generalInfo.project != filters['projects'])
|
)
|
||||||
);
|
)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (filters['projects'].length > 0 && generalInfo.project != filters['projects']) return true;
|
||||||
|
|
||||||
|
if (filters['lines'].length > 0) {
|
||||||
|
const linesNumbers = (filters['lines'] as string)
|
||||||
|
.split(',')
|
||||||
|
.map((l) => Number(l))
|
||||||
|
.filter((l) => !isNaN(l) && l != 0);
|
||||||
|
|
||||||
|
if (
|
||||||
|
!generalInfo.lines
|
||||||
|
?.split(',')
|
||||||
|
.map((l) => Number(l))
|
||||||
|
.some((l) => linesNumbers.includes(l))
|
||||||
|
)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const sortStations = (a: Station, b: Station, sorter: ActiveSorter) => {
|
export const sortStations = (a: Station, b: Station, sorter: ActiveSorter) => {
|
||||||
|
|||||||
+3
-2
@@ -317,8 +317,9 @@
|
|||||||
"minTwoWayInt": "MIN. INTERNAL OTHER DOUBLE TRACK ROUTES"
|
"minTwoWayInt": "MIN. INTERNAL OTHER DOUBLE TRACK ROUTES"
|
||||||
},
|
},
|
||||||
"sceneries-placeholder": "Search for scenery",
|
"sceneries-placeholder": "Search for scenery",
|
||||||
"authors-placeholder": "Scenery author (other filters apply)",
|
"line-numbers-placeholder": "Line numbers (separated by commas)",
|
||||||
"projects-placeholder": "Scenery project (other filters apply)",
|
"authors-placeholder": "Scenery author",
|
||||||
|
"projects-placeholder": "Scenery project",
|
||||||
"search-button-title": "SEARCH",
|
"search-button-title": "SEARCH",
|
||||||
"minimum-hours-title": "SHOW ONLY SCENERIES UNTIL:",
|
"minimum-hours-title": "SHOW ONLY SCENERIES UNTIL:",
|
||||||
"now": "NOW",
|
"now": "NOW",
|
||||||
|
|||||||
+3
-2
@@ -314,8 +314,9 @@
|
|||||||
"minTwoWayInt": "SZLAKI DWUTOROWE NIEZELEKTR. WEWNĘTRZNE (MINIMUM)"
|
"minTwoWayInt": "SZLAKI DWUTOROWE NIEZELEKTR. WEWNĘTRZNE (MINIMUM)"
|
||||||
},
|
},
|
||||||
"sceneries-placeholder": "Wyszukaj scenerię",
|
"sceneries-placeholder": "Wyszukaj scenerię",
|
||||||
"authors-placeholder": "Autor scenerii (uwzględnia inne filtry)",
|
"line-numbers-placeholder": "Numery linii (oddzielone przecinkami)",
|
||||||
"projects-placeholder": "Projekt scenerii (uwzględnia inne filtry)",
|
"authors-placeholder": "Autor scenerii",
|
||||||
|
"projects-placeholder": "Projekt scenerii",
|
||||||
"search-button-title": "SZUKAJ",
|
"search-button-title": "SZUKAJ",
|
||||||
"minimum-hours-title": "POKAŻ TYLKO SCENERIE DOSTĘPNE MINIMUM DO:",
|
"minimum-hours-title": "POKAŻ TYLKO SCENERIE DOSTĘPNE MINIMUM DO:",
|
||||||
"now": "TERAZ",
|
"now": "TERAZ",
|
||||||
|
|||||||
@@ -69,7 +69,8 @@ export const initFilters = {
|
|||||||
minTwoWayInt: 0,
|
minTwoWayInt: 0,
|
||||||
minTwoWayCatenaryInt: 0,
|
minTwoWayCatenaryInt: 0,
|
||||||
authors: '',
|
authors: '',
|
||||||
projects: ''
|
projects: '',
|
||||||
|
lines: ''
|
||||||
};
|
};
|
||||||
|
|
||||||
export const sliderStates = [
|
export const sliderStates = [
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ export interface StationGeneralInfo {
|
|||||||
abbr: string;
|
abbr: string;
|
||||||
hash?: string;
|
hash?: string;
|
||||||
reqLevel: number;
|
reqLevel: number;
|
||||||
lines: string;
|
lines?: string;
|
||||||
project: string;
|
project: string;
|
||||||
projectUrl?: string;
|
projectUrl?: string;
|
||||||
signalType: string;
|
signalType: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user