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:
parent
61734d4152
commit
8c63c1cfbb
1 changed files with 5 additions and 0 deletions
|
@ -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`);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue