Show author names in natural order everywhere
Names read from MARC personal-name fields are stored as "Steve Allen", and names already stored as "Allen, Steve" are shown and printed in natural order. Search matches both forms. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
7ae1bcef0a
commit
60fa4ef6f7
17 files changed
+183
-15
No files matched your search
@@ -1,10 +1,11 @@
|
||||
import { displayAuthors } from '../../shared/names.ts';
|
||||
import type { Book } from '../../shared/types.ts';
|
||||
import { rowState } from '../bookstate.ts';
|
||||
import { CallNo } from './CallNo.tsx';
|
||||
import { StateMark, StateText } from './StateMark.tsx';
|
||||
|
||||
function Main({ book, showYear }: { book: Book; showYear: boolean }) {
|
||||
const byline = [book.authors.join(', '), showYear ? book.year : null].filter(Boolean).join(' · ');
|
||||
const byline = [displayAuthors(book.authors).join(', '), showYear ? book.year : null].filter(Boolean).join(' · ');
|
||||
return (
|
||||
<span class="row-main">
|
||||
<span class="row-title">{book.title}</span>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { useEffect, useState } from 'preact/hooks';
|
||||
import type { Book, SearchResult } from '../../shared/types.ts';
|
||||
import { displayAuthors } from '../../shared/names.ts';
|
||||
import { api } from '../api.ts';
|
||||
import type { BookPatch } from '../api.ts';
|
||||
import { getBook, setLastScan, upsertBook, dispatch, useBooks } from '../live.ts';
|
||||
@@ -39,7 +40,7 @@ function EditorForm({ book, fixing, initial, onClose }: {
|
||||
book: Book | undefined; fixing: boolean; initial?: { title?: string; authors?: string }; onClose: () => void;
|
||||
}) {
|
||||
const [title, setTitle] = useState(book ? knownTitle(book) || book.title : initial?.title ?? '');
|
||||
const [authors, setAuthors] = useState(book?.authors.join('; ') ?? initial?.authors ?? '');
|
||||
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 [callNumber, setCallNumber] = useState(book?.callNumber ?? '');
|
||||
@@ -98,7 +99,7 @@ function EditorForm({ book, fixing, initial, onClose }: {
|
||||
function pick(r: SearchResult) {
|
||||
setPicked(r);
|
||||
setTitle(r.title);
|
||||
setAuthors(r.authors.join('; '));
|
||||
setAuthors(displayAuthors(r.authors).join('; '));
|
||||
setPublisher(r.publisher ?? '');
|
||||
setYear(r.year ? String(r.year) : '');
|
||||
if (r.lcc[0]) setCallNumber(r.lcc[0]);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { displayAuthors } from '../../shared/names.ts';
|
||||
import type { SearchResult } from '../../shared/types.ts';
|
||||
|
||||
/** Next highlighted index for an arrow key; -1 means nothing is highlighted. */
|
||||
@@ -22,7 +23,7 @@ export function ResultList({ id, label, results, active, onPick, onHover, footer
|
||||
<li role="option" id={`${id}-${i}`} class={'result' + (i === active ? ' active' : '')} aria-selected={i === active}
|
||||
onMouseDown={keep} onMouseMove={() => onHover(i)} onClick={() => onPick(r)}>
|
||||
<span class="result-title">{r.title}</span>
|
||||
<span class="result-sub">{[r.authors.join(', '), r.year, r.publisher].filter(Boolean).join(' · ')}</span>
|
||||
<span class="result-sub">{[displayAuthors(r.authors).join(', '), r.year, r.publisher].filter(Boolean).join(' · ')}</span>
|
||||
</li>
|
||||
))}
|
||||
{footer ? (
|
||||
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
import type { Book } from '../shared/types.ts';
|
||||
import { parseCallNumber } from '../shared/callnumber.ts';
|
||||
import { classNames } from '../shared/lcc-outline.ts';
|
||||
import { displayAuthors } from '../shared/names.ts';
|
||||
import { compareShelf } from './store.ts';
|
||||
|
||||
export interface LibraryGroup { key: string; heading: string; books: Book[] }
|
||||
@@ -17,7 +18,7 @@ export function mainClass(book: Book): string | null {
|
||||
export function matchesQuery(book: Book, query: string): boolean {
|
||||
const needle = query.trim().toLowerCase();
|
||||
if (!needle) return true;
|
||||
return [book.title, book.authors.join(' '), book.isbn13 ?? '', book.callNumber ?? ''].some(s => s.toLowerCase().includes(needle));
|
||||
return [book.title, book.authors.join(' '), displayAuthors(book.authors).join(' '), book.isbn13 ?? '', book.callNumber ?? ''].some(s => s.toLowerCase().includes(needle));
|
||||
}
|
||||
|
||||
export const needsAttention = (book: Book) => book.status === 'needs_attention';
|
||||
|
||||
+2
-1
@@ -1,5 +1,6 @@
|
||||
import type { Book } from '../shared/types.ts';
|
||||
import { cardLines, formatCallNumber, parseCallNumber, withYear } from '../shared/callnumber.ts';
|
||||
import { displayAuthors } from '../shared/names.ts';
|
||||
import { cutterFor, mainEntry } from '../shared/cutter.ts';
|
||||
|
||||
/** A call number for `authors`/`title` that shelves next to `neighbour`: its class part, a new cutter, then the year. */
|
||||
@@ -21,7 +22,7 @@ export function findNeighbours(books: Book[], text: string, limit = 8): Book[] {
|
||||
const out: Book[] = [];
|
||||
for (const b of books) {
|
||||
if (!b.callNumber || !parseCallNumber(b.callNumber)) continue;
|
||||
if ([b.title, b.authors.join(' ')].some(s => s.toLowerCase().includes(needle))) out.push(b);
|
||||
if ([b.title, b.authors.join(' '), displayAuthors(b.authors).join(' ')].some(s => s.toLowerCase().includes(needle))) out.push(b);
|
||||
if (out.length >= limit) break;
|
||||
}
|
||||
return out;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { displayAuthors } from '../../shared/names.ts';
|
||||
import { useState } from 'preact/hooks';
|
||||
import { api } from '../api.ts';
|
||||
import { rowState } from '../bookstate.ts';
|
||||
@@ -32,7 +33,7 @@ export function LastScan({ onFix }: { onFix: (id: number) => void }) {
|
||||
return (
|
||||
<section class="last" aria-label="Last scan" aria-live="polite">
|
||||
<h2 class="last-title">{book.title}</h2>
|
||||
{book.authors.length ? <p class="last-author">{book.authors.join(', ')}</p> : null}
|
||||
{book.authors.length ? <p class="last-author">{displayAuthors(book.authors).join(', ')}</p> : null}
|
||||
<div class="last-state">
|
||||
{s.kind === 'looking' ? <><span class="last-mark"><Spinner /></span><StateText book={book} /></> : null}
|
||||
{s.kind === 'ready' ? (
|
||||
|
||||
Reference in new issue
Block a user