Add train deactivation feature and import train number management

- Introduced DEACTIVATED status for trains, allowing staff to park trains indefinitely.
- Implemented methods to deactivate and reactivate trains in the TrainBuilderService.
- Added UI components for train deactivation and reactivation in TrainBuilderDetailPage.
- Created a dropdown setting for admin-managed import train numbers, with corresponding migrations.
- Updated yard code length to accommodate soft-delete suffix.
- Enhanced train status handling to include DEACTIVATED state.
This commit is contained in:
Marshal
2026-07-20 07:04:23 +00:00
parent ab355d0e16
commit 771aa2a605
20 changed files with 467 additions and 36 deletions

View File

@@ -54,10 +54,26 @@ export const TRAIN_RUN_FILTER_OPTIONS = Object.entries(TRAIN_RUN_PAIRS).map(
}),
);
/** The import run implied by an export run; empty string when unset/unknown. */
export const importRunFor = (exportRun: unknown): string =>
TRAIN_RUN_PAIRS[String(exportRun ?? "")] ?? "";
/**
* The import run implied by an export run; empty string when unset/unknown.
* Runs outside the hardcoded pairs (admin-added via dropdown settings) fall
* back to the numeric convention: import = export + 1.
*/
export const importRunFor = (exportRun: unknown): string => {
const run = String(exportRun ?? "");
const paired = TRAIN_RUN_PAIRS[run];
if (paired) return paired;
return /^\d*[13579]$/.test(run) ? String(Number(run) + 1) : "";
};
/** The export run implied by an import run; empty string when unset/unknown. */
export const exportRunFor = (importRun: unknown): string =>
EXPORT_BY_IMPORT[String(importRun ?? "")] ?? "";
/**
* The export run implied by an import run; empty string when unset/unknown.
* Runs outside the hardcoded pairs (admin-added via dropdown settings) fall
* back to the numeric convention: export = import 1.
*/
export const exportRunFor = (importRun: unknown): string => {
const run = String(importRun ?? "");
const paired = EXPORT_BY_IMPORT[run];
if (paired) return paired;
return /^\d*[02468]$/.test(run) && Number(run) > 0 ? String(Number(run) - 1) : "";
};