feat(collections): show and edit the own notes of a saved place

A saved place has carried notes for a while (the API and the assistant write
them), but neither the phone sheet nor the desktop detail showed them, so
notes written there were invisible. Both now show them under the
description when there are any, and edit them beside it, through the shared
form hook.

Addresses discussion #3168.
This commit is contained in:
Maurice
2026-11-27 23:13:31 +01:00
parent 59b8d00373
commit dd1a117b92
32 changed files with 110 additions and 4 deletions
@@ -32,7 +32,7 @@ interface CollectionPlaceDetailProps {
anchorRect?: { left: number; width: number } | null
onClose: () => void
onSetStatus: (status: CollectionStatus) => void
onSave: (patch: { name?: string; description?: string | null; links?: CollectionLink[]; category_id?: number | null; label_ids?: number[]; image_url?: string | null; lat?: number | null; lng?: number | null; address?: string | null }) => Promise<void>
onSave: (patch: { name?: string; description?: string | null; notes?: string | null; links?: CollectionLink[]; category_id?: number | null; label_ids?: number[]; image_url?: string | null; lat?: number | null; lng?: number | null; address?: string | null }) => Promise<void>
/** Upload a custom cover image (#1136); enables the cover change/remove controls. */
onUploadImage?: (file: File) => Promise<void>
onCopyToTrip: () => void
@@ -74,7 +74,7 @@ export default function CollectionPlaceDetail({
const navigationTargets = getNavigationTargets(place)
const descRef = useRef<HTMLTextAreaElement>(null)
const {
editing, setEditing, name, setName, categoryId, setCategoryId, description, setDescription, links, setLinks, setLink,
editing, setEditing, name, setName, categoryId, setCategoryId, description, setDescription, notes, setNotes, links, setLinks, setLink,
labelIds, toggleLabel, address, setAddress, lat, setLat, lng, setLng, saving, imgBusy, cover: banner, assignedLabels,
handleImagePick: handleCoverPick, handleImageRemove, cancelEdit: resetForm, save,
} = useCollectionPlaceForm({ place, labels, onSave, onUploadImage, t, normalizeLinkUrl, withCoordinates: true })
@@ -226,6 +226,11 @@ export default function CollectionPlaceDetail({
<MarkdownToolbar textareaRef={descRef} onUpdate={setDescription} />
<textarea ref={descRef} value={description} onChange={e => setDescription(e.target.value)} rows={4} placeholder={t('collections.descriptionPlaceholder')} className="col-detail-textarea" />
</div>
{/* Notes: the traveller's own, apart from the description (#3168) */}
<div className="col-detail-field">
<div className="col-detail-label">{t('collections.notes')}</div>
<textarea value={notes} onChange={e => setNotes(e.target.value)} rows={3} placeholder={t('collections.notesPlaceholder')} className="col-detail-textarea" />
</div>
{/* Links */}
<div className="col-detail-field">
<div className="col-detail-label">{t('collections.links')}</div>
@@ -248,6 +253,12 @@ export default function CollectionPlaceDetail({
<Markdown remarkPlugins={[remarkGfm, remarkBreaks]} components={markdownLinkComponents}>{place.description}</Markdown>
</div>
)}
{place.notes?.trim() && (
<div className="col-detail-field">
<div className="col-detail-label">{t('collections.notes')}</div>
<p className="m-0 whitespace-pre-wrap text-body text-content-muted [overflow-wrap:anywhere]">{place.notes}</p>
</div>
)}
{place.links && place.links.length > 0 && (
<div className="col-detail-links">
{place.links.map((l, i) => (
@@ -176,6 +176,7 @@ describe('useCollectionPlaceForm', () => {
expect(detail.props.onSave).toHaveBeenCalledWith({
name: 'Louvre',
description: 'Museum',
notes: null,
links: [{ label: 'Map', url: 'https://maps.example' }],
category_id: 3,
label_ids: [11],
@@ -192,6 +193,7 @@ describe('useCollectionPlaceForm', () => {
expect(sheet.props.onSave).toHaveBeenCalledWith({
name: 'Louvre',
description: 'Museum',
notes: null,
links: [{ label: 'Site', url: 'https://louvre.example' }],
category_id: 3,
label_ids: [10],
@@ -199,6 +201,25 @@ describe('useCollectionPlaceForm', () => {
});
});
it('FE-COMP-COLPLACEHOOK-014: seeds, edits and saves the own notes on a saved place (#3168)', async () => {
const sheet = setup({ place: place({ notes: 'Book a week ahead' }) });
expect(sheet.result.current.notes).toBe('Book a week ahead');
act(() => {
sheet.result.current.setEditing(true);
sheet.result.current.setNotes(' Closed on Tuesdays ');
});
await act(async () => {
await sheet.result.current.save();
});
expect(sheet.props.onSave).toHaveBeenCalledWith(expect.objectContaining({ notes: 'Closed on Tuesdays' }));
act(() => sheet.result.current.setNotes(' '));
await act(async () => {
await sheet.result.current.save();
});
expect(sheet.props.onSave).toHaveBeenLastCalledWith(expect.objectContaining({ notes: null }));
});
it('FE-COMP-COLPLACEHOOK-010: a failed save stays in edit mode and toasts', async () => {
const onSave = vi.fn().mockRejectedValue({ response: { data: { error: 'Locked' } } });
const { result } = setup({ onSave });
@@ -12,6 +12,7 @@ import { cleanListLinks } from './useListEditor';
export interface CollectionPlacePatch {
name?: string;
description?: string | null;
notes?: string | null;
links?: CollectionLink[];
category_id?: number | null;
label_ids?: number[];
@@ -84,6 +85,8 @@ export function useCollectionPlaceForm({
const [name, setName] = useState(shown?.name ?? '');
const [categoryId, setCategoryId] = useState<number | null>(shown?.category_id ?? null);
const [description, setDescription] = useState(shown?.description ?? '');
// The traveller's own notes on the place (#3168), apart from its description.
const [notes, setNotes] = useState(shown?.notes ?? '');
const [links, setLinks] = useState<CollectionLink[]>(shown?.links ?? []);
const [labelIds, setLabelIds] = useState<number[]>(shown?.label_ids ?? []);
const [address, setAddress] = useState(shown?.address ?? '');
@@ -101,6 +104,7 @@ export function useCollectionPlaceForm({
setName(p.name);
setCategoryId(p.category_id ?? null);
setDescription(p.description ?? '');
setNotes(p.notes ?? '');
setLinks(p.links ?? []);
setLabelIds(p.label_ids ?? []);
setAddress(p.address ?? '');
@@ -189,6 +193,7 @@ export function useCollectionPlaceForm({
const base = {
name: name.trim() || shown.name,
description: description.trim() || null,
notes: notes.trim() || null,
links: cleanListLinks(links, normalizeLinkUrl),
category_id: categoryId,
label_ids: labelIds,
@@ -215,6 +220,8 @@ export function useCollectionPlaceForm({
setCategoryId,
description,
setDescription,
notes,
setNotes,
links,
setLinks,
setLink,
@@ -35,7 +35,7 @@ interface MCollPlaceSheetProps {
labels: CollectionLabel[]
onClose: () => void
onSetStatus: (status: CollectionStatus) => void
onSave: (patch: { name?: string; description?: string | null; links?: CollectionLink[]; category_id?: number | null; label_ids?: number[]; image_url?: string | null; address?: string | null }) => Promise<void>
onSave: (patch: { name?: string; description?: string | null; notes?: string | null; links?: CollectionLink[]; category_id?: number | null; label_ids?: number[]; image_url?: string | null; address?: string | null }) => Promise<void>
onUploadImage?: (file: File) => Promise<void>
onCopyToTrip: () => void
onRemove: () => void
@@ -57,7 +57,7 @@ export default function MCollPlaceSheet({
const [navOpen, setNavOpen] = useState(false)
const navBtnRef = useRef<HTMLButtonElement | null>(null)
const {
shown: held, editing, setEditing, name, setName, address, setAddress, categoryId, setCategoryId, description, setDescription,
shown: held, editing, setEditing, name, setName, address, setAddress, categoryId, setCategoryId, description, setDescription, notes, setNotes,
links, setLinks, labelIds, toggleLabel, saving, imgBusy, cover, assignedLabels, handleImagePick, handleImageRemove, cancelEdit, save,
} = useCollectionPlaceForm({
place, labels, onSave, onUploadImage, t, normalizeLinkUrl, holdLastPlace: true, dropPhotoOnPlaceUpdate: true,
@@ -195,6 +195,8 @@ export default function MCollPlaceSheet({
)}
<Eyebrow className="mb-[6px] mt-[14px]">{t('collections.description').toUpperCase()}</Eyebrow>
<textarea rows={4} value={description} onChange={e => setDescription(e.target.value)} placeholder={t('collections.descriptionPlaceholder')} className={TEXTAREA_CLS} />
<Eyebrow className="mb-[6px] mt-[14px]">{t('collections.notes').toUpperCase()}</Eyebrow>
<textarea rows={3} value={notes} onChange={e => setNotes(e.target.value)} placeholder={t('collections.notesPlaceholder')} className={TEXTAREA_CLS} />
<Eyebrow className="mb-[6px] mt-[14px]">{t('collections.links').toUpperCase()}</Eyebrow>
<MCollLinksEditor links={links} onChange={setLinks} t={t} />
<div className="mt-4 flex items-center gap-2">
@@ -228,6 +230,15 @@ export default function MCollPlaceSheet({
<Markdown remarkPlugins={[remarkGfm, remarkBreaks]}>{held.description}</Markdown>
</div>
)}
{/* The traveller's own notes (#3168), the way the place sheet of a trip shows them. */}
{held.notes?.trim() && (
<>
<Eyebrow className="mb-[6px] mt-[14px]">{t('collections.notes').toUpperCase()}</Eyebrow>
<p className="m-0 whitespace-pre-wrap rounded-[14px] bg-m-card px-[13px] py-[10px] font-geist text-caption leading-[1.55] text-m-muted [overflow-wrap:anywhere]">
{held.notes}
</p>
</>
)}
{held.links && held.links.length > 0 && (
<div className="mt-3 flex flex-wrap gap-[6px]">
{held.links.map((l, i) => (
+2
View File
@@ -64,6 +64,8 @@ const collection: TranslationStrings = {
'collections.changeCover': 'تغيير الغلاف',
'collections.description': 'الوصف',
'collections.descriptionPlaceholder': 'أضف وصفًا…',
'collections.notes': 'ملاحظات',
'collections.notesPlaceholder': 'ملاحظاتك الخاصة…',
'collections.links': 'روابط',
'collections.linkLabel': 'التسمية',
'collections.addLink': 'إضافة رابط',
+2
View File
@@ -36,6 +36,8 @@ const collection: TranslationStrings = {
'collections.changeCover': 'Üzlüyü dəyiş',
'collections.description': 'Təsvir',
'collections.descriptionPlaceholder': 'Təsvir əlavə edin…',
'collections.notes': 'Qeydlər',
'collections.notesPlaceholder': 'Öz qeydləriniz…',
'collections.links': 'Linklər',
'collections.linkLabel': 'Etiket',
'collections.addLink': 'Link əlavə et',
+2
View File
@@ -36,6 +36,8 @@ const collection: TranslationStrings = {
'collections.changeCover': 'Alterar capa',
'collections.description': 'Descrição',
'collections.descriptionPlaceholder': 'Adicione uma descrição…',
'collections.notes': 'Notas',
'collections.notesPlaceholder': 'Suas anotações…',
'collections.links': 'Links', // same-as-en
'collections.linkLabel': 'Rótulo',
'collections.addLink': 'Adicionar link',
+2
View File
@@ -36,6 +36,8 @@ const collection: TranslationStrings = {
'collections.changeCover': 'Canviar portada',
'collections.description': 'Descripció',
'collections.descriptionPlaceholder': 'Afegeix una descripció…',
'collections.notes': 'Notes',
'collections.notesPlaceholder': 'Les teves notes…',
'collections.links': 'Enllaços',
'collections.linkLabel': 'Etiqueta',
'collections.addLink': 'Afegir enllaç',
+2
View File
@@ -43,6 +43,8 @@ const collection: TranslationStrings = {
'collections.changeCover': 'Změnit obálku',
'collections.description': 'Popis',
'collections.descriptionPlaceholder': 'Přidejte popis…',
'collections.notes': 'Poznámky',
'collections.notesPlaceholder': 'Vlastní poznámky…',
'collections.links': 'Odkazy',
'collections.linkLabel': 'Popisek',
'collections.addLink': 'Přidat odkaz',
+2
View File
@@ -36,6 +36,8 @@ const collection: TranslationStrings = {
'collections.changeCover': 'Titelbild ändern',
'collections.description': 'Beschreibung',
'collections.descriptionPlaceholder': 'Beschreibung hinzufügen…',
'collections.notes': 'Notizen',
'collections.notesPlaceholder': 'Eigene Notizen…',
'collections.links': 'Links', // same-as-en
'collections.linkLabel': 'Bezeichnung',
'collections.addLink': 'Link hinzufügen',
+2
View File
@@ -36,6 +36,8 @@ const collection: TranslationStrings = {
'collections.changeCover': 'Change cover',
'collections.description': 'Description',
'collections.descriptionPlaceholder': 'Add a description…',
'collections.notes': 'Notes',
'collections.notesPlaceholder': 'Your own notes…',
'collections.links': 'Links',
'collections.linkLabel': 'Label',
'collections.addLink': 'Add link',
+2
View File
@@ -36,6 +36,8 @@ const collection: TranslationStrings = {
'collections.changeCover': 'Cambiar portada',
'collections.description': 'Descripción',
'collections.descriptionPlaceholder': 'Añade una descripción…',
'collections.notes': 'Notas',
'collections.notesPlaceholder': 'Tus notas…',
'collections.links': 'Enlaces',
'collections.linkLabel': 'Etiqueta',
'collections.addLink': 'Añadir enlace',
+2
View File
@@ -36,6 +36,8 @@ const collection: TranslationStrings = {
'collections.changeCover': 'Muuda kaanepilti',
'collections.description': 'Kirjeldus',
'collections.descriptionPlaceholder': 'Lisa kirjeldus…',
'collections.notes': 'Märkmed',
'collections.notesPlaceholder': 'Sinu märkmed…',
'collections.links': 'Lingid',
'collections.linkLabel': 'Nimetus',
'collections.addLink': 'Lisa link',
+2
View File
@@ -36,6 +36,8 @@ const collection: TranslationStrings = {
'collections.changeCover': 'Changer la couverture',
'collections.description': 'Description', // same-as-en
'collections.descriptionPlaceholder': 'Ajouter une description…',
'collections.notes': 'Notes',
'collections.notesPlaceholder': 'Vos notes…',
'collections.links': 'Liens',
'collections.linkLabel': 'Libellé',
'collections.addLink': 'Ajouter un lien',
+2
View File
@@ -36,6 +36,8 @@ const collection: TranslationStrings = {
'collections.changeCover': 'Αλλαγή εξωφύλλου',
'collections.description': 'Περιγραφή',
'collections.descriptionPlaceholder': 'Προσθέστε μια περιγραφή…',
'collections.notes': 'Σημειώσεις',
'collections.notesPlaceholder': 'Οι σημειώσεις σας…',
'collections.links': 'Σύνδεσμοι',
'collections.linkLabel': 'Ετικέτα',
'collections.addLink': 'Προσθήκη συνδέσμου',
+2
View File
@@ -43,6 +43,8 @@ const collection: TranslationStrings = {
'collections.changeCover': 'החלפת שער',
'collections.description': 'תיאור',
'collections.descriptionPlaceholder': 'הוספת תיאור…',
'collections.notes': 'הערות',
'collections.notesPlaceholder': 'ההערות שלך…',
'collections.links': 'קישורים',
'collections.linkLabel': 'תווית',
'collections.addLink': 'הוספת קישור',
+2
View File
@@ -36,6 +36,8 @@ const collection: TranslationStrings = {
'collections.changeCover': 'Borító módosítása',
'collections.description': 'Leírás',
'collections.descriptionPlaceholder': 'Adjon hozzá leírást…',
'collections.notes': 'Jegyzetek',
'collections.notesPlaceholder': 'Saját jegyzetek…',
'collections.links': 'Hivatkozások',
'collections.linkLabel': 'Címke',
'collections.addLink': 'Hivatkozás hozzáadása',
+2
View File
@@ -29,6 +29,8 @@ const collection: TranslationStrings = {
'collections.changeCover': 'Ubah sampul',
'collections.description': 'Deskripsi',
'collections.descriptionPlaceholder': 'Tambahkan deskripsi…',
'collections.notes': 'Catatan',
'collections.notesPlaceholder': 'Catatan Anda…',
'collections.links': 'Tautan',
'collections.linkLabel': 'Label', // same-as-en
'collections.addLink': 'Tambah tautan',
+2
View File
@@ -36,6 +36,8 @@ const collection: TranslationStrings = {
'collections.changeCover': 'Cambia copertina',
'collections.description': 'Descrizione',
'collections.descriptionPlaceholder': 'Aggiungi una descrizione…',
'collections.notes': 'Note',
'collections.notesPlaceholder': 'Le tue note…',
'collections.links': 'Link',
'collections.linkLabel': 'Etichetta',
'collections.addLink': 'Aggiungi link',
+2
View File
@@ -29,6 +29,8 @@ const collection: TranslationStrings = {
'collections.changeCover': 'カバーを変更',
'collections.description': '説明',
'collections.descriptionPlaceholder': '説明を追加…',
'collections.notes': 'メモ',
'collections.notesPlaceholder': '自分用のメモ…',
'collections.links': 'リンク',
'collections.linkLabel': 'ラベル',
'collections.addLink': 'リンクを追加',
+2
View File
@@ -29,6 +29,8 @@ const collection: TranslationStrings = {
'collections.changeCover': '커버 변경',
'collections.description': '설명',
'collections.descriptionPlaceholder': '설명 추가…',
'collections.notes': '메모',
'collections.notesPlaceholder': '나만의 메모…',
'collections.links': '링크',
'collections.linkLabel': '레이블',
'collections.addLink': '링크 추가',
+2
View File
@@ -36,6 +36,8 @@ const collection: TranslationStrings = {
'collections.changeCover': 'Omslag wijzigen',
'collections.description': 'Beschrijving',
'collections.descriptionPlaceholder': 'Voeg een beschrijving toe…',
'collections.notes': 'Notities',
'collections.notesPlaceholder': 'Je eigen notities…',
'collections.links': 'Links', // same-as-en
'collections.linkLabel': 'Label', // same-as-en
'collections.addLink': 'Link toevoegen',
+2
View File
@@ -50,6 +50,8 @@ const collection: TranslationStrings = {
'collections.changeCover': 'Zmień okładkę',
'collections.description': 'Opis',
'collections.descriptionPlaceholder': 'Dodaj opis…',
'collections.notes': 'Notatki',
'collections.notesPlaceholder': 'Twoje notatki…',
'collections.links': 'Linki',
'collections.linkLabel': 'Etykieta',
'collections.addLink': 'Dodaj link',
+2
View File
@@ -50,6 +50,8 @@ const collection: TranslationStrings = {
'collections.changeCover': 'Изменить обложку',
'collections.description': 'Описание',
'collections.descriptionPlaceholder': 'Добавьте описание…',
'collections.notes': 'Заметки',
'collections.notesPlaceholder': 'Ваши заметки…',
'collections.links': 'Ссылки',
'collections.linkLabel': 'Название',
'collections.addLink': 'Добавить ссылку',
+2
View File
@@ -43,6 +43,8 @@ const collection: TranslationStrings = {
'collections.changeCover': 'Zmeniť obálku',
'collections.description': 'Popis',
'collections.descriptionPlaceholder': 'Pridajte popis…',
'collections.notes': 'Poznámky',
'collections.notesPlaceholder': 'Vlastné poznámky…',
'collections.links': 'Odkazy',
'collections.linkLabel': 'Popisok',
'collections.addLink': 'Pridať odkaz',
+2
View File
@@ -36,6 +36,8 @@ const collection: TranslationStrings = {
'collections.changeCover': 'Byt omslag',
'collections.description': 'Beskrivning',
'collections.descriptionPlaceholder': 'Lägg till en beskrivning…',
'collections.notes': 'Anteckningar',
'collections.notesPlaceholder': 'Egna anteckningar…',
'collections.links': 'Länkar',
'collections.linkLabel': 'Etikett',
'collections.addLink': 'Lägg till länk',
+2
View File
@@ -29,6 +29,8 @@ const collection: TranslationStrings = {
'collections.changeCover': 'เปลี่ยนปก',
'collections.description': 'คำอธิบาย',
'collections.descriptionPlaceholder': 'เพิ่มคำอธิบาย...',
'collections.notes': 'บันทึก',
'collections.notesPlaceholder': 'บันทึกของคุณ…',
'collections.links': 'ลิงก์',
'collections.linkLabel': 'ป้ายกำกับ',
'collections.addLink': 'เพิ่มลิงก์',
+2
View File
@@ -36,6 +36,8 @@ const collection: TranslationStrings = {
'collections.changeCover': 'Kapağı değiştir',
'collections.description': 'Açıklama',
'collections.descriptionPlaceholder': 'Bir açıklama ekleyin…',
'collections.notes': 'Notlar',
'collections.notesPlaceholder': 'Notlarınız…',
'collections.links': 'Bağlantılar',
'collections.linkLabel': 'Etiket',
'collections.addLink': 'Bağlantı ekle',
+2
View File
@@ -50,6 +50,8 @@ const collection: TranslationStrings = {
'collections.changeCover': 'Змінити обкладинку',
'collections.description': 'Опис',
'collections.descriptionPlaceholder': 'Додайте опис…',
'collections.notes': 'Нотатки',
'collections.notesPlaceholder': 'Ваші нотатки…',
'collections.links': 'Посилання',
'collections.linkLabel': 'Підпис',
'collections.addLink': 'Додати посилання',
+2
View File
@@ -29,6 +29,8 @@ const collection: TranslationStrings = {
'collections.changeCover': 'Đổi ảnh bìa',
'collections.description': 'Mô tả',
'collections.descriptionPlaceholder': 'Thêm mô tả…',
'collections.notes': 'Ghi chú',
'collections.notesPlaceholder': 'Ghi chú của bạn…',
'collections.links': 'Liên kết',
'collections.linkLabel': 'Nhãn',
'collections.addLink': 'Thêm liên kết',
+2
View File
@@ -29,6 +29,8 @@ const collection: TranslationStrings = {
'collections.changeCover': '更換封面',
'collections.description': '描述',
'collections.descriptionPlaceholder': '新增描述…',
'collections.notes': '備註',
'collections.notesPlaceholder': '你的備註…',
'collections.links': '連結',
'collections.linkLabel': '標籤',
'collections.addLink': '新增連結',
+2
View File
@@ -29,6 +29,8 @@ const collection: TranslationStrings = {
'collections.changeCover': '更换封面',
'collections.description': '描述',
'collections.descriptionPlaceholder': '添加描述…',
'collections.notes': '备注',
'collections.notesPlaceholder': '你的备注…',
'collections.links': '链接',
'collections.linkLabel': '标签',
'collections.addLink': '添加链接',