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
@@ -93,7 +93,7 @@ Content is split once, at authoring time, into language-neutral **structure docu
|
|||||||
- `src/i18n/draft.ts` — `DraftStore`: baselines (`data` + blob `sha`) of the 12 writable documents (4 structure + 8 text), copy-on-write draft, leaf-path diff, cross-document validation on every accepted edit, three-way rebase on save conflicts (Gitea 28 reports a blob-sha mismatch as 422 with a "does not match" message; older deployments answered 412 — both are handled; origin / base / working kept separate), draft persisted to sessionStorage `portfolio-draft`, sequential-PUT save (one commit per touched document, resume from the first unwritten one on failure). Edit mode writes JSON only: the id-union leg was deleted when spec-v5 made the unions generated, and the store is handed the branch's category labels (read-only `ui/projects.json` fetches) for rule 7 — `null` when they cannot be read, in which case the rule is skipped and the EditBar says so
|
- `src/i18n/draft.ts` — `DraftStore`: baselines (`data` + blob `sha`) of the 12 writable documents (4 structure + 8 text), copy-on-write draft, leaf-path diff, cross-document validation on every accepted edit, three-way rebase on save conflicts (Gitea 28 reports a blob-sha mismatch as 422 with a "does not match" message; older deployments answered 412 — both are handled; origin / base / working kept separate), draft persisted to sessionStorage `portfolio-draft`, sequential-PUT save (one commit per touched document, resume from the first unwritten one on failure). Edit mode writes JSON only: the id-union leg was deleted when spec-v5 made the unions generated, and the store is handed the branch's category labels (read-only `ui/projects.json` fetches) for rule 7 — `null` when they cannot be read, in which case the rule is skipped and the EditBar says so
|
||||||
- `src/components/ui/EditableText.tsx` — the site's own element (`as` = the tag or motion component it renders today) becomes the inline editor only in edit mode; commit on blur only (Vietnamese IME-safe), Esc cancels, Enter commits single-line fields, paste is plain-text, empty required values are rejected at commit; without an `EditContext` provider it renders byte-identical markup to the plain element
|
- `src/components/ui/EditableText.tsx` — the site's own element (`as` = the tag or motion component it renders today) becomes the inline editor only in edit mode; commit on blur only (Vietnamese IME-safe), Esc cancels, Enter commits single-line fields, paste is plain-text, empty required values are rejected at commit; without an `EditContext` provider it renders byte-identical markup to the plain element
|
||||||
- `src/components/layout/EditBar.tsx` — fixed save bar: per-path diff with revert and "appears on" page annotations (computed from the page manifests via `manifestsClaiming`, never from component code), conflict resolution (rebase / take-theirs / per-field keep-mine–keep-theirs), per-document save status, partial-save resume, exit confirm
|
- `src/components/layout/EditBar.tsx` — fixed save bar: per-path diff with revert and "appears on" page annotations (computed from the page manifests via `manifestsClaiming`, never from component code), conflict resolution (rebase / take-theirs / per-field keep-mine–keep-theirs), per-document save status, partial-save resume, exit confirm
|
||||||
- Editable surface: content text inline (pencil-triggered, click never edits) **and** structure — chip-level tag editors (technologies, categories, interests, roles, keywords, tagline emphasis), ghost add/delete/move on every record surface, per-record settings popover (`featured`, project section list + type picker, `variant`, location, logo), ids auto-generated from title slugs, social links handle-only with URLs derived in the loaders. Implemented 2026-10-23 (`spec-v4-inline-editing.md` + `spec-v4-data-organization.md`); the JSON panel is deleted. UI documents stay read-only in v4. Field provenance: hovering any pencil shows `document → pointer` (`describeField()` names the per-entity file automatically); the EditBar diff line and a `validate:content` error for the same field read identically
|
- Editable surface: content text inline (pencil-triggered, click never edits) **and** structure — chip-level tag editors for every tag array (`technologies`, `metrics`, `skills`, `interests`, `roles`, `keywords`, `responsibilities`, quote details, tagline segments), ghost add/delete/move on every record surface, per-record settings popover (`featured`, the project `category` picker, project section list + type picker, `variant`, location, logo), ids auto-generated from title slugs, social links handle-only with URLs derived in the loaders. Implemented 2026-10-23 (`spec-v4-inline-editing.md` + `spec-v4-data-organization.md`); the JSON panel is deleted. UI documents stay read-only in v4. `category` is a single structure value, not a chip list: the picker offers exactly the label map of `ui/projects.json` — the vocabulary rule 7 checks a project against — so a category with no label in both languages cannot be chosen from the UI; a brand-new category means adding its labels in the repository first. Field provenance: hovering any pencil shows `document → pointer` (`describeField()` names the per-entity file automatically); the EditBar diff line and a `validate:content` error for the same field read identically
|
||||||
- Dev parity: `vite.config.ts` builds the `/api/content/` dev proxy from the same `GITEA_CONTENTS_API` value production nginx renders — run `pnpm dev` with `GITEA_TOKEN` + `GITEA_CONTENTS_API` set (local `.env`); without them edit mode falls to the offline state (bundled content, save disabled)
|
- Dev parity: `vite.config.ts` builds the `/api/content/` dev proxy from the same `GITEA_CONTENTS_API` value production nginx renders — run `pnpm dev` with `GITEA_TOKEN` + `GITEA_CONTENTS_API` set (local `.env`); without them edit mode falls to the offline state (bundled content, save disabled)
|
||||||
- Spec: `docs/design/specs/v4/spec-v4-live-edit.md` §5–§6
|
- Spec: `docs/design/specs/v4/spec-v4-live-edit.md` §5–§6
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ Each chip is an edit unit: pencil per chip (inline text edit), `×` on hover to
|
|||||||
### 2.4 Record settings popover (E2)
|
### 2.4 Record settings popover (E2)
|
||||||
|
|
||||||
Gear icon on cards/entries opens a small popover anchored to the record:
|
Gear icon on cards/entries opens a small popover anchored to the record:
|
||||||
- project card: `featured` toggle, sections list (type picker, move, delete — add lives inline at §2.3);
|
- project card: `featured` toggle, `category` select (added 2026-10-24: the options are the label map of `ui/projects.json`, i.e. the vocabulary rule 7 checks a project against — a category with no label in both languages cannot be chosen, and a brand-new one needs its labels added in the repository first, since UI documents stay read-only in v4), sections list (type picker, move, delete — add lives inline at §2.3);
|
||||||
- timeline entry: `variant` select (none / current / gap), `logo` path text input;
|
- timeline entry: `variant` select (none / current / gap), `logo` path text input;
|
||||||
- nothing else needs a popover — every other field has an inline home.
|
- nothing else needs a popover — every other field has an inline home.
|
||||||
|
|
||||||
@@ -75,7 +75,7 @@ Page manifests (`spec-v4-data-organization.md` §5) are **read-only in the app**
|
|||||||
|---|---|---|
|
|---|---|---|
|
||||||
| Upgrade | `EditableText.tsx` | wrapper zone + pencil trigger (icon-only editing), inline error display, provenance tooltip + chip (E7) |
|
| Upgrade | `EditableText.tsx` | wrapper zone + pencil trigger (icon-only editing), inline error display, provenance tooltip + chip (E7) |
|
||||||
| New | `TagListEditor.tsx` | per-chip edit/delete/move + ghost add; emphasis toggle for tagline |
|
| New | `TagListEditor.tsx` | per-chip edit/delete/move + ghost add; emphasis toggle for tagline |
|
||||||
| New | `RecordSettings.tsx` | popover form: featured, variant, logo, section list |
|
| New | `RecordSettings.tsx` | popover form: featured, variant, logo, section list — plus the project `category` select (follow-up 11) |
|
||||||
| New | `AddRecord.tsx` | ghost affordance + template trigger + (sections) type picker |
|
| New | `AddRecord.tsx` | ghost affordance + template trigger + (sections) type picker |
|
||||||
| New | move controls | ↑/↓ buttons shared by `TagListEditor` and record cards |
|
| New | move controls | ↑/↓ buttons shared by `TagListEditor` and record cards |
|
||||||
| Delete | `JsonPanel.tsx` | removed outright — no fallback drawer, no advanced mode |
|
| Delete | `JsonPanel.tsx` | removed outright — no fallback drawer, no advanced mode |
|
||||||
@@ -116,3 +116,5 @@ Page manifests (`spec-v4-data-organization.md` §5) are **read-only in the app**
|
|||||||
| 8 | Remove `JsonPanel` + panel labels | ✅ Done 2026-10-23 — `JsonPanel.tsx` deleted (already orphaned by the inline wiring; no imports remained); panel labels removed from both UI documents: `openPanel`, `closePanel`, `handMerge`, the whole `edit.panel.*` namespace |
|
| 8 | Remove `JsonPanel` + panel labels | ✅ Done 2026-10-23 — `JsonPanel.tsx` deleted (already orphaned by the inline wiring; no imports remained); panel labels removed from both UI documents: `openPanel`, `closePanel`, `handMerge`, the whole `edit.panel.*` namespace |
|
||||||
| 9 | Docs superseded notes | ✅ Done 2026-10-23 — superseded notes at live-edit §5.1 (panel shape) and §12 row 14; AGENTS.md "Live Edit Mode" + "Component Structure" rewritten for the inline surface |
|
| 9 | Docs superseded notes | ✅ Done 2026-10-23 — superseded notes at live-edit §5.1 (panel shape) and §12 row 14; AGENTS.md "Live Edit Mode" + "Component Structure" rewritten for the inline surface |
|
||||||
| — | Acceptance §6 | 🟡 Partial — `pnpm build`, `pnpm validate:content`, `pnpm lint` (no new warnings), `pnpm tsx scripts/smoke-draft.ts`, `pnpm build:resume-all` pass 2026-10-23; browser verification of the edit surfaces pending (user verifies in a real browser) |
|
| — | Acceptance §6 | 🟡 Partial — `pnpm build`, `pnpm validate:content`, `pnpm lint` (no new warnings), `pnpm tsx scripts/smoke-draft.ts`, `pnpm build:resume-all` pass 2026-10-23; browser verification of the edit surfaces pending (user verifies in a real browser) |
|
||||||
|
| 10 | Fix (owner-reported 2026-10-24): clicking "add technology" on a project card opened the project instead of adding a tag | ✅ Done 2026-10-24 (automated) — root cause: the card body IS a link (`MotionLink` at `Projects.tsx:49`, `ProjectsListPage.tsx:39`), and the add chip was the one edit control inside it without a guard. The chips themselves are safe because they render through `EditableText`, whose edit-mode `onClick` does `preventDefault + stopPropagation` (`EditableText.tsx:239-242`) — that is why ↑/↓/🗑 worked — and the pencil suppresses its own mousedown. `TagListEditor`'s add button now carries both guards (`TagListEditor.tsx:126-138`): mousedown stopped, then `preventDefault + stopPropagation` on click before `write([...items, s.edit.newTag])`. Covers the technologies *and* the metrics add on both card surfaces; the same control in `Hero.tsx` (tagline), `Expertise.tsx`, `AboutPage`, `ExperiencePage`, `PhilosophyPage`, `ProjectDetailPage` and the settings popovers sits outside any anchor and is untouched. Verified: `pnpm build` ✓, `pnpm lint` (only the five pre-existing warnings). ⬜ Browser: `?edit` → add a technology on a card → a new chip appears, no navigation |
|
||||||
|
| 11 | Fix (owner-reported 2026-10-24): a project's `category` had no edit control at all — the settings popover covered `featured` + sections only, the badge is display-only, and a new project silently gets `category: 'experiment'` (`draft.ts:546`) | ✅ Done 2026-10-24 (automated) — `ProjectSettingsPanel` now renders a `category` `<select>` (`RecordSettings.tsx:59-90`): options = the label map of `ui/projects.json` (`new Map(Object.entries(s.projects.categories))`) with the current value appended, so the panel never rewrites a project whose label is missing; the write is `edit.setStructured('projects', '[i].category', value)` — the exact call `smoke-draft.ts` check 11 already gates (a labeled value is accepted, a label-less one is rejected naming both `ui/projects.json` files). `ui.edit.category` label added to both languages (`ui/edit.json:15`). CSS: `.record-settings-field select` joins the field-control rule (`App.css:2487-2488`) — the timeline `variant` select, which had no rule of its own, is now styled too. Vocabulary measured from the shipped dictionaries: 6 labeled categories (`software-engineering, logistics, ai-ml, computer-vision, architecture, experiment`), 2 in use, 4 assignable that were unreachable before, none used-but-unlabeled, en/vi key sets identical. Verified: `pnpm build`, `pnpm validate:content`, `pnpm lint` (the 5 pre-existing warnings only), `pnpm tsx scripts/smoke-draft.ts` 11/11. Out of scope by design: creating a category with no labels — UI documents stay read-only in v4, so its labels are a repository edit. ⬜ Browser: ⚙ on a project card → the select shows the current category, switching it updates the badge and the EditBar diff |
|
||||||
@@ -150,6 +150,8 @@ export type { ProjectCategory, ExperienceId, PhilosophyId, ProjectId, SkillGroup
|
|||||||
|
|
||||||
In `collectContentIssues` (`src/i18n/validate.ts:69-168`), after rule 6: for each unique category in `structures.projects`, require `ui[lang].projects.categories[value]` to be a non-empty string for `vi` and `en`; issue path `src/i18n/locales/<lang>/ui/projects.json: categories.<value>`.
|
In `collectContentIssues` (`src/i18n/validate.ts:69-168`), after rule 6: for each unique category in `structures.projects`, require `ui[lang].projects.categories[value]` to be a non-empty string for `vi` and `en`; issue path `src/i18n/locales/<lang>/ui/projects.json: categories.<value>`.
|
||||||
|
|
||||||
|
The same label map is the **category vocabulary in the editing UI**: `ProjectSettingsPanel`'s category select (`spec-v4-inline-editing.md` §2.4, follow-up 11, added 2026-10-24) offers `Object.entries(ui.<lang>.projects.categories)` plus the project's current value and writes through `setStructured('projects', '[i].category', …)`. A value chosen from that list has a label in the bundle by construction; when the branch's copy of `ui/projects.json` lacks it, the write is rejected with exactly this rule-7 issue naming both files. Rule 7 therefore stays the gate for a category written straight into `src/data/projects.json` — the editor cannot bypass it, only pre-fill it.
|
||||||
|
|
||||||
**Plumbing — corrected by the self-review.** The draft store does **not** hold UI documents: `DRAFT_DOCS` (`draft.ts:48-61`) is exactly the 12 writable content documents, and `DraftStore.validate()` (`draft.ts:585-588`) calls `collectContentIssues` with structures and content texts only. The rule therefore needs a UI source at each call site, and `collectContentIssues` / `validateContent` gain a `ui` argument:
|
**Plumbing — corrected by the self-review.** The draft store does **not** hold UI documents: `DRAFT_DOCS` (`draft.ts:48-61`) is exactly the 12 writable content documents, and `DraftStore.validate()` (`draft.ts:585-588`) calls `collectContentIssues` with structures and content texts only. The rule therefore needs a UI source at each call site, and `collectContentIssues` / `validateContent` gain a `ui` argument:
|
||||||
|
|
||||||
- `src/i18n/index.ts` (load-time): both UI trees are already built there — pass them.
|
- `src/i18n/index.ts` (load-time): both UI trees are already built there — pass them.
|
||||||
|
|||||||
+2
-1
@@ -2484,7 +2484,8 @@
|
|||||||
margin: 8px 0;
|
margin: 8px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.record-settings-field input {
|
.record-settings-field input,
|
||||||
|
.record-settings-field select {
|
||||||
background: var(--bg-surface);
|
background: var(--bg-surface);
|
||||||
color: inherit;
|
color: inherit;
|
||||||
border: 1px solid var(--border);
|
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,
|
// A project's structure: featured visibility, its category, and the section
|
||||||
// type, delete, add (spec-v4-inline-editing §2.4).
|
// list — order, type, delete, add (spec-v4-inline-editing §2.4).
|
||||||
export function ProjectSettingsPanel({ project }: { project: ProjectStructure }) {
|
export function ProjectSettingsPanel({ project }: { project: ProjectStructure }) {
|
||||||
const edit = useEdit();
|
const edit = useEdit();
|
||||||
const { ui: s } = useI18n();
|
const { ui: s } = useI18n();
|
||||||
@@ -56,6 +56,12 @@ export function ProjectSettingsPanel({ project }: { project: ProjectStructure })
|
|||||||
if (index < 0) return null;
|
if (index < 0) return null;
|
||||||
const sections = project.sections;
|
const sections = project.sections;
|
||||||
const typeLabels = s.edit.sectionTypes;
|
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 (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -68,6 +74,21 @@ export function ProjectSettingsPanel({ project }: { project: ProjectStructure })
|
|||||||
{s.edit.featured}
|
{s.edit.featured}
|
||||||
</label>
|
</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>
|
<div className="record-settings-group-title">{s.edit.sections}</div>
|
||||||
<ul className="record-settings-list">
|
<ul className="record-settings-list">
|
||||||
{sections.map((section, i) => (
|
{sections.map((section, i) => (
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
"newTag": "new",
|
"newTag": "new",
|
||||||
"emphasis": "Emphasis",
|
"emphasis": "Emphasis",
|
||||||
"featured": "Featured on the home page",
|
"featured": "Featured on the home page",
|
||||||
|
"category": "Category",
|
||||||
"sections": "Sections",
|
"sections": "Sections",
|
||||||
"sectionType": "Section type",
|
"sectionType": "Section type",
|
||||||
"sectionTypes": {
|
"sectionTypes": {
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
"newTag": "mới",
|
"newTag": "mới",
|
||||||
"emphasis": "Nhấn mạnh",
|
"emphasis": "Nhấn mạnh",
|
||||||
"featured": "Nổi bật",
|
"featured": "Nổi bật",
|
||||||
|
"category": "Danh mục",
|
||||||
"sections": "Các mục",
|
"sections": "Các mục",
|
||||||
"sectionType": "Kiểu mục",
|
"sectionType": "Kiểu mục",
|
||||||
"sectionTypes": {
|
"sectionTypes": {
|
||||||
|
|||||||
Reference in new issue
Block a user