Refactor to use ClientSchedule on client

Use the ClientSchedule data structure for deserialising and tracking
edit state on the client instead of trying to directly deal with the
ApiSchedule type which is not build for ease of edits or rendering.
This commit is contained in:
Hornwitser 2025-06-14 19:22:53 +02:00
parent ce9f758f84
commit bb450fd583
15 changed files with 488 additions and 1297 deletions

View file

@ -457,6 +457,7 @@ export class ClientSchedule extends ClientEntity {
shiftSlots: Map<Id, ClientScheduleShiftSlot>;
eventSlots: Map<Id, ClientScheduleEventSlot>;
modified: boolean;
nextClientId = -1;
constructor(
id: 111,
@ -478,6 +479,14 @@ export class ClientSchedule extends ClientEntity {
this.shiftSlots = idMap([...shifts.values()].flatMap(shift => [...shift.slots.values()]));
this.originalShiftSlots = new Map(this.shiftSlots);
this.modified = false;
// XXX For now the prototype server is assigning client ids instead of remapping them.
this.nextClientId = Math.min(
0,
...locations.keys(),
...events.keys(),
...roles.keys(),
...shifts.keys(),
) - 1;
}
equals(other: ClientSchedule): boolean {