The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.
TypeScript budget-trackercollaborativedockeritinerarymcp-serveroffline-firstopen-sourceopenstreetmappacking-listpwareal-timeself-hostedselfhostedtraveltravel-apptravel-journaltravel-plannertripitwanderlog
fix(pdf): keep a note's second line in its card, fill the preview width
Maurice2a833c4ba9ea
diff --git a/client/src/components/PDF/tripPdfDay.test.ts b/client/src/components/PDF/tripPdfDay.test.tsindex 312dc35e9..d84300aad 100644--- a/client/src/components/PDF/tripPdfDay.test.ts+++ b/client/src/components/PDF/tripPdfDay.test.ts@@ -14,13 +14,13 @@ const category = { id: 4, name: 'Temple', icon: 'landmark', color: '#c2410c' } a/** Monday first, like the stored week; Wednesday has hours, Thursday is closed. */const week = JSON.stringify([- { open: '08:00', close: '18:00' },- { open: '08:00', close: '18:00' },- { open: '09:00', close: '17:30' },+ { closed: false, open: '08:00', close: '18:00' },+ { closed: false, open: '08:00', close: '18:00' },+ { closed: false, open: '09:00', close: '17:30' },{ closed: true },- { open: '08:00', close: '18:00' },- { open: '08:00', close: '18:00' },- { open: '08:00', close: '18:00' },+ { closed: false, open: '08:00', close: '18:00' },+ { closed: false, open: '08:00', close: '18:00' },+ { closed: false, open: '08:00', close: '18:00' },]);const fullPlace = {@@ -173,11 +173,13 @@ describe('noteItem', () => {expect(tinted.querySelector('.note-card')?.className).toBe('note-card note-tinted');expect(tinted.querySelector('.note-card')?.getAttribute('style')).toBe('--note:#2563eb');expect(texts(tinted, '.note-text')).toEqual(['Buy <tickets>']);- expect(texts(tinted, '.tl-start')).toEqual(['08:00']);+ // The note's time field is its free second line, kept in the card, not a clock.+ expect(texts(tinted, '.note-time')).toEqual(['08:00']);+ expect(tinted.querySelector('.tl-start')).toBeNull();const plain = parse(noteItem({ ...note, color: 'not-a-colour', time: null } as DayNote));expect(plain.querySelector('.note-card')?.className).toBe('note-card');- expect(plain.querySelector('.tl-start')).toBeNull();+ expect(plain.querySelector('.note-time')).toBeNull();});});@@ -227,7 +229,8 @@ describe('dayHeader', () => {it('FE-PDFDAY-010: the number, date and title, with only the figures the day has', () => {const doc = parse(dayHeader(day, { stops: 4, distance: '12 km', cost: '¥3,000' }, context()));- expect(texts(doc, '.day-tag')).toEqual(['pdf.day 3']);+ expect(texts(doc, '.day-tag-lbl')).toEqual(['pdf.day']);+ expect(texts(doc, '.day-tag-num')).toEqual(['3']);expect(texts(doc, '.day-date')[0]).toMatch(/May/);expect(texts(doc, '.day-title')).toEqual(['Kyoto']);expect(texts(doc, '.meta-pill, .day-cost')).toEqual(['4', '12 km', '¥3,000']);diff --git a/client/src/components/PDF/tripPdfDay.ts b/client/src/components/PDF/tripPdfDay.tsindex fb96fecf0..91b17011a 100644--- a/client/src/components/PDF/tripPdfDay.ts+++ b/client/src/components/PDF/tripPdfDay.ts@@ -226,11 +226,16 @@ export function bookingItem(r: PdfBooking, day: Day, ctx: PdfDayContext, flags:*/export function noteItem(note: DayNote): string {const colour = note.color ? hexColour(note.color, '') : '';+ // A note's `time` is the free line the day plan prints under its text, not a clock,+ // so it stays in the card and the time column stays empty.+ const subtitle = typeof note.time === 'string' ? note.time.trim() : '';const card = `<div class="note-card${colour ? ' note-tinted' : ''}"${colour ? ` style="--note:${colour}"` : ''}><span class="note-icon">${noteIcon(note.icon)}</span>- <div class="note-body"><div class="note-text">${escHtml(note.text)}</div></div>+ <div class="note-body"><div class="note-text">${escHtml(note.text)}</div>${+ subtitle ? `<div class="note-time">${escHtml(subtitle)}</div>` : ''+ }</div></div>`;- return item('note', timeColumn(note.time || '', ''), '', card);+ return item('note', timeColumn('', ''), '', card);}// ── Places ────────────────────────────────────────────────────────────────diff --git a/client/src/components/PDF/tripPdfOverview.test.ts b/client/src/components/PDF/tripPdfOverview.test.tsnew file mode 100644index 000000000..b3c5e84be--- /dev/null+++ b/client/src/components/PDF/tripPdfOverview.test.ts@@ -0,0 +1,117 @@+/**+ * FE-PDFOVERVIEW-001 to FE-PDFOVERVIEW-005: the trip PDF's cover and overview pages,+ * built from the figures the export hands them.+ */+import { describe, expect, it } from 'vitest';++import { coverHtml, glanceHtml, ledgerHtml, type GlanceRow, type LedgerRow } from './tripPdfOverview';++const tr = (key: string) => key;+const parse = (html: string) => new DOMParser().parseFromString(html, 'text/html');+const texts = (doc: Document, selector: string) =>+ [...doc.querySelectorAll(selector)].map((el) => el.textContent?.replace(/\s+/g, ' ').trim());++describe('coverHtml', () => {+ const base = {+ title: 'Autumn <in> Japan',+ description: 'Temples and trains',+ range: '1 November – 22 November 2026',+ logo: 'https://trek.example/logo-light.svg',+ stats: [+ { value: '22', label: 'days' },+ { value: '1,234 km', label: 'pdf.distanceLabel' },+ ],+ tr,+ };++ it('FE-PDFOVERVIEW-001: the photo, the escaped title, the dates and a tile per figure', () => {+ const doc = parse(coverHtml({ ...base, image: 'https://cdn.example/cover.jpg' }));++ expect(doc.querySelector('section')?.className).toBe('cover');+ expect(doc.querySelector('.cover-bg')?.getAttribute('style')).toBe(+ "background-image:url('https://cdn.example/cover.jpg')"+ );+ expect(texts(doc, '.cover-title')).toEqual(['Autumn <in> Japan']);+ expect(texts(doc, '.cover-dates')).toEqual(['1 November – 22 November 2026']);+ expect(texts(doc, '.cover-desc')).toEqual(['Temples and trains']);+ expect(texts(doc, '.cover-stat-num')).toEqual(['22', '1,234 km']);+ expect(texts(doc, '.cover-top .eyebrow')).toEqual(['pdf.travelPlan']);+ });++ it('FE-PDFOVERVIEW-002: without a photo the cover is plain, and a hostile url cannot leave url()', () => {+ const plain = parse(coverHtml({ ...base, image: null, description: null, range: null }));+ expect(plain.querySelector('section')?.className).toBe('cover cover-plain');+ expect(plain.querySelector('.cover-bg')?.hasAttribute('style')).toBe(false);+ expect(plain.querySelector('.cover-desc')).toBeNull();+ expect(plain.querySelector('.cover-dates')).toBeNull();++ const hostile = parse(coverHtml({ ...base, image: "https://a/x.jpg');background:url('https://b/leak.jpg" }));+ const style = hostile.querySelector('.cover-bg')?.getAttribute('style') ?? '';+ expect(style.match(/url\(/g)).toHaveLength(1);+ expect(style).not.toContain("');");+ });+});++describe('glanceHtml', () => {+ const row = (over: Partial<GlanceRow> = {}): GlanceRow => ({+ number: 1,+ colour: '#0a84ff',+ date: 'Sun, Nov 1',+ title: 'Tokyo',+ stops: 3,+ stay: 'Hotel Gracery',+ cost: null,+ ...over,+ });++ it('FE-PDFOVERVIEW-003: one row per day in its colour, the cost column only when a day has one', () => {+ const without = parse(glanceHtml([row(), row({ number: 2, stops: 0 })], tr));+ expect(texts(without, 'thead th')).toEqual(['pdf.day', 'common.date', 'pdf.plan', 'pdf.stay', '']);+ expect(texts(without, 'tbody tr:first-child td')).toEqual(['1', 'Sun, Nov 1', 'Tokyo', 'Hotel Gracery', '3']);+ // A day without stops leaves the cell empty rather than printing a zero.+ expect(texts(without, 'tbody tr:last-child td').at(-1)).toBe('');+ expect(without.querySelector('tbody tr')?.getAttribute('style')).toBe('--day:#0a84ff');++ const withCost = parse(glanceHtml([row(), row({ number: 2, cost: '¥3,000' })], tr));+ expect(texts(withCost, 'thead th').at(-1)).toBe('pdf.costLabel');+ expect(texts(withCost, 'tbody tr:last-child td').at(-1)).toBe('¥3,000');++ expect(glanceHtml([], tr)).toBe('');+ });+});++describe('ledgerHtml', () => {+ it('FE-PDFOVERVIEW-004: each booking and stay with its date and the code to show', () => {+ const rows: LedgerRow[] = [+ {+ icon: '<svg></svg>',+ tint: '#3b82f6',+ title: 'LH716 <FRA>',+ sub: '<span>FRA → HND</span>',+ when: 'Sat, Oct 31',+ code: 'ABC123',+ },+ {+ icon: '<svg></svg>',+ tint: '#17171c',+ title: 'Hotel Gracery',+ sub: '',+ when: 'Sun, Nov 1 – Wed, Nov 4',+ code: null,+ },+ ];+ const doc = parse(ledgerHtml(rows, tr));++ expect(texts(doc, '.sec-title')).toEqual(['pdf.bookings']);+ expect(texts(doc, '.ledger-title')).toEqual(['LH716 <FRA>', 'Hotel Gracery']);+ expect(texts(doc, '.ledger-sub')).toEqual(['FRA → HND']);+ expect(texts(doc, '.ledger-when .code-chip')).toEqual(['ABC123']);+ expect(doc.querySelectorAll('.ledger-when')[1]?.textContent).toBe('Sun, Nov 1 – Wed, Nov 4');+ expect(doc.querySelectorAll('.code-chip')).toHaveLength(1);+ expect(doc.querySelector('.ledger-row')?.getAttribute('style')).toBe('--kind:#3b82f6');+ });++ it('FE-PDFOVERVIEW-005: a trip without bookings or stays prints no list at all', () => {+ expect(ledgerHtml([], tr)).toBe('');+ });+});diff --git a/client/src/components/PDF/tripPdfOverview.ts b/client/src/components/PDF/tripPdfOverview.tsindex b89b371ec..2d4546aec 100644--- a/client/src/components/PDF/tripPdfOverview.ts+++ b/client/src/components/PDF/tripPdfOverview.ts@@ -70,7 +70,7 @@ export function glanceHtml(rows: readonly GlanceRow[], tr: Translate): string {<th>${escHtml(tr('common.date'))}</th><th>${escHtml(tr('pdf.plan'))}</th><th>${escHtml(tr('pdf.stay'))}</th>- <th class="glance-end">${glyph('pin', 9)}</th>+ <th class="glance-stops">${glyph('pin', 9)}</th>${withCost ? `<th class="glance-end">${escHtml(tr('pdf.costLabel'))}</th>` : ''}</tr></thead><tbody>${rows@@ -80,7 +80,7 @@ export function glanceHtml(rows: readonly GlanceRow[], tr: Translate): string {<td class="num">${escHtml(r.date)}</td><td class="glance-title">${escHtml(r.title)}</td><td>${escHtml(r.stay)}</td>- <td class="num">${r.stops || ''}</td>+ <td class="num glance-stops">${r.stops || ''}</td>${withCost ? `<td class="num">${r.cost ?? ''}</td>` : ''}</tr>`)diff --git a/client/src/components/PDF/tripPdfStyles.ts b/client/src/components/PDF/tripPdfStyles.tsindex 8d23e8603..a875c6f47 100644--- a/client/src/components/PDF/tripPdfStyles.ts+++ b/client/src/components/PDF/tripPdfStyles.ts@@ -81,10 +81,6 @@ export function tripPdfCss(): string {}.page-break { break-before: page; }- @media screen {- html { background: var(--wash-2); }- .doc { max-width: 210mm; margin: 0 auto; background: var(--paper); box-shadow: 0 0 0 1px var(--hair); }- }/* ── Cover ───────────────────────────────────────────────── */.cover {@@ -153,6 +149,8 @@ export function tripPdfCss(): string {.glance-day { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 18px; padding: 0 5px; border-radius: 6px; background: var(--day); color: var(--paper); font-family: var(--num); font-weight: 600; font-size: calc(8px * var(--t)); }.glance-title { color: var(--ink); font-weight: 500; }.glance .num, .glance-end { text-align: end; white-space: nowrap; }+ .glance .glance-stops { text-align: center; }+ .glance th.glance-stops svg { display: inline-block; vertical-align: -1px; }.ledger { display: grid; gap: 5px; }.ledger-row {@@ -358,7 +356,7 @@ export function tripPdfCss(): string {.note-kicker { font-family: var(--num); font-size: calc(7.5px * var(--t)); font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--kind, var(--ink-3)); }.note-text { font-size: calc(9.5px * var(--t)); color: var(--ink); line-height: 1.5; }.booking-card .note-text { font-size: calc(11px * var(--t)); font-weight: 600; line-height: 1.35; }- .note-time { font-size: calc(8.5px * var(--t)); color: var(--ink-3); margin-block-start: 2px; }+ .note-time { font-size: calc(8.5px * var(--t)); color: var(--ink-3); margin-block-start: 2px; white-space: pre-line; }.note-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-block-start: 4px; }.note-line .route { font-family: var(--num); font-size: calc(9px * var(--t)); font-weight: 600; color: var(--ink); margin-inline-end: 2px; }.booking-card .chip { background: var(--paper); }