Fix sanity checks failing on deleted entities

If the event/shift that a location/role was referencing had been marked
for deletion the sanity check would incorrectly refuse to delete the
event/role.  Fix by ignoring deleted events/shifts.
This commit is contained in:
Hornwitser 2025-06-13 20:51:24 +02:00
parent 61734d4152
commit 8c63c1cfbb

View file

@ -484,6 +484,8 @@ export class ClientSchedule extends ClientEntity {
private checkLocationRefsForDeletion(id: Id) {
for (const event of this.events.values()) {
if (event.deleted)
continue;
for (const slot of event.slots) {
for (let i = 0; i < slot.locations.length; i++) {
if (slot.locations[i].id === id) {
@ -583,6 +585,9 @@ export class ClientSchedule extends ClientEntity {
private checkRoleRefsForDeletion(id: Id) {
for (const shift of this.shifts.values()) {
if (shift.deleted) {
continue;
}
if (shift.role.id === id) {
throw new Error(`Cannot delete role, shift "${shift.name}" depends on it`);
}