feat(places): one place view for All places and the lists

The desktop dialog and the phone sheet of a place show its overview, notes,
tours and bookings, photos and files and its history in tabs, with the tags
of each list and trip, a markdown notes editor, uploads and the place
picture. The rating bar of All places is the rating row the lists show,
with its voters, and votes once for every copy. All places filters by a
lowest rating and sorts by it, and the edit form changes the first copy the
reader may edit, which the server carries to the others.
This commit is contained in:
Maurice
2026-11-29 23:36:43 +00:00
parent 783c98f41e
commit d758f4c592
78 changed files with 5604 additions and 2797 deletions
@@ -73,13 +73,40 @@ export function useOriginNotes({
const targets = all.filter((n) => n.canEdit && !n.text.trim() && n.key !== editing);
const [draft, setDraft] = useState('');
const [busy, setBusy] = useState(false);
const [preview, setPreview] = useState(false);
/** A new note written for every trip and list that has none yet. */
const [everywhere, setEverywhere] = useState(false);
/** The note being written is a new one: it may still be moved to another trip or list. */
const isNew = !!editing && !all.find((n) => n.key === editing)?.text.trim();
/** Where a new note may go: the open one and every other empty one the reader may write. */
const composeTargets = isNew ? all.filter((n) => n.canEdit && !n.text.trim()) : [];
const edit = (note: OriginNote) => {
setChoosing(false);
setEditing(note.key);
setDraft(note.text);
setPreview(false);
setEverywhere(false);
};
const cancel = () => {
setEditing(null);
setPreview(false);
setEverywhere(false);
};
/** The new note goes to another trip or list; what is written so far stays. */
const retarget = (key: string | 'all') => {
if (key === 'all') {
setEverywhere(true);
return;
}
if (!all.some((n) => n.key === key && n.canEdit && !n.text.trim())) return;
setEverywhere(false);
setEditing(key);
};
/** The composer: straight into writing, for the first place a note can go (the chips switch it). */
const compose = () => {
if (targets[0]) edit(targets[0]);
};
const cancel = () => setEditing(null);
/** "+ Note": straight into the one place it can go, or ask where. */
const add = () => {
if (targets.length === 1) edit(targets[0]);
@@ -91,8 +118,12 @@ export function useOriginNotes({
if (!note || busy) return;
setBusy(true);
try {
await note.save(draft.trim() ? draft : null);
const text = draft.trim() ? draft : null;
// Everywhere: the same note in each trip and list that had none, one after another.
const into = everywhere && isNew ? composeTargets : [note];
for (const target of into) await target.save(text);
setEditing(null);
setPreview(false);
onSaved();
} catch (err) {
toast.error(getApiErrorMessage(err, t('common.error')));
@@ -101,5 +132,24 @@ export function useOriginNotes({
}
};
return { notes, targets, choosing, add, editing, draft, setDraft, busy, edit, cancel, save };
return {
notes,
targets,
choosing,
add,
compose,
editing,
isNew,
composeTargets,
everywhere,
retarget,
draft,
setDraft,
preview,
setPreview,
busy,
edit,
cancel,
save,
};
}