Skip to content

[Feature]: Book editor: make Category a combobox (default + existing categories) with free-text custom entry #191

Description

@hunter-read

In the book editor, Category is currently a plain free-text input (frontend/src/components/system/BookEditor.jsx, the category field ~line 142). Users have to remember/retype the exact category slug, which is error-prone and makes it easy to create accidental one-off categories via typos.

Request

Turn Category into a combobox / editable dropdown:

  • Offer the built-in categories as selectable options: core, starter-set, supplement, adventure, handout, character-sheet, map, homebrew (see CATEGORY_ORDER / CATEGORY_LABELS in frontend/src/constants.js), rendered with their friendly labels.
  • Also include any user-defined categories already in use in the library (e.g. custom category slugs produced by subfolder structure via guess_category / agnostic_category, or previously entered by hand), so the same category can be reused consistently.
  • Still allow entering a custom category name that is not in the list (free-text), so the current flexibility is preserved.

Notes / open questions

  • "If it is enabled" (from the request): this likely ties into the category-inference toggle in Allow disabling default folder-name category inference (global setting + per-system opt-out file) #190 — when folder-name inference is disabled, the dropdown may want to show only default + already-used categories rather than subfolder-derived ones. Confirm intended interaction with Allow disabling default folder-name category inference (global setting + per-system opt-out file) #190 before implementing.
  • Source of "existing categories": the frontend can derive the distinct set from the systems books already loaded in SystemDetailView, and/or a small backend endpoint could return distinct Book.category values. Prefer deriving client-side first to avoid a new endpoint unless a global list is needed.
  • Display friendly labels (CATEGORY_LABELS) but persist the slug; custom entries should be slugified consistently with the backend (slugify in backend/indexer.py) so they match on save.
  • Keep the free-text affordance obvious (editable/combobox, not a locked <select>).

Affected code

  • frontend/src/components/system/BookEditor.jsx (category field)
  • frontend/src/constants.js (category list/labels — reuse, do not duplicate)
  • Possibly frontend/src/views/SystemDetailView.jsx to pass the set of existing categories down as a prop.

Add/extend BookEditor tests for: selecting a default, selecting an existing custom category, and typing a brand-new custom category.

Metadata

Metadata

Assignees

Labels

Projects

Status
Done

Relationships

None yet

Development

No branches or pull requests

Issue actions