Show the edition statement on cards and in the library

The edition comes only from a record for this exact edition: the Library
of Congress record's edition statement first, then Open Library's edition
name when it is a well-formed statement. Existing books are filled in at
startup without changing anything else about them.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Fable 5.2 committed 2026-11-19 17:49:59 -07:00
1 parent e83774adbd
commit bb46d343a8
26 files changed
+455 -34

No files matched your search

+1 -1
View File
@@ -30,7 +30,7 @@ function toBook(r: unknown): Book {
}
export interface ManualInput { title: string; authors: string[]; year?: number; publisher?: string; callNumber?: string }
export interface BookPatch { title?: string; authors?: string[]; publisher?: string | null; year?: number | null; callNumber?: string }
export interface BookPatch { title?: string; authors?: string[]; publisher?: string | null; year?: number | null; edition?: string | null; callNumber?: string }
export const api = {
scan: (isbn: string) => request<{ book: Book; duplicate: boolean }>('POST', '/api/scan', { isbn }),
+1 -1
View File
@@ -8,7 +8,7 @@ function book(id: number, over: Partial<Book>): Book {
id, isbn13: null, lccn: null, title: 'T' + id, subtitle: null, authors: [], publisher: null, year: null,
subjects: [], callNumber: null, sortKey: null, confidence: null, source: null, dewey: null,
status: 'pending', attentionReason: null, manualOverride: false, inQueue: true,
printedAt: null, hierarchyTail: null, createdAt: `2026-01-01T00:00:0${id}Z`, updatedAt: '', ...over,
printedAt: null, hierarchyTail: null, edition: null, createdAt: `2026-01-01T00:00:0${id}Z`, updatedAt: '', ...over,
};
}
const ready = (id: number, over: Partial<Book> = {}) => book(id, { status: 'resolved', callNumber: 'QA76.73 .R87 K53 2018', sortKey: 'k' + id, ...over });
+1 -1
View File
@@ -5,7 +5,7 @@ import { CallNo } from './CallNo.tsx';
import { StateMark, StateText } from './StateMark.tsx';
function Main({ book, showYear }: { book: Book; showYear: boolean }) {
const byline = [displayAuthors(book.authors).join(', '), showYear ? book.year : null].filter(Boolean).join(' · ');
const byline = [displayAuthors(book.authors).join(', '), showYear ? book.edition : null, showYear ? book.year : null].filter(Boolean).join(' · ');
return (
<span class="row-main">
<span class="row-title">{book.title}</span>
+8
View File
@@ -43,6 +43,7 @@ function EditorForm({ book, fixing, initial, onClose }: {
const [authors, setAuthors] = useState(book ? displayAuthors(book.authors).join('; ') : initial?.authors ?? '');
const [publisher, setPublisher] = useState(book?.publisher ?? '');
const [year, setYear] = useState(book?.year?.toString() ?? '');
const [edition, setEdition] = useState(book?.edition ?? '');
const [callNumber, setCallNumber] = useState(book?.callNumber ?? '');
const [picked, setPicked] = useState<SearchResult | null>(null);
const [yearError, setYearError] = useState('');
@@ -77,6 +78,7 @@ function EditorForm({ book, fixing, initial, onClose }: {
title: title.trim(), authors: names,
...(y.value !== null ? { year: y.value } : {}),
...(publisher.trim() ? { publisher: publisher.trim() } : {}),
...(edition.trim() ? { edition: edition.trim() } : {}),
...(callNumber.trim() ? { callNumber: callNumber.trim() } : {}),
});
upsertBook(created); setLastScan(created.id, false);
@@ -85,6 +87,8 @@ function EditorForm({ book, fixing, initial, onClose }: {
return;
}
const patch: BookPatch = { title: title.trim(), authors: names, publisher: publisher.trim() || null, year: y.value };
// Only a changed edition is sent: an untouched empty one stays "not looked up yet" so the catalogue can fill it.
if (edition.trim() !== (book.edition ?? '')) patch.edition = edition.trim();
const numberChanged = callNumber.trim() !== (book.callNumber ?? '');
if (numberChanged) patch.callNumber = callNumber.trim();
let saved = await api.patchBook(book.id, patch);
@@ -130,6 +134,10 @@ function EditorForm({ book, fixing, initial, onClose }: {
</label>
</div>
{yearError ? <p class="error" role="alert">{yearError}</p> : null}
<label class="field">Edition
<input value={edition} onInput={e => setEdition(e.currentTarget.value)} />
<span class="help">From the catalogue when it has one, for example Third edition. Optional.</span>
</label>
<label class="field">Call number
<input class="mono" value={callNumber} onInput={e => setCallNumber(e.currentTarget.value)} />
<span class="help">{book ? 'Changing this locks the number' : 'Optional. Leave it empty to have it looked up.'}</span>
+1 -1
View File
@@ -8,7 +8,7 @@ function book(id: number, over: Partial<Book>): Book {
id, isbn13: null, lccn: null, title: 'T' + id, subtitle: null, authors: [], publisher: null, year: null,
subjects: [], callNumber: null, sortKey: null, confidence: null, source: null, dewey: null,
status: 'resolved', attentionReason: null, manualOverride: false, inQueue: false,
printedAt: null, hierarchyTail: null, createdAt: '', updatedAt: '', ...over,
printedAt: null, hierarchyTail: null, edition: null, createdAt: '', updatedAt: '', ...over,
};
}
const qa = (id: number, key: string) => book(id, { callNumber: 'QA76.73 .R87', sortKey: key });
+1 -1
View File
@@ -8,7 +8,7 @@ function book(id: number, title: string, sortKey: string | null): Book {
id, isbn13: null, lccn: null, title, subtitle: null, authors: [], publisher: null, year: null,
subjects: [], callNumber: null, sortKey, confidence: null, source: null, dewey: null,
status: 'resolved', attentionReason: null, manualOverride: false, inQueue: true,
printedAt: null, hierarchyTail: null, createdAt: '', updatedAt: '',
printedAt: null, hierarchyTail: null, edition: null, createdAt: '', updatedAt: '',
};
}