fix(planner): bookings a collaborator moves on a day take their new slots in every open list

reservation:positions was on the ignored list, while the stop order the same
reorder sends was applied, so in other tabs and for other members the bookings
sat between the wrong stops until a reload. The event now writes the slots the
way the mover's own list did, for the day it names (day_id from REST, dayId
from the MCP tool) or as the global slot without one, and caches them offline.

A booking handed back by an edit or a reservation:updated event without day
slots keeps the ones it had, in the store and in the offline cache.

Refs #2631
This commit is contained in:
Maurice
2026-10-12 12:33:19 +02:00
parent 12f08e3646
commit 93173b1573
7 changed files with 136 additions and 8 deletions
+17 -2
View File
@@ -1,8 +1,14 @@
// FE-UTIL-MERGEDORDER-001 to -008: the reorder writes the desktop day plan and the
// FE-UTIL-MERGEDORDER-001 to -009: the reorder writes the desktop day plan and the
// phone's plan timeline both derive from a day's new timeline order.
import { describe, expect, it } from 'vitest';
import { metadataWithLegPositions, moveRow, planMergedOrder, withTransportPositions } from './mergedOrder';
import {
keepDayPositions,
metadataWithLegPositions,
moveRow,
planMergedOrder,
withTransportPositions,
} from './mergedOrder';
const place = (id: number) => ({ type: 'place', data: { id } });
const note = (id: number) => ({ type: 'note', data: { id } });
@@ -91,3 +97,12 @@ describe('moveRow', () => {
expect(rows).toEqual(['a', 'b', 'c', 'd']);
});
});
describe('keepDayPositions', () => {
it('FE-UTIL-MERGEDORDER-009: keeps the day slots of the replaced copy only when the new one has none', () => {
const prev: { id: number; day_positions?: Record<string, number> | null } = { id: 1, day_positions: { 4: 1.5 } };
expect(keepDayPositions({ id: 1 }, prev)).toEqual({ id: 1, day_positions: { 4: 1.5 } });
expect(keepDayPositions({ id: 1, day_positions: null }, prev)).toEqual({ id: 1, day_positions: null });
expect(keepDayPositions({ id: 1 }, undefined)).toEqual({ id: 1 });
});
});
+10
View File
@@ -95,6 +95,16 @@ export function withTransportPositions<R extends PositionedBooking>(
});
}
/**
* A booking as an edit or a collaborator's event hands it back, with the day slots of
* the copy it replaces when it came without any. A server that did not send them yet
* put a moved booking back by its time on every edit until the next reload (#2631).
*/
export function keepDayPositions<R extends PositionedBooking>(next: R, prev: R | undefined): R {
if (!prev || next.day_positions !== undefined) return next;
return { ...next, day_positions: prev.day_positions };
}
/**
* A booking's metadata with each moved leg's position for the day written into
* metadata.legs[i].day_positions. Null when the metadata holds no legs to move.