mirror of
https://github.com/Spythere/srjp-td2.git
synced 2026-05-03 05:28:12 +00:00
fix: names corrections for multiple units
This commit is contained in:
@@ -63,12 +63,12 @@
|
||||
class="text-center align-top border-l border-l-black dark:border-l-white"
|
||||
:class="{
|
||||
'border-t border-t-black dark:border-t-white':
|
||||
i != 0 && computedTimetableRows[i - 1].realLine != row.realLine,
|
||||
row.lastRowRef != null && row.lastRowRef.realLine != row.realLine,
|
||||
'border-b border-b-black dark:border-b-white': i == computedTimetableRows.length - 1
|
||||
}"
|
||||
>
|
||||
{{
|
||||
i == 0 || computedTimetableRows[i - 1].realLine != row.realLine
|
||||
row.lastRowRef == null || row.lastRowRef.realLine != row.realLine
|
||||
? row.realLine
|
||||
: ' '
|
||||
}}
|
||||
@@ -79,10 +79,10 @@
|
||||
class="border border-black dark:border-white border-t-1 border-b-1 relative p-0"
|
||||
:class="{
|
||||
'border-t-0':
|
||||
i == 0 ||
|
||||
(computedTimetableRows[i - 1].departureSpeed == row.arrivalSpeed &&
|
||||
computedTimetableRows[i - 1].departureTracks == row.arrivalTracks &&
|
||||
computedTimetableRows[i - 1].realLine == row.realLine),
|
||||
row.lastRowRef == null ||
|
||||
(row.lastRowRef.departureSpeed == row.arrivalSpeed &&
|
||||
row.lastRowRef.departureTracks == row.arrivalTracks &&
|
||||
row.lastRowRef.realLine == row.realLine),
|
||||
'border-b-0': i != computedTimetableRows.length - 1
|
||||
}"
|
||||
>
|
||||
@@ -92,10 +92,10 @@
|
||||
<!-- Arrival Km -->
|
||||
<tr
|
||||
:class="`align-top ${
|
||||
i == 0 ||
|
||||
(computedTimetableRows[i - 1].departureSpeed == row.arrivalSpeed &&
|
||||
computedTimetableRows[i - 1].departureTracks == row.arrivalTracks &&
|
||||
computedTimetableRows[i - 1].realLine == row.realLine)
|
||||
row.lastRowRef == null ||
|
||||
(row.lastRowRef.departureSpeed == row.arrivalSpeed &&
|
||||
row.lastRowRef.departureTracks == row.arrivalTracks &&
|
||||
row.lastRowRef.realLine == row.realLine)
|
||||
? 'text-transparent'
|
||||
: 'text-inherit'
|
||||
}`"
|
||||
@@ -126,7 +126,7 @@
|
||||
class="text-center align-top p-0 border-l-black dark:border-l-white relative"
|
||||
:class="{
|
||||
'border-t border-t-black dark:border-t-white':
|
||||
i != 0 && computedTimetableRows[i - 1].departureSpeed != row.arrivalSpeed,
|
||||
row.lastRowRef != null && row.lastRowRef.departureSpeed != row.arrivalSpeed,
|
||||
'border-b border-b-black dark:border-b-white': i == computedTimetableRows.length - 1
|
||||
}"
|
||||
colspan="2"
|
||||
@@ -137,9 +137,9 @@
|
||||
<tr class="align-top">
|
||||
<td :colspan="row.arrivalTracks == 2 ? '1' : '2'" class="font-bold" width="35">
|
||||
{{
|
||||
i == 0 ||
|
||||
computedTimetableRows[i - 1].departureSpeed != row.arrivalSpeed ||
|
||||
computedTimetableRows[i - 1].departureTracks != row.arrivalTracks
|
||||
row.lastRowRef == null ||
|
||||
row.lastRowRef.departureSpeed != row.arrivalSpeed ||
|
||||
row.lastRowRef.departureTracks != row.arrivalTracks
|
||||
? row.arrivalSpeed
|
||||
: ' '
|
||||
}}
|
||||
@@ -151,9 +151,9 @@
|
||||
width="35"
|
||||
>
|
||||
{{
|
||||
i == 0 ||
|
||||
computedTimetableRows[i - 1].departureSpeed != row.arrivalSpeed ||
|
||||
computedTimetableRows[i - 1].departureTracks != row.arrivalTracks
|
||||
row.lastRowRef == null ||
|
||||
row.lastRowRef.departureSpeed != row.arrivalSpeed ||
|
||||
row.lastRowRef.departureTracks != row.arrivalTracks
|
||||
? row.arrivalSpeed
|
||||
: ' '
|
||||
}}
|
||||
@@ -335,6 +335,8 @@ const computedTimetableRows = computed(() => {
|
||||
|
||||
const stopRows: StopRow[] = [];
|
||||
|
||||
let lastRowRef: StopRow | null = null;
|
||||
|
||||
let currentPathIndex = 0;
|
||||
let currentPath = timetablePath[0];
|
||||
|
||||
@@ -365,9 +367,6 @@ const computedTimetableRows = computed(() => {
|
||||
|
||||
for (const stop of stopList) {
|
||||
if (stop.arrivalLine && stop.arrivalLine == currentPath.arrivalLine) {
|
||||
// console.log('arrivalKm', arrivalKm);
|
||||
// console.log('stopDistance', stop.stopDistance);
|
||||
|
||||
if (arrivalKm >= stop.stopDistance)
|
||||
arrivalKm =
|
||||
(Number(stopRows[stopRows.length - 1].departureKm ?? '0') + stop.stopDistance) / 2;
|
||||
@@ -441,7 +440,9 @@ const computedTimetableRows = computed(() => {
|
||||
headUnits: timetableData.headUnits,
|
||||
stockVmax,
|
||||
stockLength,
|
||||
stockMass
|
||||
stockMass,
|
||||
|
||||
lastRowRef
|
||||
};
|
||||
|
||||
// console.debug(stop.stopNameRAW, stop.departureLine);
|
||||
@@ -451,6 +452,7 @@ const computedTimetableRows = computed(() => {
|
||||
arrivalTracks = correctedDepartureTracks || arrivalTracks;
|
||||
|
||||
if (stop.departureTimestamp) lastDepartureTimestamp = stop.departureTimestamp;
|
||||
lastRowRef = rowData;
|
||||
|
||||
stopRows.push(rowData);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import type {
|
||||
TimetableData,
|
||||
ViewMode
|
||||
} from '../types/common.types';
|
||||
import { unitNameCorrections } from '../utils/trainUtils';
|
||||
import { getHeadUnits } from '../utils/trainUtils';
|
||||
|
||||
export const useGlobalStore = defineStore('global', {
|
||||
state: () => ({
|
||||
@@ -77,15 +77,7 @@ export const useGlobalStore = defineStore('global', {
|
||||
}`
|
||||
)
|
||||
.join('~~'),
|
||||
headUnits: selectedTrain.stockString
|
||||
.split(';')
|
||||
.slice(0, 3)
|
||||
.filter((s, i) => i == 0 || /-\d+$/.test(s))
|
||||
.map((s) => {
|
||||
const unitName = s.slice(0, s.indexOf('-'));
|
||||
|
||||
return unitNameCorrections[unitName] ?? unitName;
|
||||
})
|
||||
headUnits: getHeadUnits(selectedTrain.stockString)
|
||||
};
|
||||
} else if (this.viewMode == 'journal') {
|
||||
const selectedTimetable = this.selectedJournalTimetable;
|
||||
@@ -108,15 +100,7 @@ export const useGlobalStore = defineStore('global', {
|
||||
trainMaxSpeed: selectedTimetable.trainMaxSpeed,
|
||||
timetableId: selectedTimetable.id,
|
||||
stopListString: selectedTimetable.stopListString,
|
||||
headUnits: selectedTimetable.stockString
|
||||
.split(';')
|
||||
.slice(0, 3)
|
||||
.filter((s, i) => i == 0 || /-\d+$/.test(s))
|
||||
.map((s) => {
|
||||
const unitName = s.slice(0, s.indexOf('-'));
|
||||
|
||||
return unitNameCorrections[unitName] ?? unitName;
|
||||
})
|
||||
headUnits: getHeadUnits(selectedTimetable.stockString)
|
||||
};
|
||||
} else {
|
||||
return this.selectedStorageTimetable;
|
||||
|
||||
@@ -147,6 +147,8 @@ export interface StopRow {
|
||||
stockVmax: number;
|
||||
stockLength: number;
|
||||
stockMass: number;
|
||||
|
||||
lastRowRef: StopRow | null;
|
||||
}
|
||||
|
||||
export interface StopRowCZ {
|
||||
|
||||
+23
-7
@@ -1,3 +1,11 @@
|
||||
const unitNameCorrections: Record<string, string[]> = {
|
||||
'2EN57': ['EN57', 'EN57'],
|
||||
'201E': ['ET22'],
|
||||
'4E': ['EU07'],
|
||||
M62: ['ST44'],
|
||||
CTLR4C: ['ST44']
|
||||
};
|
||||
|
||||
export const getRegionNameById = (id: string) => {
|
||||
switch (id) {
|
||||
case 'eu':
|
||||
@@ -20,10 +28,18 @@ export const getRegionNameById = (id: string) => {
|
||||
}
|
||||
};
|
||||
|
||||
export const unitNameCorrections: Record<string, string> = {
|
||||
'2EN57': 'EN57',
|
||||
'201E': 'ET22',
|
||||
'4E': 'EU07',
|
||||
M62: 'ST44',
|
||||
CTLR4C: 'ST44',
|
||||
};
|
||||
export function getHeadUnits(stockString: string) {
|
||||
const stockList = stockString.split(';').slice(0, 3);
|
||||
|
||||
return stockList.reduce((acc, unitType, i) => {
|
||||
if (i != 0 && !/-\d+$/.test(unitType)) return acc;
|
||||
|
||||
const unitName = unitType.slice(0, unitType.indexOf('-'));
|
||||
|
||||
const correctedNames = unitNameCorrections[unitName] ?? [unitName];
|
||||
|
||||
acc.push(...correctedNames);
|
||||
|
||||
return acc;
|
||||
}, [] as string[]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user