Implement editing of slots in ClientSchedule

Implement tracking of time slots along with editing and restoration of
singularly edited time slots.  This provides a simpler interface to work
with when rendering tables of time slots that can be edited than
directly manipulating events and shifts containing an array of slots.
This commit is contained in:
Hornwitser 2025-06-14 19:12:31 +02:00
parent 73bb12c104
commit ce9f758f84
4 changed files with 432 additions and 44 deletions

View file

@ -78,3 +78,26 @@ export function setEquals<T>(...sets: Set<T>[]) {
}
return true;
}
/**
Returns true if the two maps passed as input compare equal to each other.
@param a Input map
@param b Input map
@param equals Function to compare individual values in the map.
@returns True if the maps compare equal
*/
export function mapEquals<K, V>(
a: Map<K, V>,
b: Map<K, V>,
equals: (a: V, b: V) => unknown = (a, b) => a === b,
) {
if (a.size !== b.size) {
return false;
}
for (const [key, value] of a) {
if (!b.has(key) || value !== b.get(key)) {
return false;
}
}
return true;
}