Use TypeScript private modifier for methods
The Vue Ref system and assiated proxies does not work with the native EcmaScript private fields, replace them with the TypeScript access modifiers which are regular fields under the hood.
This commit is contained in:
parent
e100555304
commit
faffe48706
1 changed files with 14 additions and 13 deletions
|
@ -445,7 +445,7 @@ export class ClientSchedule extends ClientEntity {
|
|||
throw new Error("ClientSchedule.equals not implemented")
|
||||
}
|
||||
|
||||
#fixLocationRefs(locations: Map<Id, ClientScheduleLocation>) {
|
||||
private fixLocationRefs(locations: Map<Id, ClientScheduleLocation>) {
|
||||
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<Id, ClientScheduleRole>) {
|
||||
private fixRoleRefs(roles: Map<Id, ClientScheduleRole>) {
|
||||
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),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue