diff --git a/utils/client-schedule.ts b/utils/client-schedule.ts index 347aa9f..bf1ecd3 100644 --- a/utils/client-schedule.ts +++ b/utils/client-schedule.ts @@ -445,7 +445,7 @@ export class ClientSchedule extends ClientEntity { throw new Error("ClientSchedule.equals not implemented") } - #fixLocationRefs(locations: Map) { + private fixLocationRefs(locations: Map) { for (const events of [this.events, this.originalEvents]) { for (const event of events.values()) { for (const slot of event.slots) { @@ -460,7 +460,7 @@ export class ClientSchedule extends ClientEntity { } } - #checkLocationRefsForDeletion(id: Id) { + private checkLocationRefsForDeletion(id: Id) { for (const event of this.events.values()) { for (const slot of event.slots) { for (let i = 0; i < slot.locations.length; i++) { @@ -474,11 +474,11 @@ export class ClientSchedule extends ClientEntity { setLocation(location: ClientScheduleLocation) { if (location.deleted) { - this.#checkLocationRefsForDeletion(location.id); + this.checkLocationRefsForDeletion(location.id); } this.locations.set(location.id, location); if (!location.deleted) { - this.#fixLocationRefs(new Map([[location.id, location]])); + this.fixLocationRefs(new Map([[location.id, location]])); } } @@ -486,9 +486,9 @@ export class ClientSchedule extends ClientEntity { const location = this.originalLocations.get(id); if (location) { this.locations.set(id, location); - this.#fixLocationRefs(new Map([[location.id, location]])); + this.fixLocationRefs(new Map([[location.id, location]])); } else { - this.#checkLocationRefsForDeletion(id); + this.checkLocationRefsForDeletion(id); this.locations.delete(id); } } @@ -504,9 +504,10 @@ export class ClientSchedule extends ClientEntity { } else { this.events.delete(id); } + this.recalcModified(); } - #fixRoleRefs(roles: Map) { + private fixRoleRefs(roles: Map) { for (const shifts of [this.shifts, this.originalShifts]) { for (const shift of shifts.values()) { const role = roles.get(shift.role.id); @@ -517,7 +518,7 @@ export class ClientSchedule extends ClientEntity { } } - #checkRoleRefsForDeletion(id: Id) { + private checkRoleRefsForDeletion(id: Id) { for (const shift of this.shifts.values()) { if (shift.role.id === id) { throw new Error(`Cannot delete role, shift "${shift.name}" depends on it`); @@ -527,11 +528,11 @@ export class ClientSchedule extends ClientEntity { setRole(role: ClientScheduleRole) { if (role.deleted) { - this.#checkRoleRefsForDeletion(role.id); + this.checkRoleRefsForDeletion(role.id); } this.roles.set(role.id, role); if (!role.deleted) { - this.#fixRoleRefs(new Map([[role.id, role]])); + this.fixRoleRefs(new Map([[role.id, role]])); } } @@ -539,9 +540,9 @@ export class ClientSchedule extends ClientEntity { const role = this.originalRoles.get(id); if (role) { this.roles.set(id, role); - this.#fixRoleRefs(new Map([[role.id, role]])); + this.fixRoleRefs(new Map([[role.id, role]])); } else { - this.#checkRoleRefsForDeletion(id); + this.checkRoleRefsForDeletion(id); this.roles.delete(id); } } @@ -660,7 +661,7 @@ export class ClientSchedule extends ClientEntity { this.originalLocations, this.locations, ); - this.#fixLocationRefs(setLocations); + this.fixLocationRefs(setLocations); applyEntityUpdates( update.events, api => ClientScheduleEvent.fromApi(api, this.locations, opts),