@fabriktor/fx 0.0.141 → 0.0.142
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -150,7 +150,7 @@ export class RoutesFX {
|
|
|
150
150
|
days_ago: opts.days_ago,
|
|
151
151
|
request: { signal: opts.signal },
|
|
152
152
|
});
|
|
153
|
-
//
|
|
153
|
+
// Repeated locations are allowed; employee conflicts remain enforced.
|
|
154
154
|
validateRouteInput(input, availability, current.id);
|
|
155
155
|
const result = await this.replaceRoute({
|
|
156
156
|
id: current.id,
|
|
@@ -6,6 +6,7 @@ export declare function routeInput(input: InRoute): InRoute;
|
|
|
6
6
|
export declare function validateRouteInput(input: InRoute, availability?: RPRoutesAvailability, replacing_route_id?: string): void;
|
|
7
7
|
export declare function validateRouteDestination(destination: InRoute["destinations"][number], window: WindowInput): void;
|
|
8
8
|
export declare function availableRouteIDs(availability: RPRoutesAvailability, kind: keyof RPRoutesAvailability["availables"], replacing_route_id?: string): Set<string>;
|
|
9
|
+
export declare function routeAssignmentsByEntity(assignments: RPRoutesAvailability["assignations"]["locations"], replacing_route_id?: string): Map<string, string[]>;
|
|
9
10
|
export declare function validateClientAvailabilityInput(input: InClientAvailability): void;
|
|
10
11
|
export declare function validateRouteTeamInput(input: InRouteTeam): void;
|
|
11
12
|
export declare function normalizedTagInput(input: InTag): InTag;
|
|
@@ -165,10 +165,17 @@ export function validateRouteDestination(destination, window) {
|
|
|
165
165
|
});
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
|
-
//
|
|
169
|
-
//
|
|
168
|
+
// Locations may be visited on several routes. Employees stay exclusive for
|
|
169
|
+
// the checked day; editing may retain only this route's employee assignments.
|
|
170
170
|
export function availableRouteIDs(availability, kind, replacing_route_id) {
|
|
171
171
|
const ids = new Set(normalizeIDs(availability.availables[kind]));
|
|
172
|
+
if (kind === "locations") {
|
|
173
|
+
for (const assignment of availability.assignations.locations) {
|
|
174
|
+
for (const id of normalizeIDs(assignment.entity_ids))
|
|
175
|
+
ids.add(id);
|
|
176
|
+
}
|
|
177
|
+
return ids;
|
|
178
|
+
}
|
|
172
179
|
for (const assignment of availability.assignations[kind]) {
|
|
173
180
|
if (assignment.route_id === replacing_route_id) {
|
|
174
181
|
for (const id of normalizeIDs(assignment.entity_ids))
|
|
@@ -183,6 +190,23 @@ export function availableRouteIDs(availability, kind, replacing_route_id) {
|
|
|
183
190
|
}
|
|
184
191
|
return ids;
|
|
185
192
|
}
|
|
193
|
+
// Group the backend's existing route references for informational display.
|
|
194
|
+
// Exclude the route being edited and count each route only once per entity.
|
|
195
|
+
export function routeAssignmentsByEntity(assignments, replacing_route_id) {
|
|
196
|
+
const out = new Map();
|
|
197
|
+
for (const assignment of assignments) {
|
|
198
|
+
const routeID = resolvedID(assignment.route_id);
|
|
199
|
+
if (!routeID || routeID === replacing_route_id)
|
|
200
|
+
continue;
|
|
201
|
+
for (const entityID of normalizeIDs(assignment.entity_ids)) {
|
|
202
|
+
const routes = out.get(entityID) ?? [];
|
|
203
|
+
if (!routes.includes(routeID))
|
|
204
|
+
routes.push(routeID);
|
|
205
|
+
out.set(entityID, routes);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return out;
|
|
209
|
+
}
|
|
186
210
|
export function validateClientAvailabilityInput(input) {
|
|
187
211
|
validateRouteTimeWindow(input);
|
|
188
212
|
for (const field of ["employer_id", "location_id"]) {
|