mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-03 09:38:54 +00:00
fix(journey): a timed entry takes its place in the day by its time
A new entry always went to the end of its day, so writing up 1 am after 2 am left the night out of order, and changing an entry's time never moved it. A timed entry now lands before the first entry of its day that starts later, on create and when its time or day changes; untimed entries still go last, and the hand-made order of the others stays as it was. A save that leaves time and day untouched keeps an entry where it was dragged. Closes #2679
This commit is contained in:
@@ -241,6 +241,21 @@ export class JourneyEntriesRepository extends TrekRepository<JourneyEntries> {
|
||||
return rows as { entry_date: string; m: number }[];
|
||||
}
|
||||
|
||||
/** One day's entries in timeline order, with what placing a timed entry among them reads (#2679). */
|
||||
async listDayOrder(
|
||||
journeyId: number,
|
||||
entryDate: string,
|
||||
): Promise<{ id: number; entry_time: string | null; sort_order: number | null }[]> {
|
||||
return await this.kysely<JourneyEntriesDateSortKyselyDB>()
|
||||
.selectFrom('journey_entries')
|
||||
.select(['id', 'entry_time', 'sort_order'])
|
||||
.where('journey_id', '=', journeyId)
|
||||
.where('entry_date', '=', entryDate)
|
||||
.orderBy('sort_order', 'asc')
|
||||
.orderBy('id', 'asc')
|
||||
.execute();
|
||||
}
|
||||
|
||||
/** JG42 — `onPlaceCreated`'s next-order lookup: `SELECT MAX(sort_order) AS m FROM journey_entries WHERE journey_id = ? AND entry_date = ?`. The `?? -1` fallback stays the SERVICE's, unchanged (same text as Task 2's own JG74). */
|
||||
async maxSortOrderForDate(journeyId: number, entryDate: string): Promise<number | null> {
|
||||
const row = await this.kysely<JourneyEntriesDateSortKyselyDB>()
|
||||
|
||||
Reference in New Issue
Block a user