mirror of
https://github.com/dong-nz/cv.git
synced 2026-11-22 16:10:40 +07:00
feat(edit): pick a project's category in the record settings
category had no edit control anywhere: the settings popover covered featured + sections only, the badge is display-only, and a new project silently got category 'experiment' from the draft template. ProjectSettingsPanel now renders a category select whose options are the label map of ui/projects.json (the vocabulary rule 7 checks a project against) with the project's current value appended, so opening the panel never rewrites a project whose label is missing; the write goes through setStructured('projects', '[i].category', ...), the path smoke-draft check 11 already gates.
ui.edit.label added to both languages. .record-settings-field select joins the field-control rule in App.css, which also styles the timeline variant select that had none. Out of scope by design: a category with no labels - UI documents stay read-only in v4, so its labels are a repository edit.
Docs: inline-editing spec 2.4 + component inventory + progress rows 10 (the add-button fix) and 11; spec-v5 5.4 links the picker to rule 7; AGENTS.md editable-surface bullet corrected (category is a single structure value, not a chip list). Verified: pnpm build, pnpm validate:content, pnpm lint (5 pre-existing warnings only), smoke-draft 11/11.
This commit is contained in:
1 parent
8776247176
commit
1bc12d23a6
7 files changed
+34
-6
No files matched your search
+2
-1
@@ -2484,7 +2484,8 @@
|
||||
margin: 8px 0;
|
||||
}
|
||||
|
||||
.record-settings-field input {
|
||||
.record-settings-field input,
|
||||
.record-settings-field select {
|
||||
background: var(--bg-surface);
|
||||
color: inherit;
|
||||
border: 1px solid var(--border);
|
||||
|
||||
@@ -45,8 +45,8 @@ export function RecordSettings({ title, onClose, children }: RecordSettingsProps
|
||||
);
|
||||
}
|
||||
|
||||
// A project's structure: featured visibility and the section list — order,
|
||||
// type, delete, add (spec-v4-inline-editing §2.4).
|
||||
// A project's structure: featured visibility, its category, and the section
|
||||
// list — order, type, delete, add (spec-v4-inline-editing §2.4).
|
||||
export function ProjectSettingsPanel({ project }: { project: ProjectStructure }) {
|
||||
const edit = useEdit();
|
||||
const { ui: s } = useI18n();
|
||||
@@ -56,6 +56,12 @@ export function ProjectSettingsPanel({ project }: { project: ProjectStructure })
|
||||
if (index < 0) return null;
|
||||
const sections = project.sections;
|
||||
const typeLabels = s.edit.sectionTypes;
|
||||
// The category vocabulary is the label map the UI documents carry — the same
|
||||
// map the badge renders from, and the one rule 7 checks a project against
|
||||
// (spec-v5 §5.4). The current value is kept in the list even when its label
|
||||
// is missing, so opening this panel never rewrites a project silently.
|
||||
const categoryLabels = new Map<string, string>(Object.entries(s.projects.categories));
|
||||
const categoryIds = [...new Set([...categoryLabels.keys(), project.category])];
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -68,6 +74,21 @@ export function ProjectSettingsPanel({ project }: { project: ProjectStructure })
|
||||
{s.edit.featured}
|
||||
</label>
|
||||
|
||||
<label className="record-settings-field">
|
||||
<span>{s.edit.category}</span>
|
||||
<select
|
||||
aria-label={`${s.edit.category} — ${project.id}`}
|
||||
value={project.category}
|
||||
onChange={(event) => edit.setStructured('projects', `[${index}].category`, event.target.value)}
|
||||
>
|
||||
{categoryIds.map((id) => (
|
||||
<option key={id} value={id}>
|
||||
{categoryLabels.get(id) ?? id}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
|
||||
<div className="record-settings-group-title">{s.edit.sections}</div>
|
||||
<ul className="record-settings-list">
|
||||
{sections.map((section, i) => (
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
"newTag": "new",
|
||||
"emphasis": "Emphasis",
|
||||
"featured": "Featured on the home page",
|
||||
"category": "Category",
|
||||
"sections": "Sections",
|
||||
"sectionType": "Section type",
|
||||
"sectionTypes": {
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
"newTag": "mới",
|
||||
"emphasis": "Nhấn mạnh",
|
||||
"featured": "Nổi bật",
|
||||
"category": "Danh mục",
|
||||
"sections": "Các mục",
|
||||
"sectionType": "Kiểu mục",
|
||||
"sectionTypes": {
|
||||
|
||||
Reference in new issue
Block a user