fix: names corrections for multiple units

This commit is contained in:
2025-05-02 19:30:19 +02:00
parent 4a96ed3852
commit 93acfdb780
4 changed files with 51 additions and 47 deletions
+3 -19
View File
@@ -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;