diff --git a/src/components/JournalView/typings.ts b/src/components/JournalView/typings.ts index a2605cf..ce607e0 100644 --- a/src/components/JournalView/typings.ts +++ b/src/components/JournalView/typings.ts @@ -15,7 +15,8 @@ export namespace Journal { | 'search-issuedFrom' | 'search-terminatingAt' | 'search-via' - | 'select-categoryCode'; + | 'select-categoryCode' + | 'search-headUnit'; export type TimetableSearchType = { [key in TimetableSearchKey]: string; diff --git a/src/locales/en.json b/src/locales/en.json index 7f1c0d7..8550f38 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -199,6 +199,7 @@ "search-date-from": "Date (UTC+2 / CEST)", "search-date-to": "Date (UTC+2 / CEST)", "select-categoryCode": "Train category", + "search-headUnit": "Traction unit (e.g. EP09, ET22-401)", "sort-mass": "mass", "sort-speed": "speed", "sort-length": "length", diff --git a/src/locales/pl.json b/src/locales/pl.json index 7f80222..9e1105c 100644 --- a/src/locales/pl.json +++ b/src/locales/pl.json @@ -196,6 +196,7 @@ "search-date-from": "Data (UTC+2 / CEST)", "search-date-to": "Data (UTC+2 / CEST)", "select-categoryCode": "Kategoria pociągu", + "search-headUnit": "Pojazd trakcyjny (np. EP09, ET22-137)", "sort-routeDistance": "kilometraż", "sort-allStopsCount": "stacje", "sort-beginDate": "data", diff --git a/src/typings/api.ts b/src/typings/api.ts index 606f1b8..a3aa92b 100644 --- a/src/typings/api.ts +++ b/src/typings/api.ts @@ -253,8 +253,10 @@ export namespace API { pn?: number; tn?: number; - returnType?: 'all' | 'short' | 'detailed'; + headUnitName?: string; + headUnitType?: string; + returnType?: 'all' | 'short' | 'detailed'; sortBy?: Journal.TimetableSorter['id']; } diff --git a/src/views/JournalTimetables.vue b/src/views/JournalTimetables.vue index 9888939..4e39886 100644 --- a/src/views/JournalTimetables.vue +++ b/src/views/JournalTimetables.vue @@ -173,8 +173,9 @@ export default defineComponent({ 'search-issuedFrom': '', 'search-via': '', 'search-terminatingAt': '', - 'select-categoryCode': '', - 'search-date-from': '' + 'search-headUnit': '', + 'search-date-from': '', + 'select-categoryCode': '' } as Journal.TimetableSearchType); const countFromIndex = ref(0); @@ -296,6 +297,8 @@ export default defineComponent({ async fetchHistoryData() { this.extraInfoIndexes.length = 0; + const queryParams: API.TimetableHistory.QueryParams = {}; + const driverName = this.searchersValues['search-driver'].trim() || undefined; const trainNo = this.searchersValues['search-train'].trim() || undefined; const authorName = this.searchersValues['search-dispatcher'].trim() || undefined; @@ -305,6 +308,7 @@ export default defineComponent({ const via = this.searchersValues['search-via'].trim() || undefined; const terminatingAt = this.searchersValues['search-terminatingAt'].trim() || undefined; const categoryCode = this.searchersValues['select-categoryCode'].trim() || undefined; + const headUnit = this.searchersValues['search-headUnit'].trim() || undefined; let dateFromISO: string | undefined = undefined; let dateToISO: string | undefined = undefined; @@ -320,8 +324,6 @@ export default defineComponent({ dateToISO = dateTo.toISOString(); } - const queryParams: API.TimetableHistory.QueryParams = {}; - this.filterList .filter((f) => f.isActive) .forEach((f) => { @@ -393,6 +395,17 @@ export default defineComponent({ queryParams['sortBy'] = this.sorterActive.id != 'timetableId' ? this.sorterActive.id : undefined; + // Head unit params + if (headUnit) { + const [headUnitName, headUnitNumber] = headUnit.split('-'); + + if (headUnitNumber && !isNaN(Number(headUnitNumber))) { + queryParams['headUnitName'] = `${headUnitName}-${headUnitNumber}`; + } else { + queryParams['headUnitType'] = headUnitName; + } + } + if (JSON.stringify(this.currentQueryParams) != JSON.stringify(queryParams)) this.dataStatus = Status.Data.Loading;