Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change how trainschedule id is stored in the front part #10601

Closed
11 tasks
SharglutDev opened this issue Jan 31, 2025 · 0 comments · Fixed by #10679
Closed
11 tasks

Change how trainschedule id is stored in the front part #10601

SharglutDev opened this issue Jan 31, 2025 · 0 comments · Fixed by #10679
Assignees
Labels
area:front Work on Standard OSRD Interface modules kind:refacto-task Task related to Refactorization Epic

Comments

@SharglutDev
Copy link
Contributor

SharglutDev commented Jan 31, 2025

Description and goal

With the train service / paced train feature incoming, we will now manipulate 2 sorts of trains in the app : "unique" trains and "paced trains".

Paced trains regroup many trains with a start_time equally staggered. We gonna need to be able to select every of the paced train's children on the timetable or on the space time chart and manipulate (drag on space time chart).

The back-end will provide an id for a paced train but not for its "children". To be aware of which one of them we manipulate, we need to change how we store their ids in the TrainScheduleWithDetails type.
The new id will now be of type string instead of number and will look like this :

  • train id : trainschedule-{id}
  • occurrence (paced train child) : occurrence-{occurrenceIndex}-paced-{id}

We also need to have another type of id for paced trains that will be used for the projection to differentiate it with a train schedule id.
paced train id : paced-{id}

To improve safety, we should also be able to distinguish these two kinds of ids.
Goal is to use the logic describe in this issue : #8816.
These news types should look like this :

type TrainScheduleId = string & { readonly __type: unique symbol }; // format: "trainschedule-{id}"
type OccurrenceId = string & { readonly __type: unique symbol }; // format: "occurrence-{occurrenceIndex}-paced-{id}"
type PacedTrainId = string & { readonly __type: unique symbol }; // format: "paced-{id}"

type TrainId = TrainScheduleId | OccurrenceId; // TODO: find a better name
type TimetableItemId = TrainScheduleId | PacedTrainId;

Warning

You might need to reset your store / local storage to test the PR and after testing it

Acceptance criteria

  • The new train id types have been created
  • TrainScheduleWithDetails type id property is now of type TrainId
  • When fetching current trainSchedule, the editoast id is transformed to match the new id string format
  • Everywhere we use or compare train ids has been updated
  • When a train is selected, the url displays the new id format for selection and projection
  • When "CRUD"ing a trainSchedule, the "string" id is properly transformed into the editoast "number" id
  • Macro > micro and micro > macro should still work
  • Deleting the selected train and/or the projected one should still work as before (update url and fallback into another train)
  • Selecting a train on the space time chart should still work
  • Clicking on a conflict card should still change the selected train (if the conflicted one wasn't selected)
  • Stdcm debug mode still works
@SharglutDev SharglutDev added area:front Work on Standard OSRD Interface modules kind:refacto-task Task related to Refactorization Epic labels Jan 31, 2025
@SharglutDev SharglutDev self-assigned this Jan 31, 2025
This was referenced Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:front Work on Standard OSRD Interface modules kind:refacto-task Task related to Refactorization Epic
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant