feat: Note editing (edit form + PUT proxy + Edit button) #27

Closed
opened 2026-03-15 01:53:47 +00:00 by forgejo_admin · 0 comments

Lineage

plan-pal-e-docs → Phase F8 (Note Editing)

Repo

forgejo_admin/pal-e-app

User Story

As an authenticated pal-e-app user
I want to edit existing notes from the browser
So that I can update titles, content, tags, and metadata without using the API directly

Context

Notes can be created via Quick-Jot but cannot be edited from the browser. The backend PUT /notes/{slug} endpoint exists and fully works — it supports title, slug, html_content, is_public, project_slug, tags, note_type, status, parent_slug, and position updates. The backend also auto-creates revisions when html_content changes. The frontend just needs an edit form + API proxy.

File Targets

Files to create:

  • src/routes/api/notes/[slug]/+server.ts — PUT proxy (authenticated, forwards to backend PUT /notes/{slug})
  • src/routes/notes/[slug]/edit/+page.svelte — edit form
  • src/routes/notes/[slug]/edit/+page.server.ts — load note data for editing

Files to modify:

  • src/lib/api.ts — add updateNote(slug, data) function, add getNoteLinks(slug) if needed
  • src/lib/components/NoteLayout.svelte — add Edit button (visible only to authenticated users)
  • src/routes/notes/[slug]/+page.svelte — pass session to NoteLayout for auth check
  • src/routes/notes/[slug]/+page.server.ts — include session in returned data

Files NOT to touch:

  • src/routes/api/notes/+server.ts — POST proxy is separate
  • src/auth.ts — no auth changes needed

Acceptance Criteria

  • When I click Edit on a note detail page while authenticated, I navigate to /notes/{slug}/edit
  • When the edit page loads, all fields are pre-populated with current note data
  • When I change the title and save, the note title is updated
  • When I change the body and save, a revision is created (backend handles this)
  • When I change tags (comma-separated), they are updated
  • When I save, I am redirected back to /notes/{slug}
  • When I am not authenticated, the Edit button is not visible
  • When I PUT /api/notes/{slug} without auth, I get 401

Test Expectations

  • Build passes: npm run build
  • Manual test: edit a note, verify changes persist
  • Run command: cd ~/pal-e-app && npm run build

Constraints

  • Match existing dark theme (bg-[#0a0a14], border-[#1a1a2e], accent #e94560)
  • Form fields match QuickJot styling (same input/select classes)
  • Body editing is raw HTML textarea for now (no WYSIWYG)
  • NoteType options: plan, phase, sop, convention, issue, todo, template, project-page, skill, agent, doc, reference, sprint, incident, journal, post
  • Status options depend on note_type — use VALID_STATUSES from backend or hardcode the map
  • Tags input: comma-separated string, split on save
  • The PUT proxy must forward the full body to backend PUT /notes/{slug} — backend handles partial updates (null fields are skipped)
  • Session/auth info needs to flow from +page.server.ts through +page.svelte to NoteLayout component

Checklist

  • PR opened
  • Tests pass
  • No unrelated changes
  • pal-e-docs — project this affects
### Lineage `plan-pal-e-docs` → Phase F8 (Note Editing) ### Repo `forgejo_admin/pal-e-app` ### User Story As an authenticated pal-e-app user I want to edit existing notes from the browser So that I can update titles, content, tags, and metadata without using the API directly ### Context Notes can be created via Quick-Jot but cannot be edited from the browser. The backend PUT /notes/{slug} endpoint exists and fully works — it supports title, slug, html_content, is_public, project_slug, tags, note_type, status, parent_slug, and position updates. The backend also auto-creates revisions when html_content changes. The frontend just needs an edit form + API proxy. ### File Targets Files to create: - `src/routes/api/notes/[slug]/+server.ts` — PUT proxy (authenticated, forwards to backend PUT /notes/{slug}) - `src/routes/notes/[slug]/edit/+page.svelte` — edit form - `src/routes/notes/[slug]/edit/+page.server.ts` — load note data for editing Files to modify: - `src/lib/api.ts` — add `updateNote(slug, data)` function, add `getNoteLinks(slug)` if needed - `src/lib/components/NoteLayout.svelte` — add Edit button (visible only to authenticated users) - `src/routes/notes/[slug]/+page.svelte` — pass session to NoteLayout for auth check - `src/routes/notes/[slug]/+page.server.ts` — include session in returned data Files NOT to touch: - `src/routes/api/notes/+server.ts` — POST proxy is separate - `src/auth.ts` — no auth changes needed ### Acceptance Criteria - [ ] When I click Edit on a note detail page while authenticated, I navigate to /notes/{slug}/edit - [ ] When the edit page loads, all fields are pre-populated with current note data - [ ] When I change the title and save, the note title is updated - [ ] When I change the body and save, a revision is created (backend handles this) - [ ] When I change tags (comma-separated), they are updated - [ ] When I save, I am redirected back to /notes/{slug} - [ ] When I am not authenticated, the Edit button is not visible - [ ] When I PUT /api/notes/{slug} without auth, I get 401 ### Test Expectations - [ ] Build passes: `npm run build` - [ ] Manual test: edit a note, verify changes persist - Run command: `cd ~/pal-e-app && npm run build` ### Constraints - Match existing dark theme (bg-[#0a0a14], border-[#1a1a2e], accent #e94560) - Form fields match QuickJot styling (same input/select classes) - Body editing is raw HTML textarea for now (no WYSIWYG) - NoteType options: plan, phase, sop, convention, issue, todo, template, project-page, skill, agent, doc, reference, sprint, incident, journal, post - Status options depend on note_type — use VALID_STATUSES from backend or hardcode the map - Tags input: comma-separated string, split on save - The PUT proxy must forward the full body to backend PUT /notes/{slug} — backend handles partial updates (null fields are skipped) - Session/auth info needs to flow from +page.server.ts through +page.svelte to NoteLayout component ### Checklist - [ ] PR opened - [ ] Tests pass - [ ] No unrelated changes ### Related - `pal-e-docs` — project this affects
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
forgejo_admin/pal-e-docs-app#27
No description provided.